Fossil SCM

Fix the "Leaves" computation on the vinfo web page. Improvements to the vinfo web page.

drh 2007-08-19 11:06 trunk
Commit 4ac16995e8d85ec769b3b5ad3611822247156ff6
1 file changed +62 -18
+62 -18
--- src/info.c
+++ src/info.c
@@ -109,11 +109,11 @@
109109
110110
/*
111111
** Show information about descendents of a version. Do this recursively
112112
** to a depth of N. Return true if descendents are shown and false if not.
113113
*/
114
-static int showDescendents(int pid, int depth){
114
+static int showDescendents(int pid, int depth, const char *zTitle){
115115
Stmt q;
116116
int cnt = 0;
117117
db_prepare(&q,
118118
"SELECT plink.cid, blob.uuid, datetime(plink.mtime, 'localtime'),"
119119
" event.user, event.comment"
@@ -131,21 +131,25 @@
131131
const char *zDate = db_column_text(&q, 2);
132132
const char *zUser = db_column_text(&q, 3);
133133
const char *zCom = db_column_text(&q, 4);
134134
cnt++;
135135
if( cnt==1 ){
136
+ if( zTitle ){
137
+ @ <h2>%s(zTitle)</h2>
138
+ }
136139
@ <ul>
137140
}
138141
@ <li>
139142
hyperlink_to_uuid(zUuid);
140143
@ %s(zCom) (by %s(zUser) on %s(zDate))
141144
if( depth ){
142
- n = showDescendents(cid, depth-1);
145
+ n = showDescendents(cid, depth-1, 0);
143146
}else{
144147
n = db_int(0, "SELECT 1 FROM plink WHERE pid=%d", cid);
145148
}
146149
if( n==0 ){
150
+ db_multi_exec("DELETE FROM leaves WHERE rid=%d", cid);
147151
@ <b>leaf</b>
148152
}
149153
}
150154
if( cnt ){
151155
@ </ul>
@@ -155,11 +159,11 @@
155159
156160
/*
157161
** Show information about ancestors of a version. Do this recursively
158162
** to a depth of N. Return true if ancestors are shown and false if not.
159163
*/
160
-static int showAncestors(int pid, int depth){
164
+static void showAncestors(int pid, int depth, const char *zTitle){
161165
Stmt q;
162166
int cnt = 0;
163167
db_prepare(&q,
164168
"SELECT plink.pid, blob.uuid, datetime(event.mtime, 'localtime'),"
165169
" event.user, event.comment"
@@ -168,28 +172,71 @@
168172
" AND blob.rid=plink.pid"
169173
" AND event.objid=plink.pid"
170174
" ORDER BY event.mtime DESC",
171175
pid
172176
);
173
- @ <ul>
174177
while( db_step(&q)==SQLITE_ROW ){
175178
int cid = db_column_int(&q, 0);
176179
const char *zUuid = db_column_text(&q, 1);
177180
const char *zDate = db_column_text(&q, 2);
178181
const char *zUser = db_column_text(&q, 3);
179182
const char *zCom = db_column_text(&q, 4);
180183
cnt++;
184
+ if( cnt==1 ){
185
+ if( zTitle ){
186
+ @ <h2>%s(zTitle)</h2>
187
+ }
188
+ @ <ul>
189
+ }
181190
@ <li>
182191
hyperlink_to_uuid(zUuid);
183192
@ %s(zCom) (by %s(zUser) on %s(zDate))
184193
if( depth ){
185
- showAncestors(cid, depth-1);
194
+ showAncestors(cid, depth-1, 0);
195
+ }
196
+ }
197
+ if( cnt ){
198
+ @ </ul>
199
+ }
200
+}
201
+
202
+
203
+/*
204
+** Show information about versions mentioned in the "leaves" table.
205
+*/
206
+static void showLeaves(void){
207
+ Stmt q;
208
+ int cnt = 0;
209
+ db_prepare(&q,
210
+ "SELECT blob.uuid, datetime(event.mtime, 'localtime'),"
211
+ " event.user, event.comment"
212
+ " FROM leaves, plink, blob, event"
213
+ " WHERE plink.cid=leaves.rid"
214
+ " AND blob.rid=leaves.rid"
215
+ " AND event.objid=leaves.rid"
216
+ " AND +generation>0"
217
+ " ORDER BY event.mtime DESC"
218
+ );
219
+ while( db_step(&q)==SQLITE_ROW ){
220
+ const char *zUuid = db_column_text(&q, 0);
221
+ const char *zDate = db_column_text(&q, 1);
222
+ const char *zUser = db_column_text(&q, 2);
223
+ const char *zCom = db_column_text(&q, 3);
224
+ cnt++;
225
+ if( cnt==1 ){
226
+ @ <h2>Leaves</h2>
227
+ @ <ul>
186228
}
229
+ @ <li>
230
+ hyperlink_to_uuid(zUuid);
231
+ @ %s(zCom) (by %s(zUser) on %s(zDate))
187232
}
188
- @ </ul>
189
- return cnt;
233
+ if( cnt ){
234
+ @ </ul>
235
+ }
190236
}
237
+
191238
192239
/*
193240
** WEBPAGE: vinfo
194241
**
195242
** Return information about a version. The version number is contained
@@ -197,11 +244,10 @@
197244
*/
198245
void vinfo_page(void){
199246
Stmt q;
200247
int rid;
201248
int isLeaf;
202
- int n;
203249
204250
login_check_credentials();
205251
if( !g.okHistory ){ login_needed(); return; }
206252
style_header("Version Information");
207253
rid = name_to_rid(g.zExtra);
@@ -225,23 +271,17 @@
225271
@ <li><b>Date:</b> %s(db_column_text(&q, 1))</li>
226272
@ <li><b>User:</b> %s(db_column_text(&q, 2))</li>
227273
@ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li>
228274
@ <li><a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a></li>
229275
@ <li><a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a></li>
276
+ @ <li><a href="%s(g.zBaseURL)/fview/%d(rid)">manifest</a></li>
277
+ if( g.okSetup ){
278
+ @ <li><b>Record ID:</b> %d(rid)</li>
279
+ }
230280
@ </ul>
231281
}
232282
db_finalize(&q);
233
- @ <p><h2>Descendents:</h2>
234
- n = showDescendents(rid, 2);
235
- if( n==0 ){
236
- @ <ul>None. This is a leaf node.</ul>
237
- }
238
- @ <p><h2>Ancestors:</h2>
239
- n = showAncestors(rid, 2);
240
- if( n==0 ){
241
- @ <ul>None. This is the root of the tree.</ul>
242
- }
243283
@ <p><h2>Changes:</h2>
244284
@ <ul>
245285
db_prepare(&q,
246286
"SELECT name, pid, fid"
247287
" FROM mlink, filename"
@@ -262,10 +302,14 @@
262302
@ <b>Deleted:</b>
263303
}
264304
@ <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></li>
265305
}
266306
@ </ul>
307
+ compute_leaves(rid);
308
+ showDescendents(rid, 2, "Descendents");
309
+ showLeaves();
310
+ showAncestors(rid, 2, "Ancestors");
267311
style_footer();
268312
}
269313
270314
/*
271315
** WEBPAGE: finfo
272316
--- src/info.c
+++ src/info.c
@@ -109,11 +109,11 @@
109
110 /*
111 ** Show information about descendents of a version. Do this recursively
112 ** to a depth of N. Return true if descendents are shown and false if not.
113 */
114 static int showDescendents(int pid, int depth){
115 Stmt q;
116 int cnt = 0;
117 db_prepare(&q,
118 "SELECT plink.cid, blob.uuid, datetime(plink.mtime, 'localtime'),"
119 " event.user, event.comment"
@@ -131,21 +131,25 @@
131 const char *zDate = db_column_text(&q, 2);
132 const char *zUser = db_column_text(&q, 3);
133 const char *zCom = db_column_text(&q, 4);
134 cnt++;
135 if( cnt==1 ){
 
 
 
136 @ <ul>
137 }
138 @ <li>
139 hyperlink_to_uuid(zUuid);
140 @ %s(zCom) (by %s(zUser) on %s(zDate))
141 if( depth ){
142 n = showDescendents(cid, depth-1);
143 }else{
144 n = db_int(0, "SELECT 1 FROM plink WHERE pid=%d", cid);
145 }
146 if( n==0 ){
 
147 @ <b>leaf</b>
148 }
149 }
150 if( cnt ){
151 @ </ul>
@@ -155,11 +159,11 @@
155
156 /*
157 ** Show information about ancestors of a version. Do this recursively
158 ** to a depth of N. Return true if ancestors are shown and false if not.
159 */
160 static int showAncestors(int pid, int depth){
161 Stmt q;
162 int cnt = 0;
163 db_prepare(&q,
164 "SELECT plink.pid, blob.uuid, datetime(event.mtime, 'localtime'),"
165 " event.user, event.comment"
@@ -168,28 +172,71 @@
168 " AND blob.rid=plink.pid"
169 " AND event.objid=plink.pid"
170 " ORDER BY event.mtime DESC",
171 pid
172 );
173 @ <ul>
174 while( db_step(&q)==SQLITE_ROW ){
175 int cid = db_column_int(&q, 0);
176 const char *zUuid = db_column_text(&q, 1);
177 const char *zDate = db_column_text(&q, 2);
178 const char *zUser = db_column_text(&q, 3);
179 const char *zCom = db_column_text(&q, 4);
180 cnt++;
 
 
 
 
 
 
181 @ <li>
182 hyperlink_to_uuid(zUuid);
183 @ %s(zCom) (by %s(zUser) on %s(zDate))
184 if( depth ){
185 showAncestors(cid, depth-1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186 }
 
 
 
187 }
188 @ </ul>
189 return cnt;
 
190 }
 
191
192 /*
193 ** WEBPAGE: vinfo
194 **
195 ** Return information about a version. The version number is contained
@@ -197,11 +244,10 @@
197 */
198 void vinfo_page(void){
199 Stmt q;
200 int rid;
201 int isLeaf;
202 int n;
203
204 login_check_credentials();
205 if( !g.okHistory ){ login_needed(); return; }
206 style_header("Version Information");
207 rid = name_to_rid(g.zExtra);
@@ -225,23 +271,17 @@
225 @ <li><b>Date:</b> %s(db_column_text(&q, 1))</li>
226 @ <li><b>User:</b> %s(db_column_text(&q, 2))</li>
227 @ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li>
228 @ <li><a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a></li>
229 @ <li><a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a></li>
 
 
 
 
230 @ </ul>
231 }
232 db_finalize(&q);
233 @ <p><h2>Descendents:</h2>
234 n = showDescendents(rid, 2);
235 if( n==0 ){
236 @ <ul>None. This is a leaf node.</ul>
237 }
238 @ <p><h2>Ancestors:</h2>
239 n = showAncestors(rid, 2);
240 if( n==0 ){
241 @ <ul>None. This is the root of the tree.</ul>
242 }
243 @ <p><h2>Changes:</h2>
244 @ <ul>
245 db_prepare(&q,
246 "SELECT name, pid, fid"
247 " FROM mlink, filename"
@@ -262,10 +302,14 @@
262 @ <b>Deleted:</b>
263 }
264 @ <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></li>
265 }
266 @ </ul>
 
 
 
 
267 style_footer();
268 }
269
270 /*
271 ** WEBPAGE: finfo
272
--- src/info.c
+++ src/info.c
@@ -109,11 +109,11 @@
109
110 /*
111 ** Show information about descendents of a version. Do this recursively
112 ** to a depth of N. Return true if descendents are shown and false if not.
113 */
114 static int showDescendents(int pid, int depth, const char *zTitle){
115 Stmt q;
116 int cnt = 0;
117 db_prepare(&q,
118 "SELECT plink.cid, blob.uuid, datetime(plink.mtime, 'localtime'),"
119 " event.user, event.comment"
@@ -131,21 +131,25 @@
131 const char *zDate = db_column_text(&q, 2);
132 const char *zUser = db_column_text(&q, 3);
133 const char *zCom = db_column_text(&q, 4);
134 cnt++;
135 if( cnt==1 ){
136 if( zTitle ){
137 @ <h2>%s(zTitle)</h2>
138 }
139 @ <ul>
140 }
141 @ <li>
142 hyperlink_to_uuid(zUuid);
143 @ %s(zCom) (by %s(zUser) on %s(zDate))
144 if( depth ){
145 n = showDescendents(cid, depth-1, 0);
146 }else{
147 n = db_int(0, "SELECT 1 FROM plink WHERE pid=%d", cid);
148 }
149 if( n==0 ){
150 db_multi_exec("DELETE FROM leaves WHERE rid=%d", cid);
151 @ <b>leaf</b>
152 }
153 }
154 if( cnt ){
155 @ </ul>
@@ -155,11 +159,11 @@
159
160 /*
161 ** Show information about ancestors of a version. Do this recursively
162 ** to a depth of N. Return true if ancestors are shown and false if not.
163 */
164 static void showAncestors(int pid, int depth, const char *zTitle){
165 Stmt q;
166 int cnt = 0;
167 db_prepare(&q,
168 "SELECT plink.pid, blob.uuid, datetime(event.mtime, 'localtime'),"
169 " event.user, event.comment"
@@ -168,28 +172,71 @@
172 " AND blob.rid=plink.pid"
173 " AND event.objid=plink.pid"
174 " ORDER BY event.mtime DESC",
175 pid
176 );
 
177 while( db_step(&q)==SQLITE_ROW ){
178 int cid = db_column_int(&q, 0);
179 const char *zUuid = db_column_text(&q, 1);
180 const char *zDate = db_column_text(&q, 2);
181 const char *zUser = db_column_text(&q, 3);
182 const char *zCom = db_column_text(&q, 4);
183 cnt++;
184 if( cnt==1 ){
185 if( zTitle ){
186 @ <h2>%s(zTitle)</h2>
187 }
188 @ <ul>
189 }
190 @ <li>
191 hyperlink_to_uuid(zUuid);
192 @ %s(zCom) (by %s(zUser) on %s(zDate))
193 if( depth ){
194 showAncestors(cid, depth-1, 0);
195 }
196 }
197 if( cnt ){
198 @ </ul>
199 }
200 }
201
202
203 /*
204 ** Show information about versions mentioned in the "leaves" table.
205 */
206 static void showLeaves(void){
207 Stmt q;
208 int cnt = 0;
209 db_prepare(&q,
210 "SELECT blob.uuid, datetime(event.mtime, 'localtime'),"
211 " event.user, event.comment"
212 " FROM leaves, plink, blob, event"
213 " WHERE plink.cid=leaves.rid"
214 " AND blob.rid=leaves.rid"
215 " AND event.objid=leaves.rid"
216 " AND +generation>0"
217 " ORDER BY event.mtime DESC"
218 );
219 while( db_step(&q)==SQLITE_ROW ){
220 const char *zUuid = db_column_text(&q, 0);
221 const char *zDate = db_column_text(&q, 1);
222 const char *zUser = db_column_text(&q, 2);
223 const char *zCom = db_column_text(&q, 3);
224 cnt++;
225 if( cnt==1 ){
226 @ <h2>Leaves</h2>
227 @ <ul>
228 }
229 @ <li>
230 hyperlink_to_uuid(zUuid);
231 @ %s(zCom) (by %s(zUser) on %s(zDate))
232 }
233 if( cnt ){
234 @ </ul>
235 }
236 }
237
238
239 /*
240 ** WEBPAGE: vinfo
241 **
242 ** Return information about a version. The version number is contained
@@ -197,11 +244,10 @@
244 */
245 void vinfo_page(void){
246 Stmt q;
247 int rid;
248 int isLeaf;
 
249
250 login_check_credentials();
251 if( !g.okHistory ){ login_needed(); return; }
252 style_header("Version Information");
253 rid = name_to_rid(g.zExtra);
@@ -225,23 +271,17 @@
271 @ <li><b>Date:</b> %s(db_column_text(&q, 1))</li>
272 @ <li><b>User:</b> %s(db_column_text(&q, 2))</li>
273 @ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li>
274 @ <li><a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a></li>
275 @ <li><a href="%s(g.zBaseURL)/zip/%s(zUuid).zip">ZIP archive</a></li>
276 @ <li><a href="%s(g.zBaseURL)/fview/%d(rid)">manifest</a></li>
277 if( g.okSetup ){
278 @ <li><b>Record ID:</b> %d(rid)</li>
279 }
280 @ </ul>
281 }
282 db_finalize(&q);
 
 
 
 
 
 
 
 
 
 
283 @ <p><h2>Changes:</h2>
284 @ <ul>
285 db_prepare(&q,
286 "SELECT name, pid, fid"
287 " FROM mlink, filename"
@@ -262,10 +302,14 @@
302 @ <b>Deleted:</b>
303 }
304 @ <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></li>
305 }
306 @ </ul>
307 compute_leaves(rid);
308 showDescendents(rid, 2, "Descendents");
309 showLeaves();
310 showAncestors(rid, 2, "Ancestors");
311 style_footer();
312 }
313
314 /*
315 ** WEBPAGE: finfo
316

Keyboard Shortcuts

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