Fossil

Check-in [2ad378d0]
Login

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

Overview
Comment:Branching now working correctly, including adding of bgcolor tag and correct R line
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:2ad378d06534c3bd0e33baf148514ac5d790b606
User & Date: jnc 2007-09-23 15:02:58
Context
2007-09-23
18:49
Fixes to the timeline webpage and the "open" and "update" commands. check-in: ff4cc5fa user: drh tags: trunk
18:24
Added RSS feed. You can set the RSS title, description in Setup. Added header to style to include title and pointer to the new RSS feed. The new RSS feed is BaseURL/timeline.rss check-in: 07eaead5 user: jnc tags: trunk
15:02
Branching now working correctly, including adding of bgcolor tag and correct R line check-in: 2ad378d0 user: jnc tags: trunk
11:43
Relax the lexigraphical ordering requirement on manifests. Now the lines of a manifest (or cluster or control file) must occur in lexigraphical order after the arguments have been defossilized. check-in: dea1ae50 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/branch.c.

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
..
95
96
97
98
99
100
101


102



103

104

105
106
107
108
109
110
111
...
133
134
135
136
137
138
139
140






141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#include "config.h"
#include "branch.h"
#include <assert.h>

void branch_new(void){
  int vid, nvid, noSign;
  Stmt q;
  char *zBranch, *zUuid, *zDate, *zComment, *zManifestFile;
  const char *zColor;
  Blob manifest;
  Blob mcksum;           /* Self-checksum on the manifest */
  Blob cksum1, cksum2, dskcksum1;   /* 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;
  zColor = find_option("bgcolor","c",1);
  
................................................................................
  verify_all_options();
  
  /* fossil branch new name */
  if( g.argc<3 ){
    usage("branch new ?-bgcolor COLOR BRANCH-NAME");
  }
  zBranch = g.argv[3];




  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);
  
  /* Create our new manifest */
  blob_zero(&manifest);
  zComment = mprintf("Branch created %s", zBranch);
  blob_appendf(&manifest, "C %F\n", zComment);


  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"
    " ORDER BY 1", vid);
  while( db_step(&q)==SQLITE_ROW ){
................................................................................
  db_finalize(&q);
  
  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);


  /* Cancel any tags that propagate */
  db_prepare(&q, 
      "SELECT tagname"
      "  FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
      " WHERE rid=%d AND tagtype=2", vid);
  while( db_step(&q)==SQLITE_ROW ){
................................................................................
  if( nvid==0 ){
    fossil_panic("trouble committing manifest: %s", g.zErrMsg);
  }
  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);







  /* 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) ){
    fossil_panic("manifest checksum does not agree with manifest: "
                 "%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) ){
    fossil_panic("tree checksums before and after commit do not match");
  }

  /* Clear the undo/redo stack */
  undo_reset();

  /* Commit */







|



|







 







>
>
>







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

|





>
>







 







>
>
|
>
>
>
|
>
|
>







 







|
>
>
>
>
>
>











|







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
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
...
128
129
130
131
132
133
134
135
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
#include "config.h"
#include "branch.h"
#include <assert.h>

void branch_new(void){
  int vid, nvid, noSign;
  Stmt q;
  char *zBranch, *zUuid, *zDate, *zComment;
  const char *zColor;
  Blob manifest;
  Blob mcksum;           /* Self-checksum on the manifest */
  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;
  zColor = find_option("bgcolor","c",1);
  
................................................................................
  verify_all_options();
  
  /* 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");
  }


















  vid = db_lget_int("checkout", 0);
  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"
    " ORDER BY 1", vid);
  while( db_step(&q)==SQLITE_ROW ){
................................................................................
  db_finalize(&q);
  
  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 ){
    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"
      " WHERE rid=%d AND tagtype=2", vid);
  while( db_step(&q)==SQLITE_ROW ){
................................................................................
  if( nvid==0 ){
    fossil_panic("trouble committing manifest: %s", g.zErrMsg);
  }
  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("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) ){
    fossil_panic("manifest checksum does not agree with manifest: "
                 "%b versus %b", &cksum1, &cksum1b);
  }
  
  /* Verify that the commit did not modify any disk images. */
  vfile_aggregate_checksum_disk(vid, &cksum2);
  if( blob_compare(&cksum1, &cksum2) ){
    fossil_panic("tree checksums before and after commit do not match");
  }

  /* Clear the undo/redo stack */
  undo_reset();

  /* Commit */

Changes to src/manifest.c.

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
113
114
115
116
117
118
119

120
121
122
123
124
125
126
...
247
248
249
250
251
252
253
254


255


256
257
258
259
260
261
262
...
397
398
399
400
401
402
403

404
405
406
407
408
409
410
** The pContent is reset.  If TRUE is returned, then pContent will
** be reset when the Manifest object is cleared.  If FALSE is
** 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;
  Blob line, token, a1, a2, a3;
  Blob selfuuid;
  char cPrevType = 0;

  memset(p, 0, sizeof(*p));
  memcpy(&p->content, pContent, sizeof(p->content));
  sha1sum_blob(&p->content, &selfuuid);
................................................................................
  pContent = &p->content;

  blob_zero(&a1);
  blob_zero(&a2);
  md5sum_init();
  while( blob_line(pContent, &line) ){
    char *z = blob_buffer(&line);

    if( z[0]=='-' ){
      if( strncmp(z, "-----BEGIN PGP ", 15)!=0 ){
        goto manifest_syntax_error;
      }
      if( seenHeader ){
        break;
      }
................................................................................
      ** the tag is really a property with the given value.
      **
      ** 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;


        zName = blob_terminate(&a1);
        zUuid = blob_terminate(&a2);
        if( blob_token(&line, &a3)==0 ){
          zValue = 0;
        }else{
          zValue = blob_terminate(&a3);
          defossilize(zValue);
................................................................................
    goto manifest_syntax_error;
  }
    
  md5sum_init();
  return 1;

manifest_syntax_error:

  md5sum_init();
  manifest_clear(p);
  return 0;
}

/*
** Add a single entry to the mlink table.  Also add the filename to







|







 







>







 







|
>
>
|
>
>







 







>







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
** The pContent is reset.  If TRUE is returned, then pContent will
** be reset when the Manifest object is cleared.  If FALSE is
** 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, lineNo=0;
  Blob line, token, a1, a2, a3;
  Blob selfuuid;
  char cPrevType = 0;

  memset(p, 0, sizeof(*p));
  memcpy(&p->content, pContent, sizeof(p->content));
  sha1sum_blob(&p->content, &selfuuid);
................................................................................
  pContent = &p->content;

  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 ){
        break;
      }
................................................................................
      ** the tag is really a property with the given value.
      **
      ** 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;
        }
        zName = blob_terminate(&a1);
        zUuid = blob_terminate(&a2);
        if( blob_token(&line, &a3)==0 ){
          zValue = 0;
        }else{
          zValue = blob_terminate(&a3);
          defossilize(zValue);
................................................................................
    goto manifest_syntax_error;
  }
    
  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;
}

/*
** Add a single entry to the mlink table.  Also add the filename to