Fossil SCM
Fix the "Leaves" computation on the vinfo web page. Improvements to the vinfo web page.
Commit
4ac16995e8d85ec769b3b5ad3611822247156ff6
Parent
6607844a0162db6…
1 file changed
+62
-18
+62
-18
| --- src/info.c | ||
| +++ src/info.c | ||
| @@ -109,11 +109,11 @@ | ||
| 109 | 109 | |
| 110 | 110 | /* |
| 111 | 111 | ** Show information about descendents of a version. Do this recursively |
| 112 | 112 | ** to a depth of N. Return true if descendents are shown and false if not. |
| 113 | 113 | */ |
| 114 | -static int showDescendents(int pid, int depth){ | |
| 114 | +static int showDescendents(int pid, int depth, const char *zTitle){ | |
| 115 | 115 | Stmt q; |
| 116 | 116 | int cnt = 0; |
| 117 | 117 | db_prepare(&q, |
| 118 | 118 | "SELECT plink.cid, blob.uuid, datetime(plink.mtime, 'localtime')," |
| 119 | 119 | " event.user, event.comment" |
| @@ -131,21 +131,25 @@ | ||
| 131 | 131 | const char *zDate = db_column_text(&q, 2); |
| 132 | 132 | const char *zUser = db_column_text(&q, 3); |
| 133 | 133 | const char *zCom = db_column_text(&q, 4); |
| 134 | 134 | cnt++; |
| 135 | 135 | if( cnt==1 ){ |
| 136 | + if( zTitle ){ | |
| 137 | + @ <h2>%s(zTitle)</h2> | |
| 138 | + } | |
| 136 | 139 | @ <ul> |
| 137 | 140 | } |
| 138 | 141 | @ <li> |
| 139 | 142 | hyperlink_to_uuid(zUuid); |
| 140 | 143 | @ %s(zCom) (by %s(zUser) on %s(zDate)) |
| 141 | 144 | if( depth ){ |
| 142 | - n = showDescendents(cid, depth-1); | |
| 145 | + n = showDescendents(cid, depth-1, 0); | |
| 143 | 146 | }else{ |
| 144 | 147 | n = db_int(0, "SELECT 1 FROM plink WHERE pid=%d", cid); |
| 145 | 148 | } |
| 146 | 149 | if( n==0 ){ |
| 150 | + db_multi_exec("DELETE FROM leaves WHERE rid=%d", cid); | |
| 147 | 151 | @ <b>leaf</b> |
| 148 | 152 | } |
| 149 | 153 | } |
| 150 | 154 | if( cnt ){ |
| 151 | 155 | @ </ul> |
| @@ -155,11 +159,11 @@ | ||
| 155 | 159 | |
| 156 | 160 | /* |
| 157 | 161 | ** Show information about ancestors of a version. Do this recursively |
| 158 | 162 | ** to a depth of N. Return true if ancestors are shown and false if not. |
| 159 | 163 | */ |
| 160 | -static int showAncestors(int pid, int depth){ | |
| 164 | +static void showAncestors(int pid, int depth, const char *zTitle){ | |
| 161 | 165 | Stmt q; |
| 162 | 166 | int cnt = 0; |
| 163 | 167 | db_prepare(&q, |
| 164 | 168 | "SELECT plink.pid, blob.uuid, datetime(event.mtime, 'localtime')," |
| 165 | 169 | " event.user, event.comment" |
| @@ -168,28 +172,71 @@ | ||
| 168 | 172 | " AND blob.rid=plink.pid" |
| 169 | 173 | " AND event.objid=plink.pid" |
| 170 | 174 | " ORDER BY event.mtime DESC", |
| 171 | 175 | pid |
| 172 | 176 | ); |
| 173 | - @ <ul> | |
| 174 | 177 | while( db_step(&q)==SQLITE_ROW ){ |
| 175 | 178 | int cid = db_column_int(&q, 0); |
| 176 | 179 | const char *zUuid = db_column_text(&q, 1); |
| 177 | 180 | const char *zDate = db_column_text(&q, 2); |
| 178 | 181 | const char *zUser = db_column_text(&q, 3); |
| 179 | 182 | const char *zCom = db_column_text(&q, 4); |
| 180 | 183 | cnt++; |
| 184 | + if( cnt==1 ){ | |
| 185 | + if( zTitle ){ | |
| 186 | + @ <h2>%s(zTitle)</h2> | |
| 187 | + } | |
| 188 | + @ <ul> | |
| 189 | + } | |
| 181 | 190 | @ <li> |
| 182 | 191 | hyperlink_to_uuid(zUuid); |
| 183 | 192 | @ %s(zCom) (by %s(zUser) on %s(zDate)) |
| 184 | 193 | 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> | |
| 186 | 228 | } |
| 229 | + @ <li> | |
| 230 | + hyperlink_to_uuid(zUuid); | |
| 231 | + @ %s(zCom) (by %s(zUser) on %s(zDate)) | |
| 187 | 232 | } |
| 188 | - @ </ul> | |
| 189 | - return cnt; | |
| 233 | + if( cnt ){ | |
| 234 | + @ </ul> | |
| 235 | + } | |
| 190 | 236 | } |
| 237 | + | |
| 191 | 238 | |
| 192 | 239 | /* |
| 193 | 240 | ** WEBPAGE: vinfo |
| 194 | 241 | ** |
| 195 | 242 | ** Return information about a version. The version number is contained |
| @@ -197,11 +244,10 @@ | ||
| 197 | 244 | */ |
| 198 | 245 | void vinfo_page(void){ |
| 199 | 246 | Stmt q; |
| 200 | 247 | int rid; |
| 201 | 248 | int isLeaf; |
| 202 | - int n; | |
| 203 | 249 | |
| 204 | 250 | login_check_credentials(); |
| 205 | 251 | if( !g.okHistory ){ login_needed(); return; } |
| 206 | 252 | style_header("Version Information"); |
| 207 | 253 | rid = name_to_rid(g.zExtra); |
| @@ -225,23 +271,17 @@ | ||
| 225 | 271 | @ <li><b>Date:</b> %s(db_column_text(&q, 1))</li> |
| 226 | 272 | @ <li><b>User:</b> %s(db_column_text(&q, 2))</li> |
| 227 | 273 | @ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li> |
| 228 | 274 | @ <li><a href="%s(g.zBaseURL)/vdiff/%d(rid)">diff</a></li> |
| 229 | 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 | + } | |
| 230 | 280 | @ </ul> |
| 231 | 281 | } |
| 232 | 282 | 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 | 283 | @ <p><h2>Changes:</h2> |
| 244 | 284 | @ <ul> |
| 245 | 285 | db_prepare(&q, |
| 246 | 286 | "SELECT name, pid, fid" |
| 247 | 287 | " FROM mlink, filename" |
| @@ -262,10 +302,14 @@ | ||
| 262 | 302 | @ <b>Deleted:</b> |
| 263 | 303 | } |
| 264 | 304 | @ <a href="%s(g.zBaseURL)/finfo/%T(zName)">%h(zName)</a></li> |
| 265 | 305 | } |
| 266 | 306 | @ </ul> |
| 307 | + compute_leaves(rid); | |
| 308 | + showDescendents(rid, 2, "Descendents"); | |
| 309 | + showLeaves(); | |
| 310 | + showAncestors(rid, 2, "Ancestors"); | |
| 267 | 311 | style_footer(); |
| 268 | 312 | } |
| 269 | 313 | |
| 270 | 314 | /* |
| 271 | 315 | ** WEBPAGE: finfo |
| 272 | 316 |
| --- 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 |