Fossil SCM

Branching now working correctly, including adding of bgcolor tag and correct R line

jnc 2007-09-23 15:02 trunk
Commit 2ad378d06534c3bd0e33baf148514ac5d790b606
2 files changed +25 -24 +9 -3
+25 -24
--- src/branch.c
+++ src/branch.c
@@ -29,15 +29,15 @@
2929
#include <assert.h>
3030
3131
void branch_new(void){
3232
int vid, nvid, noSign;
3333
Stmt q;
34
- char *zBranch, *zUuid, *zDate, *zComment, *zManifestFile;
34
+ char *zBranch, *zUuid, *zDate, *zComment;
3535
const char *zColor;
3636
Blob manifest;
3737
Blob mcksum; /* Self-checksum on the manifest */
38
- Blob cksum1, cksum2, dskcksum1; /* Before and after commit checksums */
38
+ Blob cksum1, cksum2; /* Before and after commit checksums */
3939
Blob cksum1b; /* Checksum recorded in the manifest */
4040
4141
noSign = find_option("nosign","",0)!=0;
4242
db_must_be_within_tree();
4343
noSign = db_get_int("omit-ci-sig", 0)|noSign;
@@ -48,41 +48,29 @@
4848
/* fossil branch new name */
4949
if( g.argc<3 ){
5050
usage("branch new ?-bgcolor COLOR BRANCH-NAME");
5151
}
5252
zBranch = g.argv[3];
53
+ if( zBranch==0 || zBranch[0]==0 ){
54
+ fossil_panic("branch name cannot be empty");
55
+ }
5356
5457
user_select();
5558
db_begin_transaction();
5659
if( unsaved_changes() ){
5760
fossil_panic("there are uncommitted changes. please commit first");
5861
}
5962
60
- /* Create a new rid? */
61
- zManifestFile = mprintf("%smanifest", g.zLocalRoot);
62
- blob_read_from_file(&manifest, zManifestFile);
63
- free(zManifestFile);
64
-
65
- zDate = db_text(0, "SELECT datetime('now')");
66
- zDate[10] = 'T';
67
-
68
- blob_appendf(&manifest, "D %s\n", zDate);
69
- blob_appendf(&manifest, "T *%F *\n", zBranch);
70
-
71
- md5sum_init();
72
- md5sum_step_blob(&manifest);
73
- md5sum_finish(&cksum1);
74
-
75
- blob_reset(&manifest);
76
-
7763
vid = db_lget_int("checkout", 0);
78
- vfile_aggregate_checksum_disk(vid, &dskcksum1);
64
+ vfile_aggregate_checksum_disk(vid, &cksum1);
7965
8066
/* Create our new manifest */
8167
blob_zero(&manifest);
8268
zComment = mprintf("Branch created %s", zBranch);
8369
blob_appendf(&manifest, "C %F\n", zComment);
70
+ zDate = db_text(0, "SELECT datetime('now')");
71
+ zDate[10] = 'T';
8472
blob_appendf(&manifest, "D %s\n", zDate);
8573
8674
db_prepare(&q,
8775
"SELECT pathname, uuid FROM vfile JOIN blob ON vfile.mrid=blob.rid"
8876
" WHERE NOT deleted AND vfile.vid=%d"
@@ -97,13 +85,20 @@
9785
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
9886
blob_appendf(&manifest, "P %s\n", zUuid);
9987
blob_appendf(&manifest, "R %b\n", &cksum1);
10088
10189
if( zColor!=0 ){
102
- blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
90
+ if( strcmp("bgcolor",zBranch)>=0 ){
91
+ blob_appendf(&manifest, "T *%F *\n", zBranch);
92
+ blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
93
+ }else{
94
+ blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
95
+ blob_appendf(&manifest, "T *%F *\n", zBranch);
96
+ }
97
+ }else{
98
+ blob_appendf(&manifest, "T *%F *\n", zBranch);
10399
}
104
- blob_appendf(&manifest, "T *%F *\n", zBranch);
105100
106101
/* Cancel any tags that propagate */
107102
db_prepare(&q,
108103
"SELECT tagname"
109104
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
@@ -135,11 +130,17 @@
135130
}
136131
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
137132
manifest_crosslink(nvid, &manifest);
138133
content_deltify(vid, nvid, 0);
139134
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
140
- printf("New_Version: %s\n", zUuid);
135
+ printf("Branch Version: %s\n", zUuid);
136
+ printf("\n");
137
+ printf("Notice: working copy not updated to the new branch. If\n");
138
+ printf(" you wish to work on the new branch, update to\n");
139
+ printf(" that branch first:\n");
140
+ printf("\n");
141
+ printf(" fossil update %s\n", zBranch);
141142
142143
/* Verify that the manifest checksum matches the expected checksum */
143144
vfile_aggregate_checksum_repository(nvid, &cksum2);
144145
vfile_aggregate_checksum_manifest(nvid, &cksum2, &cksum1b);
145146
if( blob_compare(&cksum1, &cksum1b) ){
@@ -147,11 +148,11 @@
147148
"%b versus %b", &cksum1, &cksum1b);
148149
}
149150
150151
/* Verify that the commit did not modify any disk images. */
151152
vfile_aggregate_checksum_disk(vid, &cksum2);
152
- if( blob_compare(&dskcksum1, &cksum2) ){
153
+ if( blob_compare(&cksum1, &cksum2) ){
153154
fossil_panic("tree checksums before and after commit do not match");
154155
}
155156
156157
/* Clear the undo/redo stack */
157158
undo_reset();
158159
--- src/branch.c
+++ src/branch.c
@@ -29,15 +29,15 @@
29 #include <assert.h>
30
31 void branch_new(void){
32 int vid, nvid, noSign;
33 Stmt q;
34 char *zBranch, *zUuid, *zDate, *zComment, *zManifestFile;
35 const char *zColor;
36 Blob manifest;
37 Blob mcksum; /* Self-checksum on the manifest */
38 Blob cksum1, cksum2, dskcksum1; /* Before and after commit checksums */
39 Blob cksum1b; /* Checksum recorded in the manifest */
40
41 noSign = find_option("nosign","",0)!=0;
42 db_must_be_within_tree();
43 noSign = db_get_int("omit-ci-sig", 0)|noSign;
@@ -48,41 +48,29 @@
48 /* fossil branch new name */
49 if( g.argc<3 ){
50 usage("branch new ?-bgcolor COLOR BRANCH-NAME");
51 }
52 zBranch = g.argv[3];
 
 
 
53
54 user_select();
55 db_begin_transaction();
56 if( unsaved_changes() ){
57 fossil_panic("there are uncommitted changes. please commit first");
58 }
59
60 /* Create a new rid? */
61 zManifestFile = mprintf("%smanifest", g.zLocalRoot);
62 blob_read_from_file(&manifest, zManifestFile);
63 free(zManifestFile);
64
65 zDate = db_text(0, "SELECT datetime('now')");
66 zDate[10] = 'T';
67
68 blob_appendf(&manifest, "D %s\n", zDate);
69 blob_appendf(&manifest, "T *%F *\n", zBranch);
70
71 md5sum_init();
72 md5sum_step_blob(&manifest);
73 md5sum_finish(&cksum1);
74
75 blob_reset(&manifest);
76
77 vid = db_lget_int("checkout", 0);
78 vfile_aggregate_checksum_disk(vid, &dskcksum1);
79
80 /* Create our new manifest */
81 blob_zero(&manifest);
82 zComment = mprintf("Branch created %s", zBranch);
83 blob_appendf(&manifest, "C %F\n", zComment);
 
 
84 blob_appendf(&manifest, "D %s\n", zDate);
85
86 db_prepare(&q,
87 "SELECT pathname, uuid FROM vfile JOIN blob ON vfile.mrid=blob.rid"
88 " WHERE NOT deleted AND vfile.vid=%d"
@@ -97,13 +85,20 @@
97 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
98 blob_appendf(&manifest, "P %s\n", zUuid);
99 blob_appendf(&manifest, "R %b\n", &cksum1);
100
101 if( zColor!=0 ){
102 blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
 
 
 
 
 
 
 
 
103 }
104 blob_appendf(&manifest, "T *%F *\n", zBranch);
105
106 /* Cancel any tags that propagate */
107 db_prepare(&q,
108 "SELECT tagname"
109 " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
@@ -135,11 +130,17 @@
135 }
136 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
137 manifest_crosslink(nvid, &manifest);
138 content_deltify(vid, nvid, 0);
139 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
140 printf("New_Version: %s\n", zUuid);
 
 
 
 
 
 
141
142 /* Verify that the manifest checksum matches the expected checksum */
143 vfile_aggregate_checksum_repository(nvid, &cksum2);
144 vfile_aggregate_checksum_manifest(nvid, &cksum2, &cksum1b);
145 if( blob_compare(&cksum1, &cksum1b) ){
@@ -147,11 +148,11 @@
147 "%b versus %b", &cksum1, &cksum1b);
148 }
149
150 /* Verify that the commit did not modify any disk images. */
151 vfile_aggregate_checksum_disk(vid, &cksum2);
152 if( blob_compare(&dskcksum1, &cksum2) ){
153 fossil_panic("tree checksums before and after commit do not match");
154 }
155
156 /* Clear the undo/redo stack */
157 undo_reset();
158
--- src/branch.c
+++ src/branch.c
@@ -29,15 +29,15 @@
29 #include <assert.h>
30
31 void branch_new(void){
32 int vid, nvid, noSign;
33 Stmt q;
34 char *zBranch, *zUuid, *zDate, *zComment;
35 const char *zColor;
36 Blob manifest;
37 Blob mcksum; /* Self-checksum on the manifest */
38 Blob cksum1, cksum2; /* Before and after commit checksums */
39 Blob cksum1b; /* Checksum recorded in the manifest */
40
41 noSign = find_option("nosign","",0)!=0;
42 db_must_be_within_tree();
43 noSign = db_get_int("omit-ci-sig", 0)|noSign;
@@ -48,41 +48,29 @@
48 /* fossil branch new name */
49 if( g.argc<3 ){
50 usage("branch new ?-bgcolor COLOR BRANCH-NAME");
51 }
52 zBranch = g.argv[3];
53 if( zBranch==0 || zBranch[0]==0 ){
54 fossil_panic("branch name cannot be empty");
55 }
56
57 user_select();
58 db_begin_transaction();
59 if( unsaved_changes() ){
60 fossil_panic("there are uncommitted changes. please commit first");
61 }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63 vid = db_lget_int("checkout", 0);
64 vfile_aggregate_checksum_disk(vid, &cksum1);
65
66 /* Create our new manifest */
67 blob_zero(&manifest);
68 zComment = mprintf("Branch created %s", zBranch);
69 blob_appendf(&manifest, "C %F\n", zComment);
70 zDate = db_text(0, "SELECT datetime('now')");
71 zDate[10] = 'T';
72 blob_appendf(&manifest, "D %s\n", zDate);
73
74 db_prepare(&q,
75 "SELECT pathname, uuid FROM vfile JOIN blob ON vfile.mrid=blob.rid"
76 " WHERE NOT deleted AND vfile.vid=%d"
@@ -97,13 +85,20 @@
85 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
86 blob_appendf(&manifest, "P %s\n", zUuid);
87 blob_appendf(&manifest, "R %b\n", &cksum1);
88
89 if( zColor!=0 ){
90 if( strcmp("bgcolor",zBranch)>=0 ){
91 blob_appendf(&manifest, "T *%F *\n", zBranch);
92 blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
93 }else{
94 blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
95 blob_appendf(&manifest, "T *%F *\n", zBranch);
96 }
97 }else{
98 blob_appendf(&manifest, "T *%F *\n", zBranch);
99 }
 
100
101 /* Cancel any tags that propagate */
102 db_prepare(&q,
103 "SELECT tagname"
104 " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
@@ -135,11 +130,17 @@
130 }
131 db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
132 manifest_crosslink(nvid, &manifest);
133 content_deltify(vid, nvid, 0);
134 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
135 printf("Branch Version: %s\n", zUuid);
136 printf("\n");
137 printf("Notice: working copy not updated to the new branch. If\n");
138 printf(" you wish to work on the new branch, update to\n");
139 printf(" that branch first:\n");
140 printf("\n");
141 printf(" fossil update %s\n", zBranch);
142
143 /* Verify that the manifest checksum matches the expected checksum */
144 vfile_aggregate_checksum_repository(nvid, &cksum2);
145 vfile_aggregate_checksum_manifest(nvid, &cksum2, &cksum1b);
146 if( blob_compare(&cksum1, &cksum1b) ){
@@ -147,11 +148,11 @@
148 "%b versus %b", &cksum1, &cksum1b);
149 }
150
151 /* Verify that the commit did not modify any disk images. */
152 vfile_aggregate_checksum_disk(vid, &cksum2);
153 if( blob_compare(&cksum1, &cksum2) ){
154 fossil_panic("tree checksums before and after commit do not match");
155 }
156
157 /* Clear the undo/redo stack */
158 undo_reset();
159
+9 -3
--- src/manifest.c
+++ src/manifest.c
@@ -97,11 +97,11 @@
9797
** returned then the Manifest object is cleared automatically
9898
** and pContent is reset before the return.
9999
*/
100100
int manifest_parse(Manifest *p, Blob *pContent){
101101
int seenHeader = 0;
102
- int i;
102
+ int i, lineNo=0;
103103
Blob line, token, a1, a2, a3;
104104
Blob selfuuid;
105105
char cPrevType = 0;
106106
107107
memset(p, 0, sizeof(*p));
@@ -115,10 +115,11 @@
115115
blob_zero(&a1);
116116
blob_zero(&a2);
117117
md5sum_init();
118118
while( blob_line(pContent, &line) ){
119119
char *z = blob_buffer(&line);
120
+ lineNo++;
120121
if( z[0]=='-' ){
121122
if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){
122123
goto manifest_syntax_error;
123124
}
124125
if( seenHeader ){
@@ -249,12 +250,16 @@
249250
** Tags are not allowed in clusters. Multiple T lines are allowed.
250251
*/
251252
case 'T': {
252253
char *zName, *zUuid, *zValue;
253254
md5sum_step_text(blob_buffer(&line), blob_size(&line));
254
- if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
255
- if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
255
+ if( blob_token(&line, &a1)==0 ){
256
+ goto manifest_syntax_error;
257
+ }
258
+ if( blob_token(&line, &a2)==0 ){
259
+ goto manifest_syntax_error;
260
+ }
256261
zName = blob_terminate(&a1);
257262
zUuid = blob_terminate(&a2);
258263
if( blob_token(&line, &a3)==0 ){
259264
zValue = 0;
260265
}else{
@@ -399,10 +404,11 @@
399404
400405
md5sum_init();
401406
return 1;
402407
403408
manifest_syntax_error:
409
+ /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
404410
md5sum_init();
405411
manifest_clear(p);
406412
return 0;
407413
}
408414
409415
--- src/manifest.c
+++ src/manifest.c
@@ -97,11 +97,11 @@
97 ** returned then the Manifest object is cleared automatically
98 ** and pContent is reset before the return.
99 */
100 int manifest_parse(Manifest *p, Blob *pContent){
101 int seenHeader = 0;
102 int i;
103 Blob line, token, a1, a2, a3;
104 Blob selfuuid;
105 char cPrevType = 0;
106
107 memset(p, 0, sizeof(*p));
@@ -115,10 +115,11 @@
115 blob_zero(&a1);
116 blob_zero(&a2);
117 md5sum_init();
118 while( blob_line(pContent, &line) ){
119 char *z = blob_buffer(&line);
 
120 if( z[0]=='-' ){
121 if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){
122 goto manifest_syntax_error;
123 }
124 if( seenHeader ){
@@ -249,12 +250,16 @@
249 ** Tags are not allowed in clusters. Multiple T lines are allowed.
250 */
251 case 'T': {
252 char *zName, *zUuid, *zValue;
253 md5sum_step_text(blob_buffer(&line), blob_size(&line));
254 if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error;
255 if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error;
 
 
 
 
256 zName = blob_terminate(&a1);
257 zUuid = blob_terminate(&a2);
258 if( blob_token(&line, &a3)==0 ){
259 zValue = 0;
260 }else{
@@ -399,10 +404,11 @@
399
400 md5sum_init();
401 return 1;
402
403 manifest_syntax_error:
 
404 md5sum_init();
405 manifest_clear(p);
406 return 0;
407 }
408
409
--- src/manifest.c
+++ src/manifest.c
@@ -97,11 +97,11 @@
97 ** returned then the Manifest object is cleared automatically
98 ** and pContent is reset before the return.
99 */
100 int manifest_parse(Manifest *p, Blob *pContent){
101 int seenHeader = 0;
102 int i, lineNo=0;
103 Blob line, token, a1, a2, a3;
104 Blob selfuuid;
105 char cPrevType = 0;
106
107 memset(p, 0, sizeof(*p));
@@ -115,10 +115,11 @@
115 blob_zero(&a1);
116 blob_zero(&a2);
117 md5sum_init();
118 while( blob_line(pContent, &line) ){
119 char *z = blob_buffer(&line);
120 lineNo++;
121 if( z[0]=='-' ){
122 if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){
123 goto manifest_syntax_error;
124 }
125 if( seenHeader ){
@@ -249,12 +250,16 @@
250 ** Tags are not allowed in clusters. Multiple T lines are allowed.
251 */
252 case 'T': {
253 char *zName, *zUuid, *zValue;
254 md5sum_step_text(blob_buffer(&line), blob_size(&line));
255 if( blob_token(&line, &a1)==0 ){
256 goto manifest_syntax_error;
257 }
258 if( blob_token(&line, &a2)==0 ){
259 goto manifest_syntax_error;
260 }
261 zName = blob_terminate(&a1);
262 zUuid = blob_terminate(&a2);
263 if( blob_token(&line, &a3)==0 ){
264 zValue = 0;
265 }else{
@@ -399,10 +404,11 @@
404
405 md5sum_init();
406 return 1;
407
408 manifest_syntax_error:
409 /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/
410 md5sum_init();
411 manifest_clear(p);
412 return 0;
413 }
414
415

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button