Fossil SCM

Improvements to the vinfo webpage. Show descendents, ancestors, and files changed.

drh 2007-08-01 00:40 trunk
Commit 30d7afe3285c0e2922c402af140a72ed73fddfc3
1 file changed +160 -1
+160 -1
--- src/info.c
+++ src/info.c
@@ -103,13 +103,172 @@
103103
}
104104
show_common_info(rid, "uuid:", 1);
105105
}
106106
}
107107
108
-#if 1
108
+/*
109
+** Show information about descendents of a version. Do this recursively
110
+** to a depth of N. Return true if descendents are shown and false if not.
111
+*/
112
+static int showDescendents(int pid, int depth){
113
+ Stmt q;
114
+ int cnt = 0;
115
+ db_prepare(&q,
116
+ "SELECT plink.cid, blob.uuid, datetime(plink.mtime),"
117
+ " event.user, event.comment"
118
+ " FROM plink, blob, event"
119
+ " WHERE plink.pid=%d"
120
+ " AND blob.rid=plink.cid"
121
+ " AND event.objid=plink.cid"
122
+ " ORDER BY plink.mtime ASC",
123
+ pid
124
+ );
125
+ while( db_step(&q)==SQLITE_ROW ){
126
+ int n;
127
+ int cid = db_column_int(&q, 0);
128
+ const char *zUuid = db_column_text(&q, 1);
129
+ const char *zDate = db_column_text(&q, 2);
130
+ const char *zUser = db_column_text(&q, 3);
131
+ const char *zCom = db_column_text(&q, 4);
132
+ cnt++;
133
+ if( cnt==1 ){
134
+ @ <ul>
135
+ }
136
+ @ <li>
137
+ hyperlink_to_uuid(zUuid);
138
+ @ %s(zCom) (by %s(zUser) on %s(zDate))
139
+ if( depth ){
140
+ n = showDescendents(cid, depth-1);
141
+ }else{
142
+ n = db_int(0, "SELECT 1 FROM plink WHERE pid=%d", cid);
143
+ }
144
+ if( n==0 ){
145
+ @ <b>leaf</b>
146
+ }
147
+ }
148
+ if( cnt ){
149
+ @ </ul>
150
+ }
151
+ return cnt;
152
+}
153
+
154
+/*
155
+** Show information about ancestors of a version. Do this recursively
156
+** to a depth of N. Return true if ancestors are shown and false if not.
157
+*/
158
+static int showAncestors(int pid, int depth){
159
+ Stmt q;
160
+ int cnt = 0;
161
+ db_prepare(&q,
162
+ "SELECT plink.pid, blob.uuid, datetime(event.mtime),"
163
+ " event.user, event.comment"
164
+ " FROM plink, blob, event"
165
+ " WHERE plink.cid=%d"
166
+ " AND blob.rid=plink.pid"
167
+ " AND event.objid=plink.pid"
168
+ " ORDER BY event.mtime DESC",
169
+ pid
170
+ );
171
+ @ <ul>
172
+ while( db_step(&q)==SQLITE_ROW ){
173
+ int n;
174
+ int cid = db_column_int(&q, 0);
175
+ const char *zUuid = db_column_text(&q, 1);
176
+ const char *zDate = db_column_text(&q, 2);
177
+ const char *zUser = db_column_text(&q, 3);
178
+ const char *zCom = db_column_text(&q, 4);
179
+ cnt++;
180
+ @ <li>
181
+ hyperlink_to_uuid(zUuid);
182
+ @ %s(zCom) (by %s(zUser) on %s(zDate))
183
+ if( depth ){
184
+ showAncestors(cid, depth-1);
185
+ }
186
+ }
187
+ @ </ul>
188
+ return cnt;
189
+}
190
+
109191
/*
110192
** WEBPAGE: vinfo
193
+**
194
+** Return information about a version. The version number is contained
195
+** in g.zExtra.
196
+*/
197
+void vinfo_page(void){
198
+ Stmt q;
199
+ int rid;
200
+ int isLeaf;
201
+ int cid, pid, n;
202
+
203
+ login_check_credentials();
204
+ if( !g.okHistory ){ login_needed(); return; }
205
+ style_header("Version Information");
206
+ rid = name_to_rid(g.zExtra);
207
+ if( rid==0 ){
208
+ @ No such object: %h(g.argv[2])
209
+ style_footer();
210
+ return;
211
+ }
212
+ isLeaf = !db_exists("SELECT 1 FROM plink WHERE pid=%d", rid);
213
+ db_prepare(&q,
214
+ "SELECT uuid, datetime(mtime), user, comment"
215
+ " FROM blob, event"
216
+ " WHERE blob.rid=%d"
217
+ " AND event.objid=%d",
218
+ rid, rid
219
+ );
220
+ if( db_step(&q)==SQLITE_ROW ){
221
+ @ <h2>Version %s(db_column_text(&q,0))</h2>
222
+ @ <ul>
223
+ @ <li><b>Date:</b> %s(db_column_text(&q, 1))</li>
224
+ @ <li><b>User:</b> %s(db_column_text(&q, 2))</li>
225
+ @ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li>
226
+ @ </ul>
227
+ }
228
+ db_finalize(&q);
229
+ @ <p><h2>Descendents:</h2>
230
+ n = showDescendents(rid, 2);
231
+ if( n==0 ){
232
+ @ <ul>None. This is a leaf node.</ul>
233
+ }
234
+ @ <p><h2>Ancestors:</h2>
235
+ n = showAncestors(rid, 2);
236
+ if( n==0 ){
237
+ @ <ul>None. This is the root of the tree.</ul>
238
+ }
239
+ @ <p><h2>Changes:</h2>
240
+ @ <ul>
241
+ db_prepare(&q,
242
+ "SELECT name, pid, fid"
243
+ " FROM mlink, filename"
244
+ " WHERE mid=%d"
245
+ " AND filename.fnid=mlink.fnid",
246
+ rid
247
+ );
248
+ while( db_step(&q)==SQLITE_ROW ){
249
+ const char *zName = db_column_text(&q, 0);
250
+ int pid = db_column_int(&q, 1);
251
+ int fid = db_column_int(&q, 2);
252
+ @ <li>
253
+ if( pid && fid ){
254
+ @ <b>Modified:</b>
255
+ }else if( fid ){
256
+ @ <b>Added:</b>
257
+ }else{
258
+ @ <b>Deleted:</b>
259
+ }
260
+ @ %h(zName)</li>
261
+ }
262
+ @ </ul>
263
+ style_footer();
264
+}
265
+
266
+
267
+#if 0
268
+/*
269
+** WEB PAGE: vinfo
111270
**
112271
** Return information about a version. The version number is contained
113272
** in g.zExtra.
114273
*/
115274
void vinfo_page(void){
116275
--- src/info.c
+++ src/info.c
@@ -103,13 +103,172 @@
103 }
104 show_common_info(rid, "uuid:", 1);
105 }
106 }
107
108 #if 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109 /*
110 ** WEBPAGE: vinfo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111 **
112 ** Return information about a version. The version number is contained
113 ** in g.zExtra.
114 */
115 void vinfo_page(void){
116
--- src/info.c
+++ src/info.c
@@ -103,13 +103,172 @@
103 }
104 show_common_info(rid, "uuid:", 1);
105 }
106 }
107
108 /*
109 ** Show information about descendents of a version. Do this recursively
110 ** to a depth of N. Return true if descendents are shown and false if not.
111 */
112 static int showDescendents(int pid, int depth){
113 Stmt q;
114 int cnt = 0;
115 db_prepare(&q,
116 "SELECT plink.cid, blob.uuid, datetime(plink.mtime),"
117 " event.user, event.comment"
118 " FROM plink, blob, event"
119 " WHERE plink.pid=%d"
120 " AND blob.rid=plink.cid"
121 " AND event.objid=plink.cid"
122 " ORDER BY plink.mtime ASC",
123 pid
124 );
125 while( db_step(&q)==SQLITE_ROW ){
126 int n;
127 int cid = db_column_int(&q, 0);
128 const char *zUuid = db_column_text(&q, 1);
129 const char *zDate = db_column_text(&q, 2);
130 const char *zUser = db_column_text(&q, 3);
131 const char *zCom = db_column_text(&q, 4);
132 cnt++;
133 if( cnt==1 ){
134 @ <ul>
135 }
136 @ <li>
137 hyperlink_to_uuid(zUuid);
138 @ %s(zCom) (by %s(zUser) on %s(zDate))
139 if( depth ){
140 n = showDescendents(cid, depth-1);
141 }else{
142 n = db_int(0, "SELECT 1 FROM plink WHERE pid=%d", cid);
143 }
144 if( n==0 ){
145 @ <b>leaf</b>
146 }
147 }
148 if( cnt ){
149 @ </ul>
150 }
151 return cnt;
152 }
153
154 /*
155 ** Show information about ancestors of a version. Do this recursively
156 ** to a depth of N. Return true if ancestors are shown and false if not.
157 */
158 static int showAncestors(int pid, int depth){
159 Stmt q;
160 int cnt = 0;
161 db_prepare(&q,
162 "SELECT plink.pid, blob.uuid, datetime(event.mtime),"
163 " event.user, event.comment"
164 " FROM plink, blob, event"
165 " WHERE plink.cid=%d"
166 " AND blob.rid=plink.pid"
167 " AND event.objid=plink.pid"
168 " ORDER BY event.mtime DESC",
169 pid
170 );
171 @ <ul>
172 while( db_step(&q)==SQLITE_ROW ){
173 int n;
174 int cid = db_column_int(&q, 0);
175 const char *zUuid = db_column_text(&q, 1);
176 const char *zDate = db_column_text(&q, 2);
177 const char *zUser = db_column_text(&q, 3);
178 const char *zCom = db_column_text(&q, 4);
179 cnt++;
180 @ <li>
181 hyperlink_to_uuid(zUuid);
182 @ %s(zCom) (by %s(zUser) on %s(zDate))
183 if( depth ){
184 showAncestors(cid, depth-1);
185 }
186 }
187 @ </ul>
188 return cnt;
189 }
190
191 /*
192 ** WEBPAGE: vinfo
193 **
194 ** Return information about a version. The version number is contained
195 ** in g.zExtra.
196 */
197 void vinfo_page(void){
198 Stmt q;
199 int rid;
200 int isLeaf;
201 int cid, pid, n;
202
203 login_check_credentials();
204 if( !g.okHistory ){ login_needed(); return; }
205 style_header("Version Information");
206 rid = name_to_rid(g.zExtra);
207 if( rid==0 ){
208 @ No such object: %h(g.argv[2])
209 style_footer();
210 return;
211 }
212 isLeaf = !db_exists("SELECT 1 FROM plink WHERE pid=%d", rid);
213 db_prepare(&q,
214 "SELECT uuid, datetime(mtime), user, comment"
215 " FROM blob, event"
216 " WHERE blob.rid=%d"
217 " AND event.objid=%d",
218 rid, rid
219 );
220 if( db_step(&q)==SQLITE_ROW ){
221 @ <h2>Version %s(db_column_text(&q,0))</h2>
222 @ <ul>
223 @ <li><b>Date:</b> %s(db_column_text(&q, 1))</li>
224 @ <li><b>User:</b> %s(db_column_text(&q, 2))</li>
225 @ <li><b>Comment:</b> %s(db_column_text(&q, 3))</li>
226 @ </ul>
227 }
228 db_finalize(&q);
229 @ <p><h2>Descendents:</h2>
230 n = showDescendents(rid, 2);
231 if( n==0 ){
232 @ <ul>None. This is a leaf node.</ul>
233 }
234 @ <p><h2>Ancestors:</h2>
235 n = showAncestors(rid, 2);
236 if( n==0 ){
237 @ <ul>None. This is the root of the tree.</ul>
238 }
239 @ <p><h2>Changes:</h2>
240 @ <ul>
241 db_prepare(&q,
242 "SELECT name, pid, fid"
243 " FROM mlink, filename"
244 " WHERE mid=%d"
245 " AND filename.fnid=mlink.fnid",
246 rid
247 );
248 while( db_step(&q)==SQLITE_ROW ){
249 const char *zName = db_column_text(&q, 0);
250 int pid = db_column_int(&q, 1);
251 int fid = db_column_int(&q, 2);
252 @ <li>
253 if( pid && fid ){
254 @ <b>Modified:</b>
255 }else if( fid ){
256 @ <b>Added:</b>
257 }else{
258 @ <b>Deleted:</b>
259 }
260 @ %h(zName)</li>
261 }
262 @ </ul>
263 style_footer();
264 }
265
266
267 #if 0
268 /*
269 ** WEB PAGE: vinfo
270 **
271 ** Return information about a version. The version number is contained
272 ** in g.zExtra.
273 */
274 void vinfo_page(void){
275

Keyboard Shortcuts

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