|
1
|
## -*- tcl -*- |
|
2
|
# # ## ### ##### ######## ############# ##################### |
|
3
|
## Copyright (c) 2008 Andreas Kupries. |
|
4
|
# |
|
5
|
# This software is licensed as described in the file LICENSE, which |
|
6
|
# you should have received as part of this distribution. |
|
7
|
# |
|
8
|
# This software consists of voluntary contributions made by many |
|
9
|
# individuals. For exact contribution history, see the revision |
|
10
|
# history and logs, available at http://fossil-scm.hwaci.com/fossil |
|
11
|
# # ## ### ##### ######## ############# ##################### |
|
12
|
|
|
13
|
## Track the state of a cvs workspace as changesets are committed to |
|
14
|
## it. Nothing actually happens in the filesystem, this is completely |
|
15
|
## virtual. |
|
16
|
|
|
17
|
# # ## ### ##### ######## ############# ##################### |
|
18
|
## Requirements |
|
19
|
|
|
20
|
package require Tcl 8.4 ; # Required runtime. |
|
21
|
package require snit ; # OO system. |
|
22
|
package require struct::list ; # List assignment |
|
23
|
package require vc::tools::log ; # User feedback. |
|
24
|
|
|
25
|
# # ## ### ##### ######## ############# ##################### |
|
26
|
## |
|
27
|
|
|
28
|
snit::type ::vc::fossil::import::cvs::wsstate { |
|
29
|
# # ## ### ##### ######## ############# |
|
30
|
## Public API |
|
31
|
|
|
32
|
constructor {lod} { |
|
33
|
# Start with an empty state |
|
34
|
set myname $lod |
|
35
|
set myticks 0 |
|
36
|
set myparent {} |
|
37
|
return |
|
38
|
} |
|
39
|
|
|
40
|
method name {} { return $myname } |
|
41
|
method ticks {} { return $myticks } |
|
42
|
|
|
43
|
method add {oprevisioninfo} { |
|
44
|
# oprevisioninfo = list (rid path label op ...) /quadruples |
|
45
|
|
|
46
|
# Overwrite all changed files (identified by path) with the |
|
47
|
# new revisions. This keeps all unchanged files. Files marked |
|
48
|
# as dead are removed. |
|
49
|
|
|
50
|
foreach {rid path label rop} $oprevisioninfo { |
|
51
|
log write 5 wss {$myop($rop) $label} |
|
52
|
|
|
53
|
if {$rop < 0} { |
|
54
|
if {[catch { |
|
55
|
unset mystate($path) |
|
56
|
}]} { |
|
57
|
log write 0 wss "Removed path \"$path\" is not known to the workspace" |
|
58
|
} |
|
59
|
} else { |
|
60
|
set mystate($path) [list $rid $label] |
|
61
|
} |
|
62
|
} |
|
63
|
|
|
64
|
incr myticks |
|
65
|
return |
|
66
|
} |
|
67
|
|
|
68
|
method get {} { |
|
69
|
set res {} |
|
70
|
foreach path [lsort -dict [array names mystate]] { |
|
71
|
struct::list assign $mystate($path) rid label |
|
72
|
lappend res $rid $path $label |
|
73
|
} |
|
74
|
return $res |
|
75
|
} |
|
76
|
|
|
77
|
method defid {id} { |
|
78
|
set myid $id |
|
79
|
return |
|
80
|
} |
|
81
|
|
|
82
|
method getid {} { return $myid } |
|
83
|
|
|
84
|
method defstate {s} { array set mystate $s ; return } |
|
85
|
method getstate {} { return [array get mystate] } |
|
86
|
|
|
87
|
method parent {} { return $myparent } |
|
88
|
method defparent {parent} { |
|
89
|
set myparent $parent |
|
90
|
return |
|
91
|
} |
|
92
|
|
|
93
|
# # ## ### ##### ######## ############# |
|
94
|
## State |
|
95
|
|
|
96
|
variable myname {} ; # Name of the LOD the workspace is |
|
97
|
# for. |
|
98
|
variable myid {} ; # Record id of the fossil manifest |
|
99
|
# associated with the current state. |
|
100
|
variable mystate -array {} ; # Map from paths to the recordid of |
|
101
|
# the file revision behind it, and |
|
102
|
# the associated label for logging. |
|
103
|
variable myticks 0 ; # Number of 'add' operations |
|
104
|
# performed on the state. |
|
105
|
variable myparent {} ; # Reference to the parent workspace. |
|
106
|
|
|
107
|
typevariable myop -array { |
|
108
|
-1 REM |
|
109
|
0 --- |
|
110
|
1 ADD |
|
111
|
2 CHG |
|
112
|
} |
|
113
|
|
|
114
|
# # ## ### ##### ######## ############# |
|
115
|
## Configuration |
|
116
|
|
|
117
|
pragma -hastypeinfo no ; # no type introspection |
|
118
|
pragma -hasinfo no ; # no object introspection |
|
119
|
pragma -hastypemethods no ; # type is not relevant. |
|
120
|
|
|
121
|
# # ## ### ##### ######## ############# |
|
122
|
} |
|
123
|
|
|
124
|
namespace eval ::vc::fossil::import::cvs { |
|
125
|
namespace export wsstate |
|
126
|
namespace eval wsstate { |
|
127
|
namespace import ::vc::tools::log |
|
128
|
log register wss |
|
129
|
} |
|
130
|
} |
|
131
|
|
|
132
|
# # ## ### ##### ######## ############# ##################### |
|
133
|
## Ready |
|
134
|
|
|
135
|
package provide vc::fossil::import::cvs::wsstate 1.0 |
|
136
|
return |
|
137
|
|