Overview
SHA1 Hash: | 2ad378d06534c3bd0e33baf148514ac5d790b606 |
---|---|
Date: | 2007-09-23 15:02:58 |
User: | jnc |
Comment: | Branching now working correctly, including adding of bgcolor tag and correct R line |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/branch.c from [3a849760c1] to [c0919d6b52].
@@ -29,15 +29,15 @@ #include <assert.h> 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(); noSign = db_get_int("omit-ci-sig", 0)|noSign; @@ -48,41 +48,29 @@ /* fossil branch new name */ 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" " WHERE NOT deleted AND vfile.vid=%d" @@ -97,13 +85,20 @@ zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid); 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" " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid" @@ -135,11 +130,17 @@ } 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); if( blob_compare(&cksum1, &cksum1b) ){ @@ -147,11 +148,11 @@ "%b versus %b", &cksum1, &cksum1b); } /* 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 */ undo_reset();
Modified src/manifest.c from [a851f31798] to [ad3136f660].
@@ -97,11 +97,11 @@ ** returned then the Manifest object is cleared automatically ** and pContent is reset before the return. */ int manifest_parse(Manifest *p, Blob *pContent){ int seenHeader = 0; - int i; + int i, lineNo=0; Blob line, token, a1, a2, a3; Blob selfuuid; char cPrevType = 0; memset(p, 0, sizeof(*p)); @@ -115,10 +115,11 @@ blob_zero(&a1); blob_zero(&a2); md5sum_init(); while( blob_line(pContent, &line) ){ char *z = blob_buffer(&line); + lineNo++; if( z[0]=='-' ){ if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){ goto manifest_syntax_error; } if( seenHeader ){ @@ -249,12 +250,16 @@ ** Tags are not allowed in clusters. Multiple T lines are allowed. */ case 'T': { char *zName, *zUuid, *zValue; md5sum_step_text(blob_buffer(&line), blob_size(&line)); - if( blob_token(&line, &a1)==0 ) goto manifest_syntax_error; - if( blob_token(&line, &a2)==0 ) goto manifest_syntax_error; + if( blob_token(&line, &a1)==0 ){ + goto manifest_syntax_error; + } + if( blob_token(&line, &a2)==0 ){ + goto manifest_syntax_error; + } zName = blob_terminate(&a1); zUuid = blob_terminate(&a2); if( blob_token(&line, &a3)==0 ){ zValue = 0; }else{ @@ -399,10 +404,11 @@ md5sum_init(); return 1; manifest_syntax_error: + /*fprintf(stderr, "Manifest error on line %i\n", lineNo);fflush(stderr);*/ md5sum_init(); manifest_clear(p); return 0; }