Fossil

Check-in [042a08b564]
Login

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

Overview
Comment:Improved messages in the "tags and properties" section of the vinfo page. Distinguish between a merge between forks and a merge between branches. A merge from forks, closes the fork, but not a merge from a branch.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 042a08b564579fbfe4526af43164c379eb2d73c6
User & Date: drh 2009-01-22 01:10:41.000
Context
2009-01-22
01:53
Define a "leaf" as a check-in with no children in the same branch. The is_a_leaf() function does some complicated SQL to figure this out. ... (check-in: faf09dc7ae user: drh tags: trunk)
01:10
Improved messages in the "tags and properties" section of the vinfo page. Distinguish between a merge between forks and a merge between branches. A merge from forks, closes the fork, but not a merge from a branch. ... (check-in: 042a08b564 user: drh tags: trunk)
2009-01-21
23:40
Track the origin of tags and display that origin in the tag and properities information field of the "vinfo" page. Must "fossil rebuild" after this change. ... (check-in: 08db9e11cb user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/descendants.c.
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106







107
108
109
110
111
112
113
114
115

116
117
118
119
120
121
122
** The default behavior is to ignore closed leaves (closeMode==0).  To
** Show all leaves, use closeMode==1.  To show only closed leaves, use
** closeMode==2.
*/
void compute_leaves(int iBase, int closeMode){
  Bag seen;       /* Descendants seen */
  Bag pending;    /* Unpropagated descendants */
  Stmt q;         /* Query to find children of a check-in */

  Stmt isBr;      /* Query to check to see if a check-in starts a new branch */
  Stmt ins;       /* INSERT statement for a new record */




  db_multi_exec(
    "CREATE TEMP TABLE IF NOT EXISTS leaves("
    "  rid INTEGER PRIMARY KEY"
    ");"
    "DELETE FROM leaves;"
  );
  bag_init(&seen);
  bag_init(&pending);


  if( iBase<=0 ){
    iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
                      " ORDER BY mtime LIMIT 1");
    if( iBase==0 ) return;
  }




  bag_insert(&pending, iBase);


  db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");



























  db_prepare(&isBr, 
     "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
     TAG_NEWBRANCH
  );



  db_prepare(&ins, "INSERT OR IGNORE INTO leaves VALUES(:rid)");

  while( bag_count(&pending) ){
    int rid = bag_first(&pending);
    int cnt = 0;
    bag_remove(&pending, rid);
    db_bind_int(&q, ":rid", rid);
    while( db_step(&q)==SQLITE_ROW ){
      int cid = db_column_int(&q, 0);
      if( bag_insert(&seen, cid) ){
        bag_insert(&pending, cid);
      }
      db_bind_int(&isBr, ":rid", cid);
      if( db_step(&isBr)==SQLITE_DONE ){
        cnt++;
      }
      db_reset(&isBr);
    }
    db_reset(&q);







    if( cnt==0 ){
      db_bind_int(&ins, ":rid", rid);
      db_step(&ins);
      db_reset(&ins);
    }
  }
  db_finalize(&ins);
  db_finalize(&isBr);
  db_finalize(&q);

  bag_clear(&pending);
  bag_clear(&seen);
  if( closeMode==1 ){
    db_multi_exec(
      "DELETE FROM leaves WHERE rid IN"
      "  (SELECT leaves.rid FROM leaves, tagxref"
      "    WHERE tagxref.rid=leaves.rid "







|
>



>
>
>






|
|
>
>





>
>
>
>

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




>
>
>

>




|
|
|









|
>
>
>
>
>
>
>








|
>







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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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
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
** The default behavior is to ignore closed leaves (closeMode==0).  To
** Show all leaves, use closeMode==1.  To show only closed leaves, use
** closeMode==2.
*/
void compute_leaves(int iBase, int closeMode){
  Bag seen;       /* Descendants seen */
  Bag pending;    /* Unpropagated descendants */
  Stmt q1;        /* Query to find children of a check-in */
  Stmt q2;        /* Query to detect if a merge is across branches */
  Stmt isBr;      /* Query to check to see if a check-in starts a new branch */
  Stmt ins;       /* INSERT statement for a new record */

  /* Create the LEAVES table if it does not already exist.  Make sure
  ** it is empty.
  */
  db_multi_exec(
    "CREATE TEMP TABLE IF NOT EXISTS leaves("
    "  rid INTEGER PRIMARY KEY"
    ");"
    "DELETE FROM leaves;"
  );

  /* We are checking all descendants of iBase.  If iBase==0, then
  ** change iBase to be the root of the entire check-in hierarchy.
  */
  if( iBase<=0 ){
    iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
                      " ORDER BY mtime LIMIT 1");
    if( iBase==0 ) return;
  }

  /* Initialize the bags. */
  bag_init(&seen);
  bag_init(&pending);
  bag_insert(&pending, iBase);

  /* This query returns all non-merge children of check-in :rid */
  db_prepare(&q1, "SELECT cid FROM plink WHERE pid=:rid AND isprim");

  /* This query returns all merge children of check-in :rid where
  ** the child and parent are on same branch.  The child and
  ** parent are assumed to be on same branch if they have
  ** the same set of propagated symbolic tags.
  */
  db_prepare(&q2,
     "SELECT cid FROM plink"
     " WHERE pid=:rid AND NOT isprim"
     "   AND (SELECT group_concat(x) FROM ("
     "          SELECT tag.tagid AS x FROM tagxref, tag"
     "           WHERE tagxref.rid=:rid AND tagxref.tagtype=2"
     "             AND tag.tagid=tagxref.tagid AND tagxref.srcid=0"
     "             AND tag.tagname GLOB 'sym-*'"
     "           ORDER BY 1))"
     "    == (SELECT group_concat(x) FROM ("
     "          SELECT tag.tagid AS x FROM tagxref, tag"
     "           WHERE tagxref.rid=plink.cid AND tagxref.tagtype=2"
     "             AND tag.tagid=tagxref.tagid AND tagxref.srcid=0"
     "             AND tag.tagname GLOB 'sym-*'"
     "           ORDER BY 1))"
  );

  /* This query returns a single row if check-in :rid is the first
  ** check-in of a new branch.  In other words, it returns a row if
  ** check-in :rid has the 'newbranch' tag.
  */
  db_prepare(&isBr, 
     "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
     TAG_NEWBRANCH
  );

  /* This statement inserts check-in :rid into the LEAVES table.
  */
  db_prepare(&ins, "INSERT OR IGNORE INTO leaves VALUES(:rid)");

  while( bag_count(&pending) ){
    int rid = bag_first(&pending);
    int cnt = 0;
    bag_remove(&pending, rid);
    db_bind_int(&q1, ":rid", rid);
    while( db_step(&q1)==SQLITE_ROW ){
      int cid = db_column_int(&q1, 0);
      if( bag_insert(&seen, cid) ){
        bag_insert(&pending, cid);
      }
      db_bind_int(&isBr, ":rid", cid);
      if( db_step(&isBr)==SQLITE_DONE ){
        cnt++;
      }
      db_reset(&isBr);
    }
    db_reset(&q1);
    if( cnt==0 ){
      db_bind_int(&q2, ":rid", rid);
      if( db_step(&q2)==SQLITE_ROW ){
        cnt++;
      }
      db_reset(&q2);
    }
    if( cnt==0 ){
      db_bind_int(&ins, ":rid", rid);
      db_step(&ins);
      db_reset(&ins);
    }
  }
  db_finalize(&ins);
  db_finalize(&isBr);
  db_finalize(&q2);
  db_finalize(&q1);
  bag_clear(&pending);
  bag_clear(&seen);
  if( closeMode==1 ){
    db_multi_exec(
      "DELETE FROM leaves WHERE rid IN"
      "  (SELECT leaves.rid FROM leaves, tagxref"
      "    WHERE tagxref.rid=leaves.rid "
Changes to src/info.c.
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311



312

313
314
315
316
317
318
319
static void showTags(int rid, const char *zNotGlob){
  Stmt q;
  int cnt = 0;
  db_prepare(&q,
    "SELECT tag.tagid, tagname, "
    "       (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
    "       value, datetime(tagxref.mtime,'localtime'), tagtype,"
    "       (SELECT uuid FROM blob WHERE rid=tagxref.origid)"
    "  FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
    " WHERE tagxref.rid=%d AND tagname NOT GLOB '%s'"
    " ORDER BY tagname", rid, rid, zNotGlob
  );
  while( db_step(&q)==SQLITE_ROW ){
    const char *zTagname = db_column_text(&q, 1);
    const char *zSrcUuid = db_column_text(&q, 2);
    const char *zValue = db_column_text(&q, 3);
    const char *zDate = db_column_text(&q, 4);
    int tagtype = db_column_int(&q, 5);
    const char *zOrigUuid = db_column_text(&q, 6);
    cnt++;
    if( cnt==1 ){
      @ <div class="section">Tags And Properties</div>
      @ <ul>
    }
    @ <li>
    @ <b>%h(zTagname)</b>
    if( tagtype==0 ){
      @ <i>cancelled.
    }else if( zValue ){
      @ = %h(zValue)<i>
    }else {
      @ <i>
    }
    if( tagtype==2 ){
      if( zOrigUuid && zOrigUuid[0] ){
        @ inherited from
        hyperlink_to_uuid(zOrigUuid);
      }else{
        @ propagates to descendants
      }
    }
    if( zSrcUuid && zSrcUuid[0] ){



      @ added by

      hyperlink_to_uuid(zSrcUuid);
      @ on %s(zDate)
    }
    @ </i>
  }
  db_finalize(&q);
  if( cnt ){







|


|
















|














>
>
>
|
>







270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
static void showTags(int rid, const char *zNotGlob){
  Stmt q;
  int cnt = 0;
  db_prepare(&q,
    "SELECT tag.tagid, tagname, "
    "       (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
    "       value, datetime(tagxref.mtime,'localtime'), tagtype,"
    "       (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)"
    "  FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
    " WHERE tagxref.rid=%d AND tagname NOT GLOB '%s'"
    " ORDER BY tagname", rid, rid, rid, zNotGlob
  );
  while( db_step(&q)==SQLITE_ROW ){
    const char *zTagname = db_column_text(&q, 1);
    const char *zSrcUuid = db_column_text(&q, 2);
    const char *zValue = db_column_text(&q, 3);
    const char *zDate = db_column_text(&q, 4);
    int tagtype = db_column_int(&q, 5);
    const char *zOrigUuid = db_column_text(&q, 6);
    cnt++;
    if( cnt==1 ){
      @ <div class="section">Tags And Properties</div>
      @ <ul>
    }
    @ <li>
    @ <b>%h(zTagname)</b>
    if( tagtype==0 ){
      @ <i>cancelled
    }else if( zValue ){
      @ = %h(zValue)<i>
    }else {
      @ <i>
    }
    if( tagtype==2 ){
      if( zOrigUuid && zOrigUuid[0] ){
        @ inherited from
        hyperlink_to_uuid(zOrigUuid);
      }else{
        @ propagates to descendants
      }
    }
    if( zSrcUuid && zSrcUuid[0] ){
      if( tagtype==0 ){
        @ by
      }else{
        @ added by
      }
      hyperlink_to_uuid(zSrcUuid);
      @ on %s(zDate)
    }
    @ </i>
  }
  db_finalize(&q);
  if( cnt ){
Changes to src/tag.c.
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
  rc = db_step(&s);
  db_finalize(&s);
  if( rc==SQLITE_ROW ){
    /* Another entry that is more recent already exists.  Do nothing */
    return;
  }
  db_prepare(&s, 
    "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
    " VALUES(%d,%d,%d,%Q,:mtime,%d)",
    tagid, tagtype, srcId, zValue, rid
  );
  db_bind_double(&s, ":mtime", mtime);
  db_step(&s);
  db_finalize(&s);
  if( tagtype==0 ){
    zValue = 0;
  }







|
|
|







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
  rc = db_step(&s);
  db_finalize(&s);
  if( rc==SQLITE_ROW ){
    /* Another entry that is more recent already exists.  Do nothing */
    return;
  }
  db_prepare(&s, 
    "REPLACE INTO tagxref(tagid,tagtype,srcId,origid,value,mtime,rid)"
    " VALUES(%d,%d,%d,%d,%Q,:mtime,%d)",
    tagid, tagtype, srcId, rid, zValue, rid
  );
  db_bind_double(&s, ":mtime", mtime);
  db_step(&s);
  db_finalize(&s);
  if( tagtype==0 ){
    zValue = 0;
  }