@@ -30,13 +30,13 @@
void branch_new(void){
int vid, nvid, noSign;
Stmt q;
- char *zBranch, *zUuid, *zDate, *zComment, *zManifestFile;
+ char *zBranch, *zUuid, *zDate, *zComment;
const char *zColor;
Blob manifest;
Blob mcksum; /* Self-checksum on the manifest */
- Blob cksum1, cksum2, dskcksum1; /* Before and after commit checksums */
+ Blob cksum1, cksum2; /* Before and after commit checksums */
Blob cksum1b; /* Checksum recorded in the manifest */
noSign = find_option("nosign","",0)!=0;
db_must_be_within_tree();
@@ -49,39 +49,27 @@
if( g.argc<3 ){
usage("branch new ?-bgcolor COLOR BRANCH-NAME");
}
zBranch = g.argv[3];
+ if( zBranch==0 || zBranch[0]==0 ){
+ fossil_panic("branch name cannot be empty");
+ }
user_select();
db_begin_transaction();
if( unsaved_changes() ){
fossil_panic("there are uncommitted changes. please commit first");
}
- /* Create a new rid? */
- zManifestFile = mprintf("%smanifest", g.zLocalRoot);
- blob_read_from_file(&manifest, zManifestFile);
- free(zManifestFile);
-
- zDate = db_text(0, "SELECT datetime('now')");
- zDate[10] = 'T';
-
- blob_appendf(&manifest, "D %s\n", zDate);
- blob_appendf(&manifest, "T *%F *\n", zBranch);
-
- md5sum_init();
- md5sum_step_blob(&manifest);
- md5sum_finish(&cksum1);
-
- blob_reset(&manifest);
-
vid = db_lget_int("checkout", 0);
- vfile_aggregate_checksum_disk(vid, &dskcksum1);
+ vfile_aggregate_checksum_disk(vid, &cksum1);
/* Create our new manifest */
blob_zero(&manifest);
zComment = mprintf("Branch created %s", zBranch);
blob_appendf(&manifest, "C %F\n", zComment);
+ zDate = db_text(0, "SELECT datetime('now')");
+ zDate[10] = 'T';
blob_appendf(&manifest, "D %s\n", zDate);
db_prepare(&q,
"SELECT pathname, uuid FROM vfile JOIN blob ON vfile.mrid=blob.rid"
@@ -98,11 +86,18 @@
blob_appendf(&manifest, "P %s\n", zUuid);
blob_appendf(&manifest, "R %b\n", &cksum1);
if( zColor!=0 ){
- blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
- }
- blob_appendf(&manifest, "T *%F *\n", zBranch);
+ if( strcmp("bgcolor",zBranch)>=0 ){
+ blob_appendf(&manifest, "T *%F *\n", zBranch);
+ blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
+ }else{
+ blob_appendf(&manifest, "T *bgcolor * %F\n", zColor);
+ blob_appendf(&manifest, "T *%F *\n", zBranch);
+ }
+ }else{
+ blob_appendf(&manifest, "T *%F *\n", zBranch);
+ }
/* Cancel any tags that propagate */
db_prepare(&q,
"SELECT tagname"
@@ -136,9 +131,15 @@
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d)", nvid);
manifest_crosslink(nvid, &manifest);
content_deltify(vid, nvid, 0);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", nvid);
- printf("New_Version: %s\n", zUuid);
+ printf("Branch Version: %s\n", zUuid);
+ printf("\n");
+ printf("Notice: working copy not updated to the new branch. If\n");
+ printf(" you wish to work on the new branch, update to\n");
+ printf(" that branch first:\n");
+ printf("\n");
+ printf(" fossil update %s\n", zBranch);
/* Verify that the manifest checksum matches the expected checksum */
vfile_aggregate_checksum_repository(nvid, &cksum2);
vfile_aggregate_checksum_manifest(nvid, &cksum2, &cksum1b);
@@ -148,9 +149,9 @@
}
/* Verify that the commit did not modify any disk images. */
vfile_aggregate_checksum_disk(vid, &cksum2);
- if( blob_compare(&dskcksum1, &cksum2) ){
+ if( blob_compare(&cksum1, &cksum2) ){
fossil_panic("tree checksums before and after commit do not match");
}
/* Clear the undo/redo stack */