Fossil

Check-in [b7fc4d9d]
Login

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

Overview
Comment:Extended test-import-manifest to return not only the record-id, but the hash uuid as well. Extended the fossil accessor class with methods for regular and branch tagging. Split the initialization from construction (needed for when we split the import pass into three), and a method to set/retrieve the accessor's configuration (persistence across passes).
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:b7fc4d9d047d993a345ef54bdf50e0b5ecae58a7
User & Date: aku 2008-03-05 03:35:16
Context
2008-03-05
03:42
Extended main import method (pushto) to handle all types of changesets, not only revisions. Tag changesets lead to tagging of imported revisions, branch changesets reflect the proper location where branches start, and make it possible to handle tagging of branches without revisions as well. Modified code returning changesets for a projects to return all, not only revision, in sync with the previous. Changed the code determining tag/branch lod's to use table 'preferedparent'. check-in: 983090a3 user: aku tags: trunk
03:35
Extended test-import-manifest to return not only the record-id, but the hash uuid as well. Extended the fossil accessor class with methods for regular and branch tagging. Split the initialization from construction (needed for when we split the import pass into three), and a method to set/retrieve the accessor's configuration (persistence across passes). check-in: b7fc4d9d user: aku tags: trunk
03:30
Remember #commits to a workspace (= lod), and also their parental relationship. This will be used to control branch tagging (add/cancel), and provides us with the proper names for the tags as well. check-in: 011fb38d user: aku tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/checkin.c.

585
586
587
588
589
590
591


592
593
594
595
596
597
598
...
803
804
805
806
807
808
809

810
811
812
813
814
815
816
817

818

819
820
821
822
  Blob manifest;        /* container for the manifest to be generated */
  Blob mcksum;          /* Self-checksum on the manifest */
  Blob cksum, cksum2;   /* Before and after commit checksums */
  Blob cksum1b;         /* Checksum recorded in the manifest */
  const char* parent;   /* loop variable when collecting parent references */
  int i, mid;           /* Another loop index, and id of new manifest */
  Stmt q;               /* sql statement to query table of files */



#define USAGE ("DATE COMMENT ?-p|-parent PARENT_RID...? ?-f|-file (FILE_RID PATH)...?")

  /*
  ** Validate and process arguments, collect information.
  */

................................................................................

  /*
  ** At last commit all changes, after getting rid of the temp
  ** holder for the files, and release allocated memory.
  */

  db_multi_exec("DROP TABLE __im");

  db_end_transaction(0);
  free(zParents);

  /*
  ** At the very last inform the caller about the id of the new
  ** manifest.
  */


  printf("inserted as record %d\n", mid);

  return;

#undef USAGE
}







>
>







 







>




|
|


>
|
>




585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
...
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
  Blob manifest;        /* container for the manifest to be generated */
  Blob mcksum;          /* Self-checksum on the manifest */
  Blob cksum, cksum2;   /* Before and after commit checksums */
  Blob cksum1b;         /* Checksum recorded in the manifest */
  const char* parent;   /* loop variable when collecting parent references */
  int i, mid;           /* Another loop index, and id of new manifest */
  Stmt q;               /* sql statement to query table of files */
  char* zMidUuid;       /* Uuid for the newly generated manifest */


#define USAGE ("DATE COMMENT ?-p|-parent PARENT_RID...? ?-f|-file (FILE_RID PATH)...?")

  /*
  ** Validate and process arguments, collect information.
  */

................................................................................

  /*
  ** At last commit all changes, after getting rid of the temp
  ** holder for the files, and release allocated memory.
  */

  db_multi_exec("DROP TABLE __im");
  zMidUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
  db_end_transaction(0);
  free(zParents);

  /*
  ** At the very last inform the caller about the id and uuid of the
  ** new manifest.
  */


  printf("inserted as record %d, %s\n", mid, zMidUuid);
  free(zMidUuid);
  return;

#undef USAGE
}

Changes to tools/cvs2fossil/lib/c2f_fossil.tcl.

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
..
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
...
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
...
188
189
190
191
192
193
194

