Eskil

Check-in [cfc89c24fc]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cannot use fossil ls to get historical info. Instead parse the fileage web page.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cfc89c24fc7806789ba08cf09956609b4d1e4ce7
User & Date: peter 2015-02-25 02:27:47.845
Context
2015-02-25
22:37
Do not trigger a revision dirdiff when starting blank. check-in: ce73fe5d82 user: peter tags: trunk
02:27
Cannot use fossil ls to get historical info. Instead parse the fileage web page. check-in: cfc89c24fc user: peter tags: trunk
2015-02-24
00:05
Bumped revision to 2.7 check-in: c5289c72df user: peter tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vcsvfs.tcl.
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63


64
65
66







67
68
69
70




71
72
73
74
75
76
77








78
































































79
80
81
82
83
84
85
    # a sub directory was given.
    # Locate fossil root for the given directory.
    set info [exec fossil info]
    regexp -line {local-root:\s*(\S.*)} $info -> root
    set root [file normalize $root]
    cd $root

    # Getting files via ls
    set allfiles [exec fossil ls --age $rev .]
    foreach line [split $allfiles \n] {
        # Expected format in a line:
        # 2012-08-21 20:38:19  tests/rev.test
        regexp {(\S+ \S+)\s+(.+)} $line -> fDate fName
        dict set finfo $fName mtimestr $fDate
        dict set finfo $fName type file
        dict set finfo $fName isfile 1
        dict set finfo $fName isdir 0
        # Mark all known directory paths and build up file tree info
        set parentStr ""
        foreach dirPath [file split $fName] {
            dict set finfo $parentStr child $dirPath 1
            dict set finfo $parentStr isfile 0
            dict set finfo $parentStr isdir 1
            dict set finfo $parentStr type directory
            set parentStr [file join $parentStr $dirPath]
        }
    }
    # Getting files via artifact
    set artifact [exec fossil artifact $rev]


    foreach line [split $artifact \n] {
        # Expected format in a line:
        # F tests/left.txt c1572b3809a1ba6ab2de9307c96b1cfeefdcf0ba







        if {[regexp {F (\S+) (\S+)} $line -> fName fSha]} {
            # File names can have spaces, coded with \s
            set fName [string map {\\s " "} $fName]
            dict set finfo $fName sha $fSha




            # TBD: Delay calling whatis until size is needed
            # Expected format in a line:
            # size:    629 bytes
            set whatis [exec fossil whatis $fSha]
            regexp {size:\s+(\d+)} $whatis -> fSize
            dict set finfo $fName size $fSize
        }








    }
































































    cd $oldpwd

    # Generate a mount point.
    set tail [string range $dir [string length $root] end]
    set mountpoint "${root} ($rev)"

    dict set mpoints $mountpoint "finfo" $finfo







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


>
>



>
>
>
>
>
>
>




>
>
>
>






|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







35
36
37
38
39
40
41




















42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
    # a sub directory was given.
    # Locate fossil root for the given directory.
    set info [exec fossil info]
    regexp -line {local-root:\s*(\S.*)} $info -> root
    set root [file normalize $root]
    cd $root





















    # Getting files via artifact
    set artifact [exec fossil artifact $rev]
    set commitTime 0
    set cTime now
    foreach line [split $artifact \n] {
        # Expected format in a line:
        # F tests/left.txt c1572b3809a1ba6ab2de9307c96b1cfeefdcf0ba
        # D 2015-02-23T23:30:07.509
        if {[regexp {D (.*)} $line -> cTime]} {
            # Remove decimals and middle T
            regsub {\.\d+} $cTime "" cTime
            regsub {T} $cTime " " cTime
            set commitTime [clock scan $cTime -gmt 1]
        }
        if {[regexp {F (\S+) (\S+)} $line -> fName fSha]} {
            # File names can have spaces, coded with \s
            set fName [string map {\\s " "} $fName]
            dict set finfo $fName sha $fSha
            dict set finfo $fName mtimestr $cTime ;# Anything
            dict set finfo $fName type file
            dict set finfo $fName isfile 1
            dict set finfo $fName isdir 0
            # TBD: Delay calling whatis until size is needed
            # Expected format in a line:
            # size:    629 bytes
            set whatis [exec fossil whatis $fSha]
            regexp {size:\s+(\d+)} $whatis -> fSize
            dict set finfo $fName size $fSize

            # Mark all known directory paths and build up file tree info
            set parentStr ""
            foreach dirPath [file split $fName] {
                dict set finfo $parentStr child $dirPath 1
                dict set finfo $parentStr isfile 0
                dict set finfo $parentStr isdir 1
                dict set finfo $parentStr type directory
                set parentStr [file join $parentStr $dirPath]
            }
        }
    }

    # Getting files via http fileage to aquire file times
    set html [exec fossil http << "GET /fileage?name=$rev"]
    regexp {Files in.*} $html html
    regexp {\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}} $html cTime2
    set commitTime2 [clock scan $cTime2 -gmt 1]
    #puts "CT $commitTime  CT2 $commitTime2"
    foreach row [regexp -all -inline {<tr>.*?</tr>} $html] {
        set cols [regexp -all -inline {<td>(.*?)</td>} $row]
        set col1 [string trim [lindex $cols 1]]
        set col2 [string trim [lindex $cols 3]]
        # First column is age, in readable format
        # e.g. "current" "36.4 minutes" "97.0 days" "1.06 years"
        if {$col1 eq ""} continue
        if {$col1 eq "current"} {
            set fTime $commitTime
        } else {
            set value [lindex $col1 0]
            set unit [lindex $col1 1]
            switch -glob $unit {
                second* {
                    set value [expr {int($value)}]
                    set unit second
                }
                minute* {
                    set value [expr {int($value*60)}]
                    set unit second
                }
                hour* {
                    set value [expr {int($value*60*60)}]
                    set unit second
                }
                day* {
                    set value [expr {int($value*60*60*24)}]
                    set unit second
                }
                year* {
                    set value [expr {int($value*60*60*24*365)}]
                    set unit second
                }
                default {
                    puts "Unhandled unit: $unit in '$col1'"
                    set value [expr {int($value)}]
                }
            }
            set fTime [expr {$commitTime - $value}]
        }
        #puts "AGE $col1 -> $fTime"

        # Second column is file names, separated by <br>
        # Remove links
        regsub -all {<a .*?>} $col2 "" col2
        regsub -all {</a>} $col2 "" col2
        regsub -all {\n} $col2 "" col2
        regsub -all {<br>} $col2 "\n" col2
        set col2 [string trim $col2]
        foreach fName [split $col2 \n] {
            #puts $fName
            dict set finfo $fName mtime $fTime
        }
    }

    cd $oldpwd

    # Generate a mount point.
    set tail [string range $dir [string length $root] end]
    set mountpoint "${root} ($rev)"

    dict set mpoints $mountpoint "finfo" $finfo