|
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 revision import. Essentially maps lines of |
|
14
|
## developments to their workspace state. |
|
15
|
|
|
16
|
# # ## ### ##### ######## ############# ##################### |
|
17
|
## Requirements |
|
18
|
|
|
19
|
package require Tcl 8.4 ; # Required runtime. |
|
20
|
package require snit ; # OO system. |
|
21
|
package require struct::list ; # List assignment |
|
22
|
package require vc::fossil::import::cvs::wsstate ; # Workspace state |
|
23
|
package require vc::fossil::import::cvs::integrity ; # State integrity checks. |
|
24
|
package require vc::tools::log ; # User feedback. |
|
25
|
package require vc::tools::trouble ; # Error reporting. |
|
26
|
|
|
27
|
# # ## ### ##### ######## ############# ##################### |
|
28
|
## |
|
29
|
|
|
30
|
snit::type ::vc::fossil::import::cvs::ristate { |
|
31
|
# # ## ### ##### ######## ############# |
|
32
|
## Public API |
|
33
|
|
|
34
|
constructor {} { |
|
35
|
# Start with an empty state |
|
36
|
return |
|
37
|
} |
|
38
|
|
|
39
|
method new {lod {parentlod {}}} { |
|
40
|
# Create a workspace for a line of development (LOD). If a |
|
41
|
# parent LOD is specified let the new workspace inherit the |
|
42
|
# current state of the parent. |
|
43
|
|
|
44
|
log write 8 ristate {Open workspace for LOD "$lod"} |
|
45
|
|
|
46
|
integrity assert { |
|
47
|
![info exists mystate($lod)] |
|
48
|
} {Trying to override existing state for lod "$lod"} |
|
49
|
|
|
50
|
set wss [wsstate ${selfns}::%AUTO% $lod] |
|
51
|
set mystate($lod) $wss |
|
52
|
|
|
53
|
if {$parentlod ne ""} { |
|
54
|
log write 8 ristate {Inheriting from workspace for LOD "$parentlod"} |
|
55
|
|
|
56
|
integrity assert { |
|
57
|
[info exists mystate($parentlod)] |
|
58
|
} {Trying to inherit from undefined lod "$parentlod"} |
|
59
|
|
|
60
|
set pwss $mystate($parentlod) |
|
61
|
|
|
62
|
$wss defstate [$pwss getstate] |
|
63
|
$wss defid [$pwss getid] |
|
64
|
$wss defparent $pwss |
|
65
|
} |
|
66
|
|
|
67
|
return $wss |
|
68
|
} |
|
69
|
|
|
70
|
method get {lod} { return $mystate($lod) } |
|
71
|
method has {lod} { return [info exists mystate($lod)] } |
|
72
|
|
|
73
|
method names {} { return [array names mystate] } |
|
74
|
|
|
75
|
method dup {dst _from_ src} { |
|
76
|
log write 8 ristate {Duplicate workspace for LOD "$dst" from "$src"} |
|
77
|
set mystate($dst) $mystate($src) |
|
78
|
return |
|
79
|
} |
|
80
|
|
|
81
|
# # ## ### ##### ######## ############# |
|
82
|
## State |
|
83
|
|
|
84
|
variable mystate -array {} ; # Map from lines of development |
|
85
|
# (identified by name) to their |
|
86
|
# workspace. |
|
87
|
|
|
88
|
# # ## ### ##### ######## ############# |
|
89
|
## Configuration |
|
90
|
|
|
91
|
pragma -hastypeinfo no ; # no type introspection |
|
92
|
pragma -hasinfo no ; # no object introspection |
|
93
|
pragma -hastypemethods no ; # type is not relevant. |
|
94
|
|
|
95
|
# # ## ### ##### ######## ############# |
|
96
|
} |
|
97
|
|
|
98
|
namespace eval ::vc::fossil::import::cvs { |
|
99
|
namespace export ristate |
|
100
|
namespace eval ristate { |
|
101
|
namespace import ::vc::fossil::import::cvs::wsstate |
|
102
|
namespace import ::vc::fossil::import::cvs::integrity |
|
103
|
namespace import ::vc::tools::trouble |
|
104
|
namespace import ::vc::tools::log |
|
105
|
log register ristate |
|
106
|
} |
|
107
|
} |
|
108
|
|
|
109
|
# # ## ### ##### ######## ############# ##################### |
|
110
|
## Ready |
|
111
|
|
|
112
|
package provide vc::fossil::import::cvs::ristate 1.0 |
|
113
|
return |
|
114
|
|