195
196
197
198
199
200
201
##

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

    constructor {} {




	set myrepository [fileutil::tempfile cvs2fossil_repo_]
	set myworkspace  [fileutil::tempfile cvs2fossil_wspc_]
	::file delete $myworkspace
	::file mkdir  $myworkspace

	Do new [::file nativename $myrepository]
	$self InWorkspace ; Do open [::file nativename $myrepository]
	$self RestorePwd

	log write 8 fossil {scratch repository $myrepository}
	log write 8 fossil {scratch workspace  $myworkspace}
	return
    }














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

    method root {} {
	# The id of the root manifest is hardwired into fossil. This
	# manifest is created when a new repository is made (See
................................................................................
	$self RestorePwd

	log write 3 fossil Done.
	return [array get id]
    }

    method importrevision {label user message date parent revisions} {
	# TODO = Write the actual import, and up the log level.

	# Massage the commit message to remember the old user name
	# which did the commit in CVS.

	set message "By $user:\n$message"

	log write 2 fossil {== $user @ [clock format $date]}
	log write 2 fossil {-> $parent}
................................................................................
	log write 12 fossil {	[lreplace $cmd 3 3 @@]}

	$self InWorkspace
	set res [eval $cmd]
	$self RestorePwd

	integrity assert {
	    [regexp {^inserted as record \d+$} $res]
	} {Unable to process unexpected fossil output '$res'}

	set uuid [lindex $res 3]

	log write 2 fossil {== $uuid}





	log write 2 fossil { }











	log write 2 fossil { }




	return $uuid
    }














    method finalize {destination} {

	Do rebuild [::file nativename $myrepository]

	::file rename -force $myrepository $destination
	::file delete -force $myworkspace
	$self destroy

	log write 2 fossil {destination $destination}
................................................................................
				  # tell us where fossil lives or not.

    # # ## ### ##### ######## #############
    ## Internal methods

    proc Do {args} {
	# 8.5: exec $myfossilcmd {*}$args

	return [eval [linsert $args 0 exec $myfossilcmd]]
    }

    method InWorkspace {} { set mypwd [pwd] ; cd $myworkspace ; return }
    method RestorePwd  {} { cd $mypwd       ; set mypwd {}    ; return }

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







>
>
>
>









|
|


>
>
>
>
>
>
>
>
>
>
>
>
>







 







<
<







 







|

>
|

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

>
>
>
|


>
>
>
>
>
>
>
>
>
>
>
>
>

>







 







>







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
...
112
113
114
115
116
117
118


119
120
121
122
123
124
125
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
##

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

    constructor {} {
	return
    }

    method initialize {} {
	set myrepository [fileutil::tempfile cvs2fossil_repo_]
	set myworkspace  [fileutil::tempfile cvs2fossil_wspc_]
	::file delete $myworkspace
	::file mkdir  $myworkspace

	Do new [::file nativename $myrepository]
	$self InWorkspace ; Do open [::file nativename $myrepository]
	$self RestorePwd

	log write 8 fossil {Scratch repository created @ $myrepository}
	log write 8 fossil {Scratch workspace  created @ $myworkspace }
	return
    }

    method load {r w} {
	set myrepository $r
	set myworkspace  $w

	log write 8 fossil {Scratch repository found @ $myrepository}
	log write 8 fossil {Scratch workspace  found @ $myworkspace}
	return
    }

    method space {} {
	return [list $myrepository $myworkspace]
    }

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

    method root {} {
	# The id of the root manifest is hardwired into fossil. This
	# manifest is created when a new repository is made (See
................................................................................
	$self RestorePwd

	log write 3 fossil Done.
	return [array get id]
    }

    method importrevision {label user message date parent revisions} {


	# Massage the commit message to remember the old user name
	# which did the commit in CVS.

	set message "By $user:\n$message"

	log write 2 fossil {== $user @ [clock format $date]}
	log write 2 fossil {-> $parent}
................................................................................
	log write 12 fossil {	[lreplace $cmd 3 3 @@]}

	$self InWorkspace
	set res [eval $cmd]
	$self RestorePwd

	integrity assert {
	    [regexp {^inserted as record \d+, [0-9a-fA-F]+$} $res]
	} {Unable to process unexpected fossil output '$res'}
	set rid  [string trim [lindex $res 3] ,]
	set uuid [lindex $res 4]

	log write 2 fossil {== $rid ($uuid)}

	return [list $rid $uuid]
    }

    method tag {uuid name} {
	log write 2 fossil {Tag '$name' @ $uuid}

	$self InWorkspace
	Do tag add sym-$name $uuid
	$self RestorePwd
	return
    }

    method branchmark {uuid name} {
	# We do not mark the trunk
	if {$name eq ":trunk:"} return

	log write 2 fossil {Begin branch '$name' @ $uuid}

	$self InWorkspace
	Do tag branch sym-$name $uuid
	$self RestorePwd
	return
    }

    method branchcancel {uuid name} {
	# The trunk is unmarked, thus cancellation is not needed
	# either.
	if {$name eq ":trunk:"} return

	log write 2 fossil {Cancel branch '$name' @ $uuid}

	$self InWorkspace
	Do tag delete sym-$name $uuid
	$self RestorePwd
	return
    }

    method finalize {destination} {
	log write 2 fossil {Finalize, rebuilding repository}
	Do rebuild [::file nativename $myrepository]

	::file rename -force $myrepository $destination
	::file delete -force $myworkspace
	$self destroy

	log write 2 fossil {destination $destination}
................................................................................
				  # tell us where fossil lives or not.

    # # ## ### ##### ######## #############
    ## Internal methods

    proc Do {args} {
	# 8.5: exec $myfossilcmd {*}$args
	log write 14 fossil {Doing '$args'}
	return [eval [linsert $args 0 exec $myfossilcmd]]
    }

    method InWorkspace {} { set mypwd [pwd] ; cd $myworkspace ; return }
    method RestorePwd  {} { cd $mypwd       ; set mypwd {}    ; return }

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