Fossil SCM

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.

drh 2009-01-22 01:10 trunk
Commit 042a08b564579fbfe4526af43164c379eb2d73c6
3 files changed +60 -9 +8 -4 +3 -3
--- src/descendants.c
+++ src/descendants.c
@@ -61,60 +61,111 @@
6161
** closeMode==2.
6262
*/
6363
void compute_leaves(int iBase, int closeMode){
6464
Bag seen; /* Descendants seen */
6565
Bag pending; /* Unpropagated descendants */
66
- Stmt q; /* Query to find children of a check-in */
66
+ Stmt q1; /* Query to find children of a check-in */
67
+ Stmt q2; /* Query to detect if a merge is across branches */
6768
Stmt isBr; /* Query to check to see if a check-in starts a new branch */
6869
Stmt ins; /* INSERT statement for a new record */
6970
71
+ /* Create the LEAVES table if it does not already exist. Make sure
72
+ ** it is empty.
73
+ */
7074
db_multi_exec(
7175
"CREATE TEMP TABLE IF NOT EXISTS leaves("
7276
" rid INTEGER PRIMARY KEY"
7377
");"
7478
"DELETE FROM leaves;"
7579
);
76
- bag_init(&seen);
77
- bag_init(&pending);
80
+
81
+ /* We are checking all descendants of iBase. If iBase==0, then
82
+ ** change iBase to be the root of the entire check-in hierarchy.
83
+ */
7884
if( iBase<=0 ){
7985
iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
8086
" ORDER BY mtime LIMIT 1");
8187
if( iBase==0 ) return;
8288
}
89
+
90
+ /* Initialize the bags. */
91
+ bag_init(&seen);
92
+ bag_init(&pending);
8393
bag_insert(&pending, iBase);
84
- db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");
94
+
95
+ /* This query returns all non-merge children of check-in :rid */
96
+ db_prepare(&q1, "SELECT cid FROM plink WHERE pid=:rid AND isprim");
97
+
98
+ /* This query returns all merge children of check-in :rid where
99
+ ** the child and parent are on same branch. The child and
100
+ ** parent are assumed to be on same branch if they have
101
+ ** the same set of propagated symbolic tags.
102
+ */
103
+ db_prepare(&q2,
104
+ "SELECT cid FROM plink"
105
+ " WHERE pid=:rid AND NOT isprim"
106
+ " AND (SELECT group_concat(x) FROM ("
107
+ " SELECT tag.tagid AS x FROM tagxref, tag"
108
+ " WHERE tagxref.rid=:rid AND tagxref.tagtype=2"
109
+ " AND tag.tagid=tagxref.tagid AND tagxref.srcid=0"
110
+ " AND tag.tagname GLOB 'sym-*'"
111
+ " ORDER BY 1))"
112
+ " == (SELECT group_concat(x) FROM ("
113
+ " SELECT tag.tagid AS x FROM tagxref, tag"
114
+ " WHERE tagxref.rid=plink.cid AND tagxref.tagtype=2"
115
+ " AND tag.tagid=tagxref.tagid AND tagxref.srcid=0"
116
+ " AND tag.tagname GLOB 'sym-*'"
117
+ " ORDER BY 1))"
118
+ );
119
+
120
+ /* This query returns a single row if check-in :rid is the first
121
+ ** check-in of a new branch. In other words, it returns a row if
122
+ ** check-in :rid has the 'newbranch' tag.
123
+ */
85124
db_prepare(&isBr,
86125
"SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
87126
TAG_NEWBRANCH
88127
);
128
+
129
+ /* This statement inserts check-in :rid into the LEAVES table.
130
+ */
89131
db_prepare(&ins, "INSERT OR IGNORE INTO leaves VALUES(:rid)");
132
+
90133
while( bag_count(&pending) ){
91134
int rid = bag_first(&pending);
92135
int cnt = 0;
93136
bag_remove(&pending, rid);
94
- db_bind_int(&q, ":rid", rid);
95
- while( db_step(&q)==SQLITE_ROW ){
96
- int cid = db_column_int(&q, 0);
137
+ db_bind_int(&q1, ":rid", rid);
138
+ while( db_step(&q1)==SQLITE_ROW ){
139
+ int cid = db_column_int(&q1, 0);
97140
if( bag_insert(&seen, cid) ){
98141
bag_insert(&pending, cid);
99142
}
100143
db_bind_int(&isBr, ":rid", cid);
101144
if( db_step(&isBr)==SQLITE_DONE ){
102145
cnt++;
103146
}
104147
db_reset(&isBr);
105148
}
106
- db_reset(&q);
149
+ db_reset(&q1);
150
+ if( cnt==0 ){
151
+ db_bind_int(&q2, ":rid", rid);
152
+ if( db_step(&q2)==SQLITE_ROW ){
153
+ cnt++;
154
+ }
155
+ db_reset(&q2);
156
+ }
107157
if( cnt==0 ){
108158
db_bind_int(&ins, ":rid", rid);
109159
db_step(&ins);
110160
db_reset(&ins);
111161
}
112162
}
113163
db_finalize(&ins);
114164
db_finalize(&isBr);
115
- db_finalize(&q);
165
+ db_finalize(&q2);
166
+ db_finalize(&q1);
116167
bag_clear(&pending);
117168
bag_clear(&seen);
118169
if( closeMode==1 ){
119170
db_multi_exec(
120171
"DELETE FROM leaves WHERE rid IN"
121172
--- src/descendants.c
+++ src/descendants.c
@@ -61,60 +61,111 @@
61 ** closeMode==2.
62 */
63 void compute_leaves(int iBase, int closeMode){
64 Bag seen; /* Descendants seen */
65 Bag pending; /* Unpropagated descendants */
66 Stmt q; /* Query to find children of a check-in */
 
67 Stmt isBr; /* Query to check to see if a check-in starts a new branch */
68 Stmt ins; /* INSERT statement for a new record */
69
 
 
 
70 db_multi_exec(
71 "CREATE TEMP TABLE IF NOT EXISTS leaves("
72 " rid INTEGER PRIMARY KEY"
73 ");"
74 "DELETE FROM leaves;"
75 );
76 bag_init(&seen);
77 bag_init(&pending);
 
 
78 if( iBase<=0 ){
79 iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
80 " ORDER BY mtime LIMIT 1");
81 if( iBase==0 ) return;
82 }
 
 
 
 
83 bag_insert(&pending, iBase);
84 db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85 db_prepare(&isBr,
86 "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
87 TAG_NEWBRANCH
88 );
 
 
 
89 db_prepare(&ins, "INSERT OR IGNORE INTO leaves VALUES(:rid)");
 
90 while( bag_count(&pending) ){
91 int rid = bag_first(&pending);
92 int cnt = 0;
93 bag_remove(&pending, rid);
94 db_bind_int(&q, ":rid", rid);
95 while( db_step(&q)==SQLITE_ROW ){
96 int cid = db_column_int(&q, 0);
97 if( bag_insert(&seen, cid) ){
98 bag_insert(&pending, cid);
99 }
100 db_bind_int(&isBr, ":rid", cid);
101 if( db_step(&isBr)==SQLITE_DONE ){
102 cnt++;
103 }
104 db_reset(&isBr);
105 }
106 db_reset(&q);
 
 
 
 
 
 
 
107 if( cnt==0 ){
108 db_bind_int(&ins, ":rid", rid);
109 db_step(&ins);
110 db_reset(&ins);
111 }
112 }
113 db_finalize(&ins);
114 db_finalize(&isBr);
115 db_finalize(&q);
 
116 bag_clear(&pending);
117 bag_clear(&seen);
118 if( closeMode==1 ){
119 db_multi_exec(
120 "DELETE FROM leaves WHERE rid IN"
121
--- src/descendants.c
+++ src/descendants.c
@@ -61,60 +61,111 @@
61 ** closeMode==2.
62 */
63 void compute_leaves(int iBase, int closeMode){
64 Bag seen; /* Descendants seen */
65 Bag pending; /* Unpropagated descendants */
66 Stmt q1; /* Query to find children of a check-in */
67 Stmt q2; /* Query to detect if a merge is across branches */
68 Stmt isBr; /* Query to check to see if a check-in starts a new branch */
69 Stmt ins; /* INSERT statement for a new record */
70
71 /* Create the LEAVES table if it does not already exist. Make sure
72 ** it is empty.
73 */
74 db_multi_exec(
75 "CREATE TEMP TABLE IF NOT EXISTS leaves("
76 " rid INTEGER PRIMARY KEY"
77 ");"
78 "DELETE FROM leaves;"
79 );
80
81 /* We are checking all descendants of iBase. If iBase==0, then
82 ** change iBase to be the root of the entire check-in hierarchy.
83 */
84 if( iBase<=0 ){
85 iBase = db_int(0, "SELECT objid FROM event WHERE type='ci'"
86 " ORDER BY mtime LIMIT 1");
87 if( iBase==0 ) return;
88 }
89
90 /* Initialize the bags. */
91 bag_init(&seen);
92 bag_init(&pending);
93 bag_insert(&pending, iBase);
94
95 /* This query returns all non-merge children of check-in :rid */
96 db_prepare(&q1, "SELECT cid FROM plink WHERE pid=:rid AND isprim");
97
98 /* This query returns all merge children of check-in :rid where
99 ** the child and parent are on same branch. The child and
100 ** parent are assumed to be on same branch if they have
101 ** the same set of propagated symbolic tags.
102 */
103 db_prepare(&q2,
104 "SELECT cid FROM plink"
105 " WHERE pid=:rid AND NOT isprim"
106 " AND (SELECT group_concat(x) FROM ("
107 " SELECT tag.tagid AS x FROM tagxref, tag"
108 " WHERE tagxref.rid=:rid AND tagxref.tagtype=2"
109 " AND tag.tagid=tagxref.tagid AND tagxref.srcid=0"
110 " AND tag.tagname GLOB 'sym-*'"
111 " ORDER BY 1))"
112 " == (SELECT group_concat(x) FROM ("
113 " SELECT tag.tagid AS x FROM tagxref, tag"
114 " WHERE tagxref.rid=plink.cid AND tagxref.tagtype=2"
115 " AND tag.tagid=tagxref.tagid AND tagxref.srcid=0"
116 " AND tag.tagname GLOB 'sym-*'"
117 " ORDER BY 1))"
118 );
119
120 /* This query returns a single row if check-in :rid is the first
121 ** check-in of a new branch. In other words, it returns a row if
122 ** check-in :rid has the 'newbranch' tag.
123 */
124 db_prepare(&isBr,
125 "SELECT 1 FROM tagxref WHERE rid=:rid AND tagid=%d AND tagtype=1",
126 TAG_NEWBRANCH
127 );
128
129 /* This statement inserts check-in :rid into the LEAVES table.
130 */
131 db_prepare(&ins, "INSERT OR IGNORE INTO leaves VALUES(:rid)");
132
133 while( bag_count(&pending) ){
134 int rid = bag_first(&pending);
135 int cnt = 0;
136 bag_remove(&pending, rid);
137 db_bind_int(&q1, ":rid", rid);
138 while( db_step(&q1)==SQLITE_ROW ){
139 int cid = db_column_int(&q1, 0);
140 if( bag_insert(&seen, cid) ){
141 bag_insert(&pending, cid);
142 }
143 db_bind_int(&isBr, ":rid", cid);
144 if( db_step(&isBr)==SQLITE_DONE ){
145 cnt++;
146 }
147 db_reset(&isBr);
148 }
149 db_reset(&q1);
150 if( cnt==0 ){
151 db_bind_int(&q2, ":rid", rid);
152 if( db_step(&q2)==SQLITE_ROW ){
153 cnt++;
154 }
155 db_reset(&q2);
156 }
157 if( cnt==0 ){
158 db_bind_int(&ins, ":rid", rid);
159 db_step(&ins);
160 db_reset(&ins);
161 }
162 }
163 db_finalize(&ins);
164 db_finalize(&isBr);
165 db_finalize(&q2);
166 db_finalize(&q1);
167 bag_clear(&pending);
168 bag_clear(&seen);
169 if( closeMode==1 ){
170 db_multi_exec(
171 "DELETE FROM leaves WHERE rid IN"
172
+8 -4
--- src/info.c
+++ src/info.c
@@ -272,14 +272,14 @@
272272
int cnt = 0;
273273
db_prepare(&q,
274274
"SELECT tag.tagid, tagname, "
275275
" (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
276276
" value, datetime(tagxref.mtime,'localtime'), tagtype,"
277
- " (SELECT uuid FROM blob WHERE rid=tagxref.origid)"
277
+ " (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)"
278278
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
279279
" WHERE tagxref.rid=%d AND tagname NOT GLOB '%s'"
280
- " ORDER BY tagname", rid, rid, zNotGlob
280
+ " ORDER BY tagname", rid, rid, rid, zNotGlob
281281
);
282282
while( db_step(&q)==SQLITE_ROW ){
283283
const char *zTagname = db_column_text(&q, 1);
284284
const char *zSrcUuid = db_column_text(&q, 2);
285285
const char *zValue = db_column_text(&q, 3);
@@ -292,11 +292,11 @@
292292
@ <ul>
293293
}
294294
@ <li>
295295
@ <b>%h(zTagname)</b>
296296
if( tagtype==0 ){
297
- @ <i>cancelled.
297
+ @ <i>cancelled
298298
}else if( zValue ){
299299
@ = %h(zValue)<i>
300300
}else {
301301
@ <i>
302302
}
@@ -307,11 +307,15 @@
307307
}else{
308308
@ propagates to descendants
309309
}
310310
}
311311
if( zSrcUuid && zSrcUuid[0] ){
312
- @ added by
312
+ if( tagtype==0 ){
313
+ @ by
314
+ }else{
315
+ @ added by
316
+ }
313317
hyperlink_to_uuid(zSrcUuid);
314318
@ on %s(zDate)
315319
}
316320
@ </i>
317321
}
318322
--- src/info.c
+++ src/info.c
@@ -272,14 +272,14 @@
272 int cnt = 0;
273 db_prepare(&q,
274 "SELECT tag.tagid, tagname, "
275 " (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
276 " value, datetime(tagxref.mtime,'localtime'), tagtype,"
277 " (SELECT uuid FROM blob WHERE rid=tagxref.origid)"
278 " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
279 " WHERE tagxref.rid=%d AND tagname NOT GLOB '%s'"
280 " ORDER BY tagname", rid, rid, zNotGlob
281 );
282 while( db_step(&q)==SQLITE_ROW ){
283 const char *zTagname = db_column_text(&q, 1);
284 const char *zSrcUuid = db_column_text(&q, 2);
285 const char *zValue = db_column_text(&q, 3);
@@ -292,11 +292,11 @@
292 @ <ul>
293 }
294 @ <li>
295 @ <b>%h(zTagname)</b>
296 if( tagtype==0 ){
297 @ <i>cancelled.
298 }else if( zValue ){
299 @ = %h(zValue)<i>
300 }else {
301 @ <i>
302 }
@@ -307,11 +307,15 @@
307 }else{
308 @ propagates to descendants
309 }
310 }
311 if( zSrcUuid && zSrcUuid[0] ){
312 @ added by
 
 
 
 
313 hyperlink_to_uuid(zSrcUuid);
314 @ on %s(zDate)
315 }
316 @ </i>
317 }
318
--- src/info.c
+++ src/info.c
@@ -272,14 +272,14 @@
272 int cnt = 0;
273 db_prepare(&q,
274 "SELECT tag.tagid, tagname, "
275 " (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d),"
276 " value, datetime(tagxref.mtime,'localtime'), tagtype,"
277 " (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)"
278 " FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid"
279 " WHERE tagxref.rid=%d AND tagname NOT GLOB '%s'"
280 " ORDER BY tagname", rid, rid, rid, zNotGlob
281 );
282 while( db_step(&q)==SQLITE_ROW ){
283 const char *zTagname = db_column_text(&q, 1);
284 const char *zSrcUuid = db_column_text(&q, 2);
285 const char *zValue = db_column_text(&q, 3);
@@ -292,11 +292,11 @@
292 @ <ul>
293 }
294 @ <li>
295 @ <b>%h(zTagname)</b>
296 if( tagtype==0 ){
297 @ <i>cancelled
298 }else if( zValue ){
299 @ = %h(zValue)<i>
300 }else {
301 @ <i>
302 }
@@ -307,11 +307,15 @@
307 }else{
308 @ propagates to descendants
309 }
310 }
311 if( zSrcUuid && zSrcUuid[0] ){
312 if( tagtype==0 ){
313 @ by
314 }else{
315 @ added by
316 }
317 hyperlink_to_uuid(zSrcUuid);
318 @ on %s(zDate)
319 }
320 @ </i>
321 }
322
+3 -3
--- src/tag.c
+++ src/tag.c
@@ -173,13 +173,13 @@
173173
if( rc==SQLITE_ROW ){
174174
/* Another entry that is more recent already exists. Do nothing */
175175
return;
176176
}
177177
db_prepare(&s,
178
- "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
179
- " VALUES(%d,%d,%d,%Q,:mtime,%d)",
180
- tagid, tagtype, srcId, zValue, rid
178
+ "REPLACE INTO tagxref(tagid,tagtype,srcId,origid,value,mtime,rid)"
179
+ " VALUES(%d,%d,%d,%d,%Q,:mtime,%d)",
180
+ tagid, tagtype, srcId, rid, zValue, rid
181181
);
182182
db_bind_double(&s, ":mtime", mtime);
183183
db_step(&s);
184184
db_finalize(&s);
185185
if( tagtype==0 ){
186186
--- src/tag.c
+++ src/tag.c
@@ -173,13 +173,13 @@
173 if( rc==SQLITE_ROW ){
174 /* Another entry that is more recent already exists. Do nothing */
175 return;
176 }
177 db_prepare(&s,
178 "REPLACE INTO tagxref(tagid,tagtype,srcId,value,mtime,rid)"
179 " VALUES(%d,%d,%d,%Q,:mtime,%d)",
180 tagid, tagtype, srcId, zValue, rid
181 );
182 db_bind_double(&s, ":mtime", mtime);
183 db_step(&s);
184 db_finalize(&s);
185 if( tagtype==0 ){
186
--- src/tag.c
+++ src/tag.c
@@ -173,13 +173,13 @@
173 if( rc==SQLITE_ROW ){
174 /* Another entry that is more recent already exists. Do nothing */
175 return;
176 }
177 db_prepare(&s,
178 "REPLACE INTO tagxref(tagid,tagtype,srcId,origid,value,mtime,rid)"
179 " VALUES(%d,%d,%d,%d,%Q,:mtime,%d)",
180 tagid, tagtype, srcId, rid, zValue, rid
181 );
182 db_bind_double(&s, ":mtime", mtime);
183 db_step(&s);
184 db_finalize(&s);
185 if( tagtype==0 ){
186

Keyboard Shortcuts

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