File: c2f_ristate.tcl

package info (click to toggle)
fossil 1%3A1.22.1%2Bdfsg-0.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 10,588 kB
  • sloc: ansic: 151,799; tcl: 10,291; sh: 4,413; makefile: 1,822; sql: 376
file content (113 lines) | stat: -rw-r--r-- 3,485 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
## -*- tcl -*-
# # ## ### ##### ######## ############# #####################
## Copyright (c) 2008 Andreas Kupries.
#
# This software is licensed as described in the file LICENSE, which
# you should have received as part of this distribution.
#
# This software consists of voluntary contributions made by many
# individuals.  For exact contribution history, see the revision
# history and logs, available at http://fossil-scm.hwaci.com/fossil
# # ## ### ##### ######## ############# #####################

## Track the state of revision import. Essentially maps lines of
## developments to their workspace state.

# # ## ### ##### ######## ############# #####################
## Requirements

package require Tcl 8.4                               ; # Required runtime.
package require snit                                  ; # OO system.
package require struct::list                          ; # List assignment
package require vc::fossil::import::cvs::wsstate      ; # Workspace state
package require vc::fossil::import::cvs::integrity    ; # State integrity checks.
package require vc::tools::log                        ; # User feedback.
package require vc::tools::trouble                    ; # Error reporting.

# # ## ### ##### ######## ############# #####################
##

snit::type ::vc::fossil::import::cvs::ristate {
    # # ## ### ##### ######## #############
    ## Public API

    constructor {} {
	# Start with an empty state
	return
    }

    method new {lod {parentlod {}}} {
	# Create a workspace for a line of development (LOD). If a
	# parent LOD is specified let the new workspace inherit the
	# current state of the parent.

	log write 8 ristate {Open workspace for LOD "$lod"}

	integrity assert {
	    ![info exists mystate($lod)]
	} {Trying to override existing state for lod "$lod"}

	set wss [wsstate ${selfns}::%AUTO% $lod]
	set mystate($lod) $wss

	if {$parentlod ne ""} {
	    log write 8 ristate {Inheriting from workspace for LOD "$parentlod"}

	    integrity assert {
		[info exists mystate($parentlod)]
	    } {Trying to inherit from undefined lod "$parentlod"}

	    set pwss $mystate($parentlod)

	    $wss defstate  [$pwss getstate]
	    $wss defid     [$pwss getid]
	    $wss defparent $pwss
	}

	return $wss
    }

    method get {lod} { return $mystate($lod) }
    method has {lod} { return [info exists mystate($lod)] }

    method names {} { return [array names mystate] }

    method dup {dst _from_ src} {
	log write 8 ristate {Duplicate workspace for LOD "$dst" from "$src"}
	set mystate($dst) $mystate($src)
	return
    }

    # # ## ### ##### ######## #############
    ## State

    variable mystate -array {} ; # Map from lines of development
				 # (identified by name) to their
				 # workspace.

    # # ## ### ##### ######## #############
    ## Configuration

    pragma -hastypeinfo    no  ; # no type introspection
    pragma -hasinfo        no  ; # no object introspection
    pragma -hastypemethods no  ; # type is not relevant.

    # # ## ### ##### ######## #############
}

namespace eval ::vc::fossil::import::cvs {
    namespace export ristate
    namespace eval ristate {
	namespace import ::vc::fossil::import::cvs::wsstate
	namespace import ::vc::fossil::import::cvs::integrity
	namespace import ::vc::tools::trouble
	namespace import ::vc::tools::log
	log register ristate
    }
}

# # ## ### ##### ######## ############# #####################
## Ready

package provide vc::fossil::import::cvs::ristate 1.0
return