|
1
|
/* |
|
2
|
** Copyright (c) 2009 D. Richard Hipp |
|
3
|
** |
|
4
|
** This program is free software; you can redistribute it and/or |
|
5
|
** modify it under the terms of the Simplified BSD License (also |
|
6
|
** known as the "2-Clause License" or "FreeBSD License".) |
|
7
|
|
|
8
|
** This program is distributed in the hope that it will be useful, |
|
9
|
** but without any warranty; without even the implied warranty of |
|
10
|
** merchantability or fitness for a particular purpose. |
|
11
|
** |
|
12
|
** Author contact information: |
|
13
|
** [email protected] |
|
14
|
** http://www.hwaci.com/drh/ |
|
15
|
** |
|
16
|
******************************************************************************* |
|
17
|
** |
|
18
|
** This file contains code to implement the "finfo" command. |
|
19
|
*/ |
|
20
|
#include "config.h" |
|
21
|
#include "finfo.h" |
|
22
|
|
|
23
|
/* |
|
24
|
** COMMAND: finfo |
|
25
|
** |
|
26
|
** Usage: %fossil finfo ?OPTIONS? FILENAME |
|
27
|
** |
|
28
|
** Print the complete change history for a single file going backwards |
|
29
|
** in time. The default mode is -l. |
|
30
|
** |
|
31
|
** For the -l|--log mode: If "-b|--brief" is specified one line per revision |
|
32
|
** is printed, otherwise the full comment is printed. The "-n|--limit N" |
|
33
|
** and "--offset P" options limits the output to the first N changes |
|
34
|
** after skipping P changes. |
|
35
|
** |
|
36
|
** The -i mode will print various facts about FILENAME, including its |
|
37
|
** hash and the check-in and time when the current version of the file |
|
38
|
** was created. Use -v for additional information. Add the -r VERSION |
|
39
|
** option to see similar information about the same file for the check-in |
|
40
|
** specified by VERSION. |
|
41
|
** |
|
42
|
** The -s mode prints the status as <status> <revision>. This is |
|
43
|
** a quick status and does not check for up-to-date-ness of the file. |
|
44
|
** |
|
45
|
** In the -p mode, there's an optional flag "-r|--revision REVISION". |
|
46
|
** The specified version (or the latest checked-out version) is printed |
|
47
|
** to stdout. The -p mode is another form of the "cat" command. |
|
48
|
** |
|
49
|
** Options: |
|
50
|
** -b|--brief Display a brief (one line / revision) summary |
|
51
|
** --case-sensitive B Enable or disable case-sensitive filenames. B is a |
|
52
|
** boolean: "yes", "no", "true", "false", etc. |
|
53
|
** -i|--id Print the artifact ID |
|
54
|
** -l|--log Select log mode (the default) |
|
55
|
** -n|--limit N Display the first N changes (default unlimited). |
|
56
|
** N less than 0 means no limit. |
|
57
|
** --offset P Skip P changes |
|
58
|
** -p|--print Select print mode |
|
59
|
** -r|--revision R Print the given revision (or ckout, if none is given) |
|
60
|
** to stdout (only in print mode) |
|
61
|
** -s|--status Select status mode (print a status indicator for FILE) |
|
62
|
** -v|--verbose On the -i option, show all check-ins that use the |
|
63
|
** file, not just the earliest check-in |
|
64
|
** -W|--width N Width of lines (default is to auto-detect). Must be |
|
65
|
** more than 22 or else 0 to indicate no limit. |
|
66
|
** |
|
67
|
** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]] |
|
68
|
*/ |
|
69
|
void finfo_cmd(void){ |
|
70
|
db_must_be_within_tree(); |
|
71
|
if( find_option("status","s",0) ){ |
|
72
|
Stmt q; |
|
73
|
Blob line; |
|
74
|
Blob fname; |
|
75
|
int vid; |
|
76
|
|
|
77
|
/* We should be done with options.. */ |
|
78
|
verify_all_options(); |
|
79
|
|
|
80
|
if( g.argc!=3 ) usage("-s|--status FILENAME"); |
|
81
|
vid = db_lget_int("checkout", 0); |
|
82
|
if( vid==0 ){ |
|
83
|
fossil_fatal("no check-out to finfo files in"); |
|
84
|
} |
|
85
|
vfile_check_signature(vid, CKSIG_ENOTFILE); |
|
86
|
file_tree_name(g.argv[2], &fname, 0, 1); |
|
87
|
db_prepare(&q, |
|
88
|
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)" |
|
89
|
" FROM vfile WHERE vfile.pathname=%B %s", |
|
90
|
&fname, filename_collation()); |
|
91
|
blob_zero(&line); |
|
92
|
if( db_step(&q)==SQLITE_ROW ) { |
|
93
|
Blob uuid; |
|
94
|
int isDeleted = db_column_int(&q, 1); |
|
95
|
int isNew = db_column_int(&q,2) == 0; |
|
96
|
int chnged = db_column_int(&q,3); |
|
97
|
int renamed = db_column_int(&q,4); |
|
98
|
|
|
99
|
blob_zero(&uuid); |
|
100
|
db_blob(&uuid, |
|
101
|
"SELECT uuid FROM blob, mlink, vfile WHERE " |
|
102
|
"blob.rid = mlink.mid AND mlink.fid = vfile.rid AND " |
|
103
|
"vfile.pathname=%B %s", |
|
104
|
&fname, filename_collation() |
|
105
|
); |
|
106
|
if( isNew ){ |
|
107
|
blob_appendf(&line, "new"); |
|
108
|
}else if( isDeleted ){ |
|
109
|
blob_appendf(&line, "deleted"); |
|
110
|
}else if( renamed ){ |
|
111
|
blob_appendf(&line, "renamed"); |
|
112
|
}else if( chnged ){ |
|
113
|
blob_appendf(&line, "edited"); |
|
114
|
}else{ |
|
115
|
blob_appendf(&line, "unchanged"); |
|
116
|
} |
|
117
|
blob_appendf(&line, " "); |
|
118
|
blob_appendf(&line, " %10.10s", blob_str(&uuid)); |
|
119
|
blob_reset(&uuid); |
|
120
|
}else{ |
|
121
|
blob_appendf(&line, "unknown 0000000000"); |
|
122
|
} |
|
123
|
db_finalize(&q); |
|
124
|
fossil_print("%s\n", blob_str(&line)); |
|
125
|
blob_reset(&fname); |
|
126
|
blob_reset(&line); |
|
127
|
}else if( find_option("print","p",0) ){ |
|
128
|
Blob record; |
|
129
|
Blob fname; |
|
130
|
const char *zRevision = find_option("revision", "r", 1); |
|
131
|
|
|
132
|
/* We should be done with options.. */ |
|
133
|
verify_all_options(); |
|
134
|
|
|
135
|
file_tree_name(g.argv[2], &fname, 0, 1); |
|
136
|
if( zRevision ){ |
|
137
|
historical_blob(zRevision, blob_str(&fname), &record, 1); |
|
138
|
}else{ |
|
139
|
int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
|
140
|
&fname, filename_collation()); |
|
141
|
if( rid==0 ){ |
|
142
|
fossil_fatal("no history for file: %b", &fname); |
|
143
|
} |
|
144
|
content_get(rid, &record); |
|
145
|
} |
|
146
|
blob_write_to_file(&record, "-"); |
|
147
|
blob_reset(&record); |
|
148
|
blob_reset(&fname); |
|
149
|
}else if( find_option("id","i",0) ){ |
|
150
|
Blob fname; |
|
151
|
int rid; |
|
152
|
int whatisFlags = WHATIS_BRIEF; |
|
153
|
const char *zRevision = find_option("revision", "r", 1); |
|
154
|
if( find_option("verbose","v",0)!=0 ) whatisFlags = 0; |
|
155
|
|
|
156
|
verify_all_options(); |
|
157
|
|
|
158
|
if( zRevision==0 ) zRevision = "current"; |
|
159
|
if( g.argc!=3 ) usage("FILENAME"); |
|
160
|
file_tree_name(g.argv[2], &fname, 0, 1); |
|
161
|
rid = db_int(0, "SELECT rid FROM blob WHERE uuid =" |
|
162
|
" (SELECT uuid FROM files_of_checkin(%Q)" |
|
163
|
" WHERE filename=%B %s)", |
|
164
|
zRevision, &fname, filename_collation()); |
|
165
|
if( rid==0 ) { |
|
166
|
fossil_fatal("file not found for revision %s: %s", |
|
167
|
zRevision, blob_str(&fname)); |
|
168
|
} |
|
169
|
whatis_rid(rid,whatisFlags); |
|
170
|
blob_reset(&fname); |
|
171
|
}else{ |
|
172
|
Blob line; |
|
173
|
Stmt q; |
|
174
|
Blob fname; |
|
175
|
int rid; |
|
176
|
const char *zFilename; |
|
177
|
const char *zLimit; |
|
178
|
const char *zWidth; |
|
179
|
const char *zOffset; |
|
180
|
int iLimit, iOffset, iBrief, iWidth; |
|
181
|
const char *zMainBranch; |
|
182
|
|
|
183
|
if( find_option("log","l",0) ){ |
|
184
|
/* this is the default, no-op */ |
|
185
|
} |
|
186
|
zLimit = find_option("limit","n",1); |
|
187
|
zWidth = find_option("width","W",1); |
|
188
|
iLimit = zLimit ? atoi(zLimit) : -1; |
|
189
|
zOffset = find_option("offset",0,1); |
|
190
|
iOffset = zOffset ? atoi(zOffset) : 0; |
|
191
|
iBrief = find_option("brief","b",0) != 0; |
|
192
|
if( iLimit==0 ){ |
|
193
|
iLimit = -1; |
|
194
|
} |
|
195
|
if( zWidth ){ |
|
196
|
iWidth = atoi(zWidth); |
|
197
|
if( (iWidth!=0) && (iWidth<=22) ){ |
|
198
|
fossil_fatal("-W|--width value must be >22 or 0"); |
|
199
|
} |
|
200
|
}else{ |
|
201
|
iWidth = -1; |
|
202
|
} |
|
203
|
|
|
204
|
/* We should be done with options.. */ |
|
205
|
verify_all_options(); |
|
206
|
|
|
207
|
if( g.argc!=3 ){ |
|
208
|
usage("?-l|--log? ?-b|--brief? FILENAME"); |
|
209
|
} |
|
210
|
file_tree_name(g.argv[2], &fname, 0, 1); |
|
211
|
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s", |
|
212
|
&fname, filename_collation()); |
|
213
|
if( rid==0 ){ |
|
214
|
fossil_fatal("no history for file: %b", &fname); |
|
215
|
} |
|
216
|
zFilename = blob_str(&fname); |
|
217
|
db_prepare(&q, |
|
218
|
"SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime,toLocal())," |
|
219
|
" coalesce(event.ecomment, event.comment)," |
|
220
|
" coalesce(event.euser, event.user)," |
|
221
|
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0" |
|
222
|
" AND tagxref.rid=mlink.mid)" /* Tags */ |
|
223
|
" FROM mlink, blob b, event, blob ci, filename" |
|
224
|
" WHERE filename.name=%Q %s" |
|
225
|
" AND mlink.fnid=filename.fnid" |
|
226
|
" AND b.rid=mlink.fid" |
|
227
|
" AND event.objid=mlink.mid" |
|
228
|
" AND event.objid=ci.rid" |
|
229
|
" ORDER BY event.mtime DESC LIMIT %d OFFSET %d", |
|
230
|
TAG_BRANCH, zFilename, filename_collation(), |
|
231
|
iLimit, iOffset |
|
232
|
); |
|
233
|
blob_zero(&line); |
|
234
|
if( iBrief == 0 ){ |
|
235
|
fossil_print("History for %s\n", blob_str(&fname)); |
|
236
|
} |
|
237
|
zMainBranch = db_main_branch(); |
|
238
|
while( db_step(&q)==SQLITE_ROW ){ |
|
239
|
const char *zFileUuid = db_column_text(&q, 0); |
|
240
|
const char *zCiUuid = db_column_text(&q,1); |
|
241
|
const char *zDate = db_column_text(&q, 2); |
|
242
|
const char *zCom = db_column_text(&q, 3); |
|
243
|
const char *zUser = db_column_text(&q, 4); |
|
244
|
const char *zBr = db_column_text(&q, 5); |
|
245
|
char *zOut; |
|
246
|
if( zBr==0 ) zBr = fossil_strdup(zMainBranch); |
|
247
|
if( iBrief == 0 ){ |
|
248
|
fossil_print("%s ", zDate); |
|
249
|
zOut = mprintf( |
|
250
|
"[%S] %s (user: %s, artifact: [%S], branch: %s)", |
|
251
|
zCiUuid, zCom, zUser, zFileUuid, zBr); |
|
252
|
comment_print(zOut, zCom, 11, iWidth, get_comment_format()); |
|
253
|
fossil_free(zOut); |
|
254
|
}else{ |
|
255
|
blob_reset(&line); |
|
256
|
blob_appendf(&line, "%S ", zCiUuid); |
|
257
|
blob_appendf(&line, "%.10s ", zDate); |
|
258
|
blob_appendf(&line, "%8.8s ", zUser); |
|
259
|
blob_appendf(&line, "%8.8s ", zBr); |
|
260
|
blob_appendf(&line,"%-39.39s", zCom ); |
|
261
|
comment_print(blob_str(&line), zCom, 0, iWidth, get_comment_format()); |
|
262
|
} |
|
263
|
} |
|
264
|
db_finalize(&q); |
|
265
|
blob_reset(&fname); |
|
266
|
} |
|
267
|
} |
|
268
|
|
|
269
|
/* |
|
270
|
** COMMAND: cat |
|
271
|
** |
|
272
|
** Usage: %fossil cat FILENAME ... ?OPTIONS? |
|
273
|
** |
|
274
|
** Print on standard output the content of one or more files as they exist |
|
275
|
** in the repository. The version currently checked out is shown by default. |
|
276
|
** Other versions may be specified using the -r option. |
|
277
|
** |
|
278
|
** Options: |
|
279
|
** -o|--out OUTFILE For exactly one given FILENAME, write to OUTFILE |
|
280
|
** -R|--repository REPO Extract artifacts from repository REPO |
|
281
|
** -r VERSION The specific check-in containing the file |
|
282
|
** |
|
283
|
** See also: [[finfo]] |
|
284
|
*/ |
|
285
|
void cat_cmd(void){ |
|
286
|
int i; |
|
287
|
Blob content, fname; |
|
288
|
const char *zRev; |
|
289
|
const char *zFileName; |
|
290
|
db_find_and_open_repository(0, 0); |
|
291
|
zRev = find_option("r","r",1); |
|
292
|
zFileName = find_option("out","o",1); |
|
293
|
|
|
294
|
/* We should be done with options.. */ |
|
295
|
verify_all_options(); |
|
296
|
|
|
297
|
if ( zFileName && g.argc>3 ){ |
|
298
|
fossil_fatal("output file can only be given when retrieving a single file"); |
|
299
|
} |
|
300
|
|
|
301
|
for(i=2; i<g.argc; i++){ |
|
302
|
file_tree_name(g.argv[i], &fname, 0, 1); |
|
303
|
blob_zero(&content); |
|
304
|
historical_blob(zRev, blob_str(&fname), &content, 1); |
|
305
|
if ( g.argc==3 && zFileName ){ |
|
306
|
blob_write_to_file(&content, zFileName); |
|
307
|
}else{ |
|
308
|
blob_write_to_file(&content, "-"); |
|
309
|
} |
|
310
|
blob_reset(&fname); |
|
311
|
blob_reset(&content); |
|
312
|
} |
|
313
|
} |
|
314
|
|
|
315
|
/* Values for the debug= query parameter to finfo */ |
|
316
|
#define FINFO_DEBUG_MLINK 0x01 |
|
317
|
|
|
318
|
/* |
|
319
|
** WEBPAGE: finfo |
|
320
|
** Usage: |
|
321
|
** * /finfo?name=FILENAME |
|
322
|
** * /finfo?name=FILENAME&ci=HASH |
|
323
|
** |
|
324
|
** Show the change history for a single file. The name=FILENAME query |
|
325
|
** parameter gives the filename and is a required parameter. If the |
|
326
|
** ci=HASH parameter is also supplied, then the FILENAME,HASH combination |
|
327
|
** identifies a particular version of a file, and in that case all changes |
|
328
|
** to that one file version are tracked across both edits and renames. |
|
329
|
** If only the name=FILENAME parameter is supplied (if ci=HASH is omitted) |
|
330
|
** then the graph shows all changes to any file while it happened |
|
331
|
** to be called FILENAME and changes are not tracked across renames. |
|
332
|
** |
|
333
|
** Additional query parameters: |
|
334
|
** |
|
335
|
** a=DATETIME Only show changes after DATETIME |
|
336
|
** b=DATETIME Only show changes before DATETIME |
|
337
|
** ci=HASH identify a particular version of a file and then |
|
338
|
** track changes to that file across renames |
|
339
|
** m=HASH Mark this particular file version. |
|
340
|
** n=NUM Show the first NUM changes only |
|
341
|
** name=FILENAME (Required) name of file whose history to show |
|
342
|
** brbg Background color by branch name |
|
343
|
** ubg Background color by user name |
|
344
|
** from=HASH Ancestors only (not descendants) of the version of |
|
345
|
** the file in this particular check-in. |
|
346
|
** to=HASH If both from= and to= are supplied, only show those |
|
347
|
** changes on the direct path between the two given |
|
348
|
** checkins. |
|
349
|
** showid Show RID values for debugging |
|
350
|
** showsql Show the SQL query used to gather the data for |
|
351
|
** the graph |
|
352
|
** |
|
353
|
** DATETIME may be in any of usual formats, including "now", |
|
354
|
** "YYYY-MM-DDTHH:MM:SS.SSS", "YYYYMMDDHHMM", and others. |
|
355
|
*/ |
|
356
|
void finfo_page(void){ |
|
357
|
Stmt q; |
|
358
|
const char *zFilename = PD("name",""); |
|
359
|
char zPrevDate[20]; |
|
360
|
const char *zA; |
|
361
|
const char *zB; |
|
362
|
int n; |
|
363
|
int ridFrom; |
|
364
|
int ridTo = 0; |
|
365
|
int ridCi = 0; |
|
366
|
const char *zCI = P("ci"); |
|
367
|
int fnid; |
|
368
|
Blob title; |
|
369
|
Blob sql; |
|
370
|
HQuery url; |
|
371
|
GraphContext *pGraph; |
|
372
|
int brBg = P("brbg")!=0; |
|
373
|
int uBg = P("ubg")!=0; |
|
374
|
int fDebug = atoi(PD("debug","0")); |
|
375
|
int fShowId = P("showid")!=0; |
|
376
|
Stmt qparent; |
|
377
|
int iTableId = timeline_tableid(); |
|
378
|
int tmFlags = 0; /* Viewing mode */ |
|
379
|
const char *zStyle; /* Viewing mode name */ |
|
380
|
const char *zMark; /* Mark this version of the file */ |
|
381
|
int selRid = 0; /* RID of the marked file version */ |
|
382
|
int mxfnid; /* Maximum filename.fnid value */ |
|
383
|
const char *zMainBranch; |
|
384
|
|
|
385
|
login_check_credentials(); |
|
386
|
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
387
|
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename); |
|
388
|
ridCi = zCI ? name_to_rid_www("ci") : 0; |
|
389
|
if( fnid==0 ){ |
|
390
|
style_header("No such file"); |
|
391
|
}else if( ridCi==0 ){ |
|
392
|
style_header("All files named \"%s\"", zFilename); |
|
393
|
}else{ |
|
394
|
style_header("History of %s of %s",zFilename, zCI); |
|
395
|
} |
|
396
|
login_anonymous_available(); |
|
397
|
tmFlags = timeline_ss_submenu(); |
|
398
|
if( tmFlags & TIMELINE_COLUMNAR ){ |
|
399
|
zStyle = "Columnar"; |
|
400
|
}else if( tmFlags & TIMELINE_COMPACT ){ |
|
401
|
zStyle = "Compact"; |
|
402
|
}else if( tmFlags & TIMELINE_SIMPLE ){ |
|
403
|
zStyle = "Simple"; |
|
404
|
}else if( tmFlags & TIMELINE_VERBOSE ){ |
|
405
|
zStyle = "Verbose"; |
|
406
|
}else if( tmFlags & TIMELINE_CLASSIC ){ |
|
407
|
zStyle = "Classic"; |
|
408
|
}else{ |
|
409
|
zStyle = "Modern"; |
|
410
|
} |
|
411
|
url_initialize(&url, "finfo"); |
|
412
|
if( brBg ) url_add_parameter(&url, "brbg", 0); |
|
413
|
if( uBg ) url_add_parameter(&url, "ubg", 0); |
|
414
|
ridFrom = name_to_rid_www("from"); |
|
415
|
zPrevDate[0] = 0; |
|
416
|
if( fnid==0 ){ |
|
417
|
@ No such file: %h(zFilename) |
|
418
|
style_finish_page(); |
|
419
|
return; |
|
420
|
} |
|
421
|
if( g.perm.Admin ){ |
|
422
|
style_submenu_element("MLink Table", "%R/mlink?name=%t", zFilename); |
|
423
|
} |
|
424
|
if( ridFrom ){ |
|
425
|
if( P("to")!=0 ){ |
|
426
|
ridTo = name_to_typed_rid(P("to"),"ci"); |
|
427
|
path_shortest_stored_in_ancestor_table(ridFrom,ridTo); |
|
428
|
}else{ |
|
429
|
compute_direct_ancestors(ridFrom); |
|
430
|
} |
|
431
|
} |
|
432
|
url_add_parameter(&url, "name", zFilename); |
|
433
|
cgi_check_for_malice(); |
|
434
|
blob_zero(&sql); |
|
435
|
if( ridCi ){ |
|
436
|
/* If we will be tracking changes across renames, some extra temp |
|
437
|
** tables (implemented as CTEs) are required */ |
|
438
|
blob_append_sql(&sql, |
|
439
|
/* The clade(fid,fnid) table is the set of all (fid,fnid) pairs |
|
440
|
** that should participate in the output. Clade is computed by |
|
441
|
** walking the graph of mlink edges. |
|
442
|
*/ |
|
443
|
"WITH RECURSIVE clade(fid,fnid) AS (\n" |
|
444
|
" SELECT blob.rid, %d FROM blob\n" /* %d is fnid */ |
|
445
|
" WHERE blob.uuid=(SELECT uuid FROM files_of_checkin(%Q)" |
|
446
|
" WHERE filename=%Q)\n" /* %Q is the filename */ |
|
447
|
" UNION\n" |
|
448
|
" SELECT mlink.fid, mlink.fnid\n" |
|
449
|
" FROM clade, mlink\n" |
|
450
|
" WHERE clade.fid=mlink.pid\n" |
|
451
|
" AND ((mlink.pfnid=0 AND mlink.fnid=clade.fnid)\n" |
|
452
|
" OR mlink.pfnid=clade.fnid)\n" |
|
453
|
" AND (mlink.fid>0 OR NOT EXISTS(SELECT 1 FROM mlink AS mx" |
|
454
|
" WHERE mx.mid=mlink.mid AND mx.pid=mlink.pid" |
|
455
|
" AND mx.fid>0 AND mx.pfnid=mlink.fnid))\n" |
|
456
|
" UNION\n" |
|
457
|
" SELECT mlink.pid," |
|
458
|
" CASE WHEN mlink.pfnid>0 THEN mlink.pfnid ELSE mlink.fnid END\n" |
|
459
|
" FROM clade, mlink\n" |
|
460
|
" WHERE mlink.pid>0\n" |
|
461
|
" AND mlink.fid=clade.fid\n" |
|
462
|
" AND mlink.fnid=clade.fnid\n" |
|
463
|
")\n", |
|
464
|
fnid, zCI, zFilename |
|
465
|
); |
|
466
|
}else{ |
|
467
|
/* This is the case for all files with a given name. We will still |
|
468
|
** create a "clade(fid,fnid)" table that identifies all participates |
|
469
|
** in the output graph, so that subsequent queries can all be the same, |
|
470
|
** but in the case the clade table is much simplier, being just a |
|
471
|
** single direct query against the mlink table. |
|
472
|
*/ |
|
473
|
blob_append_sql(&sql, |
|
474
|
"WITH clade(fid,fnid) AS (\n" |
|
475
|
" SELECT DISTINCT fid, %d\n" |
|
476
|
" FROM mlink\n" |
|
477
|
" WHERE fnid=%d)", |
|
478
|
fnid, fnid |
|
479
|
); |
|
480
|
} |
|
481
|
blob_append_sql(&sql, |
|
482
|
"SELECT\n" |
|
483
|
" datetime(min(event.mtime),toLocal()),\n" /* Date of change */ |
|
484
|
" coalesce(event.ecomment, event.comment),\n" /* Check-in comment */ |
|
485
|
" coalesce(event.euser, event.user),\n" /* User who made chng */ |
|
486
|
" mlink.pid,\n" /* Parent file rid */ |
|
487
|
" mlink.fid,\n" /* File rid */ |
|
488
|
" (SELECT uuid FROM blob WHERE rid=mlink.pid),\n" /* Parent file hash */ |
|
489
|
" blob.uuid,\n" /* Current file hash */ |
|
490
|
" (SELECT uuid FROM blob WHERE rid=mlink.mid),\n" /* Check-in hash */ |
|
491
|
" event.bgcolor,\n" /* Background color */ |
|
492
|
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0" |
|
493
|
" AND tagxref.rid=mlink.mid),\n" /* Branchname */ |
|
494
|
" mlink.mid,\n" /* check-in ID */ |
|
495
|
" mlink.pfnid,\n" /* Previous filename */ |
|
496
|
" blob.size,\n" /* File size */ |
|
497
|
" mlink.fnid,\n" /* Current filename */ |
|
498
|
" filename.name\n" /* Current filename */ |
|
499
|
"FROM clade CROSS JOIN mlink, event" |
|
500
|
" LEFT JOIN blob ON blob.rid=clade.fid" |
|
501
|
" LEFT JOIN filename ON filename.fnid=clade.fnid\n" |
|
502
|
"WHERE mlink.fnid=clade.fnid AND mlink.fid=clade.fid\n" |
|
503
|
" AND event.objid=mlink.mid\n", |
|
504
|
TAG_BRANCH |
|
505
|
); |
|
506
|
if( (zA = P("a"))!=0 ){ |
|
507
|
blob_append_sql(&sql, " AND event.mtime>=%.16g\n", |
|
508
|
symbolic_name_to_mtime(zA,0,0)); |
|
509
|
url_add_parameter(&url, "a", zA); |
|
510
|
} |
|
511
|
if( (zB = P("b"))!=0 ){ |
|
512
|
blob_append_sql(&sql, " AND event.mtime<=%.16g\n", |
|
513
|
symbolic_name_to_mtime(zB,0,1)); |
|
514
|
url_add_parameter(&url, "b", zB); |
|
515
|
} |
|
516
|
if( ridFrom ){ |
|
517
|
blob_append_sql(&sql, |
|
518
|
" AND mlink.mid IN (SELECT rid FROM ancestor)\n" |
|
519
|
"GROUP BY mlink.fid\n" |
|
520
|
); |
|
521
|
}else{ |
|
522
|
/* We only want each version of a file to appear on the graph once, |
|
523
|
** at its earliest appearance. All the other times that it gets merged |
|
524
|
** into this or that branch can be ignored. An exception is for when |
|
525
|
** files are deleted (when they have mlink.fid==0). If the same file |
|
526
|
** is deleted in multiple places, we want to show each deletion, so |
|
527
|
** use a "fake fid" which is derived from the parent-fid for grouping. |
|
528
|
** The same fake-fid must be used on the graph. |
|
529
|
*/ |
|
530
|
blob_append_sql(&sql, |
|
531
|
"GROUP BY" |
|
532
|
" CASE WHEN mlink.fid>0 THEN mlink.fid ELSE mlink.pid+1000000000 END," |
|
533
|
" mlink.fnid\n" |
|
534
|
); |
|
535
|
} |
|
536
|
blob_append_sql(&sql, "ORDER BY event.mtime DESC"); |
|
537
|
if( (n = atoi(PD("n","0")))>0 ){ |
|
538
|
blob_append_sql(&sql, " LIMIT %d", n); |
|
539
|
url_add_parameter(&url, "n", P("n")); |
|
540
|
} |
|
541
|
blob_append_sql(&sql, " /*sort*/\n"); |
|
542
|
db_prepare(&q, "%s", blob_sql_text(&sql)); |
|
543
|
if( P("showsql")!=0 ){ |
|
544
|
@ <p>SQL: <blockquote><pre>%h(blob_str(&sql))</blockquote></pre> |
|
545
|
} |
|
546
|
zMark = P("m"); |
|
547
|
if( zMark ){ |
|
548
|
selRid = symbolic_name_to_rid(zMark, "*"); |
|
549
|
} |
|
550
|
blob_reset(&sql); |
|
551
|
blob_zero(&title); |
|
552
|
if( ridFrom ){ |
|
553
|
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ridFrom); |
|
554
|
char *zLink = href("%R/info/%!S", zUuid); |
|
555
|
if( ridTo ){ |
|
556
|
blob_appendf(&title, "Changes to file "); |
|
557
|
}else if( n>0 ){ |
|
558
|
blob_appendf(&title, "First %d ancestors of file ", n); |
|
559
|
}else{ |
|
560
|
blob_appendf(&title, "Ancestors of file "); |
|
561
|
} |
|
562
|
blob_appendf(&title,"%z%h</a>", |
|
563
|
href("%R/file?name=%T&ci=%!S", zFilename, zUuid), |
|
564
|
zFilename); |
|
565
|
if( fShowId ) blob_appendf(&title, " (%d)", fnid); |
|
566
|
blob_append(&title, ridTo ? " between " : " from ", -1); |
|
567
|
blob_appendf(&title, "check-in %z%S</a>", zLink, zUuid); |
|
568
|
if( fShowId ) blob_appendf(&title, " (%d)", ridFrom); |
|
569
|
fossil_free(zUuid); |
|
570
|
if( ridTo ){ |
|
571
|
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ridTo); |
|
572
|
zLink = href("%R/info/%!S", zUuid); |
|
573
|
blob_appendf(&title, " and check-in %z%S</a>", zLink, zUuid); |
|
574
|
fossil_free(zUuid); |
|
575
|
} |
|
576
|
}else if( ridCi ){ |
|
577
|
blob_appendf(&title, "History of file "); |
|
578
|
hyperlinked_path(zFilename, &title, 0, "tree", "", LINKPATH_FILE); |
|
579
|
if( fShowId ) blob_appendf(&title, " (%d)", fnid); |
|
580
|
blob_appendf(&title, " at check-in %z%h</a>", |
|
581
|
href("%R/info?name=%t",zCI), zCI); |
|
582
|
}else{ |
|
583
|
blob_appendf(&title, "History for "); |
|
584
|
hyperlinked_path(zFilename, &title, 0, "tree", "", LINKPATH_FILE); |
|
585
|
if( fShowId ) blob_appendf(&title, " (%d)", fnid); |
|
586
|
} |
|
587
|
if( uBg ){ |
|
588
|
blob_append(&title, " (color-coded by user)", -1); |
|
589
|
} |
|
590
|
@ <h2>%b(&title)</h2> |
|
591
|
blob_reset(&title); |
|
592
|
pGraph = graph_init(); |
|
593
|
@ <table id="timelineTable%d(iTableId)" class="timelineTable"> |
|
594
|
mxfnid = db_int(0, "SELECT max(fnid) FROM filename"); |
|
595
|
if( ridFrom ){ |
|
596
|
db_prepare(&qparent, |
|
597
|
"SELECT DISTINCT pid*%d+CASE WHEN pfnid>0 THEN pfnid ELSE fnid END" |
|
598
|
" FROM mlink" |
|
599
|
" WHERE fid=:fid AND mid=:mid AND pid>0 AND fnid=:fnid" |
|
600
|
" AND pmid IN (SELECT rid FROM ancestor)" |
|
601
|
" ORDER BY isaux /*sort*/", mxfnid+1 |
|
602
|
); |
|
603
|
}else{ |
|
604
|
db_prepare(&qparent, |
|
605
|
"SELECT DISTINCT pid*%d+CASE WHEN pfnid>0 THEN pfnid ELSE fnid END" |
|
606
|
" FROM mlink" |
|
607
|
" WHERE fid=:fid AND mid=:mid AND pid>0 AND fnid=:fnid" |
|
608
|
" ORDER BY isaux /*sort*/", mxfnid+1 |
|
609
|
); |
|
610
|
} |
|
611
|
while( db_step(&q)==SQLITE_ROW ){ |
|
612
|
const char *zDate = db_column_text(&q, 0); |
|
613
|
const char *zCom = db_column_text(&q, 1); |
|
614
|
const char *zUser = db_column_text(&q, 2); |
|
615
|
int fpid = db_column_int(&q, 3); |
|
616
|
int frid = db_column_int(&q, 4); |
|
617
|
const char *zPUuid = db_column_text(&q, 5); |
|
618
|
const char *zUuid = db_column_text(&q, 6); |
|
619
|
const char *zCkin = db_column_text(&q,7); |
|
620
|
const char *zBgClr = db_column_text(&q, 8); |
|
621
|
const char *zBr = db_column_text(&q, 9); |
|
622
|
int fmid = db_column_int(&q, 10); |
|
623
|
int pfnid = db_column_int(&q, 11); |
|
624
|
int szFile = db_column_int(&q, 12); |
|
625
|
int fnid = db_column_int(&q, 13); |
|
626
|
const char *zFName = db_column_text(&q,14); |
|
627
|
int gidx; |
|
628
|
char zTime[10]; |
|
629
|
int nParent = 0; |
|
630
|
int bIsModified = 0; |
|
631
|
GraphRowId aParent[GR_MAX_RAIL]; |
|
632
|
|
|
633
|
db_bind_int(&qparent, ":fid", frid); |
|
634
|
db_bind_int(&qparent, ":mid", fmid); |
|
635
|
db_bind_int(&qparent, ":fnid", fnid); |
|
636
|
while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){ |
|
637
|
aParent[nParent] = db_column_int64(&qparent, 0); |
|
638
|
nParent++; |
|
639
|
} |
|
640
|
db_reset(&qparent); |
|
641
|
zMainBranch = db_main_branch(); |
|
642
|
if( zBr==0 ) zBr = fossil_strdup(zMainBranch); |
|
643
|
if( uBg ){ |
|
644
|
zBgClr = user_color(zUser); |
|
645
|
}else if( brBg || zBgClr==0 || zBgClr[0]==0 ){ |
|
646
|
zBgClr = strcmp(zBr, zMainBranch)==0 ? "" : hash_color(zBr); |
|
647
|
}else if( zBgClr ){ |
|
648
|
zBgClr = reasonable_bg_color(zBgClr,0); |
|
649
|
} |
|
650
|
gidx = graph_add_row(pGraph, |
|
651
|
frid>0 ? (GraphRowId)frid*(mxfnid+1)+fnid : fpid+1000000000, |
|
652
|
nParent, 0, aParent, zBr, zBgClr, |
|
653
|
zUuid, 0); |
|
654
|
if( strncmp(zDate, zPrevDate, 10) ){ |
|
655
|
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate); |
|
656
|
@ <tr><td> |
|
657
|
@ <div class="divider timelineDate">%s(zPrevDate)</div> |
|
658
|
@ </td><td></td><td></td></tr> |
|
659
|
} |
|
660
|
memcpy(zTime, &zDate[11], 5); |
|
661
|
zTime[5] = 0; |
|
662
|
if( frid==selRid ){ |
|
663
|
@ <tr class='timelineSelected'> |
|
664
|
}else{ |
|
665
|
@ <tr> |
|
666
|
} |
|
667
|
@ <td class="timelineTime">\ |
|
668
|
@ %z(href("%R/file?name=%T&ci=%!S",zFName,zCkin))%s(zTime)</a></td> |
|
669
|
@ <td class="timelineGraph"><div id="m%d(gidx)" class="tl-nodemark"></div> |
|
670
|
@ </td> |
|
671
|
if( zBgClr && zBgClr[0] ){ |
|
672
|
@ <td class="timeline%s(zStyle)Cell" id='mc%d(gidx)'> |
|
673
|
}else{ |
|
674
|
@ <td class="timeline%s(zStyle)Cell"> |
|
675
|
} |
|
676
|
if( zPUuid && zUuid && fossil_strcmp(zPUuid, zUuid)!=0 ){ |
|
677
|
bIsModified = 1; |
|
678
|
} |
|
679
|
if( tmFlags & TIMELINE_COMPACT ){ |
|
680
|
@ <span class='timelineCompactComment' data-id='%d(frid)'> |
|
681
|
}else{ |
|
682
|
@ <span class='timeline%s(zStyle)Comment'> |
|
683
|
if( pfnid ){ |
|
684
|
char *zPrevName = db_text(0,"SELECT name FROM filename WHERE fnid=%d", |
|
685
|
pfnid); |
|
686
|
if( bIsModified ){ |
|
687
|
@ <b>Renamed and modified</b> %h(zPrevName) → %h(zFName). |
|
688
|
}else{ |
|
689
|
@ <b>Renamed</b> %h(zPrevName) → %h(zFName). |
|
690
|
} |
|
691
|
fossil_free(zPrevName); |
|
692
|
} |
|
693
|
if( zUuid && ridTo==0 && nParent==0 ){ |
|
694
|
@ <b>Added:</b> |
|
695
|
} |
|
696
|
if( zUuid==0 ){ |
|
697
|
char *zNewName; |
|
698
|
zNewName = db_text(0, |
|
699
|
"SELECT name FROM filename WHERE fnid = " |
|
700
|
" (SELECT fnid FROM mlink" |
|
701
|
" WHERE mid=%d" |
|
702
|
" AND pfnid IN (SELECT fnid FROM filename WHERE name=%Q))", |
|
703
|
fmid, zFName); |
|
704
|
if( zNewName ){ |
|
705
|
@ <b>Renamed</b> to |
|
706
|
@ %z(href("%R/finfo?name=%t",zNewName))%h(zNewName)</a>. |
|
707
|
fossil_free(zNewName); |
|
708
|
}else{ |
|
709
|
@ <b>Deleted:</b> |
|
710
|
} |
|
711
|
} |
|
712
|
if( (tmFlags & TIMELINE_VERBOSE)!=0 && zUuid ){ |
|
713
|
hyperlink_to_version(zUuid); |
|
714
|
if( fShowId ){ |
|
715
|
int srcId = delta_source_rid(frid); |
|
716
|
if( srcId ){ |
|
717
|
@ (%z(href("%R/deltachain/%d",frid))%d(frid)←%d(srcId)</a>) |
|
718
|
}else{ |
|
719
|
@ (%z(href("%R/deltachain/%d",frid))%d(frid)</a>) |
|
720
|
} |
|
721
|
} |
|
722
|
@ part of check-in \ |
|
723
|
hyperlink_to_version(zCkin); |
|
724
|
} |
|
725
|
} |
|
726
|
@ %W(zCom)</span> |
|
727
|
if( (tmFlags & TIMELINE_COMPACT)!=0 ){ |
|
728
|
@ <span class='timelineEllipsis' data-id='%d(frid)' \ |
|
729
|
@ id='ellipsis-%d(frid)'>...</span> |
|
730
|
} |
|
731
|
if( tmFlags & TIMELINE_COLUMNAR ){ |
|
732
|
if( zBgClr && zBgClr[0] ){ |
|
733
|
@ <td class="timelineDetailCell" id='md%d(gidx)'> |
|
734
|
}else{ |
|
735
|
@ <td class="timelineDetailCell"> |
|
736
|
} |
|
737
|
} |
|
738
|
if( tmFlags & TIMELINE_COMPACT ){ |
|
739
|
cgi_printf("<span class='clutter' id='detail-%d'>",frid); |
|
740
|
} |
|
741
|
cgi_printf("<span class='timeline%sDetail'>", zStyle); |
|
742
|
if( tmFlags & TIMELINE_INLINE ) cgi_printf("("); |
|
743
|
if( zUuid && (tmFlags & TIMELINE_VERBOSE)==0 ){ |
|
744
|
@ file: %z(href("%R/file?name=%T&ci=%!S",zFName,zCkin))\ |
|
745
|
@ %S(zUuid)</a> |
|
746
|
if( fShowId ){ |
|
747
|
int srcId = delta_source_rid(frid); |
|
748
|
if( srcId>0 ){ |
|
749
|
@ id: %z(href("%R/deltachain/%d",frid))\ |
|
750
|
@ %d(frid)←%d(srcId)</a> |
|
751
|
}else{ |
|
752
|
@ id: %z(href("%R/deltachain/%d",frid))%d(frid)</a> |
|
753
|
} |
|
754
|
} |
|
755
|
} |
|
756
|
if( tmFlags & TIMELINE_SIMPLE ){ |
|
757
|
@ <span class='timelineEllipsis' data-id='%d(frid)' \ |
|
758
|
@ id='ellipsis-%d(frid)'>...</span> |
|
759
|
@ <span class='clutter' id='detail-%d(frid)'> |
|
760
|
} |
|
761
|
@ check-in: \ |
|
762
|
hyperlink_to_version(zCkin); |
|
763
|
if( fShowId ){ |
|
764
|
@ (%d(fmid)) |
|
765
|
} |
|
766
|
@ user: \ |
|
767
|
hyperlink_to_user(zUser, zDate, ","); |
|
768
|
@ branch: %z(href("%R/timeline?t=%T",zBr))%h(zBr)</a>, |
|
769
|
if( tmFlags & TIMELINE_INLINE ){ |
|
770
|
@ size: %d(szFile) |
|
771
|
}else{ |
|
772
|
@ size: %d(szFile) |
|
773
|
} |
|
774
|
if( g.perm.Hyperlink && zUuid ){ |
|
775
|
const char *z = zFName; |
|
776
|
@ <span id='links-%d(frid)'><span class='timelineExtraLinks'> |
|
777
|
@ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin)) |
|
778
|
@ [annotate]</a> |
|
779
|
@ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin)) |
|
780
|
@ [blame]</a> |
|
781
|
@ %z(href("%R/timeline?uf=%!S",zUuid))[check-ins using]</a> |
|
782
|
if( fpid>0 && bIsModified!=0 ){ |
|
783
|
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zPUuid,zUuid))[diff]</a> |
|
784
|
} |
|
785
|
if( fileedit_is_editable(zFName) ){ |
|
786
|
@ %z(href("%R/fileedit?filename=%T&checkin=%!S",zFName,zCkin))\ |
|
787
|
@ [edit]</a> |
|
788
|
} |
|
789
|
@ </span></span> |
|
790
|
} |
|
791
|
if( fDebug & FINFO_DEBUG_MLINK ){ |
|
792
|
int ii; |
|
793
|
char *zAncLink; |
|
794
|
@ <br>fid=%d(frid) \ |
|
795
|
@ graph-id=%lld(frid>0?(GraphRowId)frid*(mxfnid+1)+fnid:fpid+1000000000) \ |
|
796
|
@ pid=%d(fpid) mid=%d(fmid) fnid=%d(fnid) \ |
|
797
|
@ pfnid=%d(pfnid) mxfnid=%d(mxfnid) |
|
798
|
if( nParent>0 ){ |
|
799
|
@ parents=%lld(aParent[0]) |
|
800
|
for(ii=1; ii<nParent; ii++){ |
|
801
|
@ %lld(aParent[ii]) |
|
802
|
} |
|
803
|
} |
|
804
|
zAncLink = href("%R/finfo?name=%T&from=%!S&debug=1",zFName,zCkin); |
|
805
|
@ %z(zAncLink)[ancestry]</a> |
|
806
|
} |
|
807
|
tag_private_status(frid); |
|
808
|
/* End timelineDetail */ |
|
809
|
if( tmFlags & TIMELINE_INLINE ){ |
|
810
|
@ </span>)</span> |
|
811
|
}else{ |
|
812
|
@ </span> |
|
813
|
} |
|
814
|
@ </td></tr> |
|
815
|
} |
|
816
|
db_finalize(&q); |
|
817
|
db_finalize(&qparent); |
|
818
|
if( pGraph ){ |
|
819
|
graph_finish(pGraph, 0, TIMELINE_DISJOINT); |
|
820
|
if( pGraph->nErr ){ |
|
821
|
graph_free(pGraph); |
|
822
|
pGraph = 0; |
|
823
|
}else{ |
|
824
|
@ <tr class="timelineBottom" id="btm-%d(iTableId)">\ |
|
825
|
@ <td></td><td></td><td></td></tr> |
|
826
|
} |
|
827
|
} |
|
828
|
@ </table> |
|
829
|
{ |
|
830
|
int tmFlags = TIMELINE_GRAPH | TIMELINE_FILEDIFF; |
|
831
|
timeline_output_graph_javascript(pGraph, tmFlags, iTableId); |
|
832
|
} |
|
833
|
style_finish_page(); |
|
834
|
} |
|
835
|
|
|
836
|
/* |
|
837
|
** WEBPAGE: mlink |
|
838
|
** URL: /mlink?name=FILENAME |
|
839
|
** URL: /mlink?ci=NAME |
|
840
|
** |
|
841
|
** Show all MLINK table entries for a particular file, or for |
|
842
|
** a particular check-in. |
|
843
|
** |
|
844
|
** This screen is intended for use by Fossil developers to help |
|
845
|
** in debugging Fossil itself. Ordinary Fossil users are not |
|
846
|
** expected to know what the MLINK table is or why it is important. |
|
847
|
** |
|
848
|
** To avoid confusing ordinary users, this page is only available |
|
849
|
** to administrators. |
|
850
|
*/ |
|
851
|
void mlink_page(void){ |
|
852
|
const char *zFName = P("name"); |
|
853
|
const char *zCI = P("ci"); |
|
854
|
Stmt q; |
|
855
|
|
|
856
|
login_check_credentials(); |
|
857
|
if( !g.perm.Admin ){ login_needed(g.anon.Admin); return; } |
|
858
|
style_set_current_feature("finfo"); |
|
859
|
style_header("MLINK Table"); |
|
860
|
if( zFName==0 && zCI==0 ){ |
|
861
|
@ <span class='generalError'> |
|
862
|
@ Requires either a name= or ci= query parameter |
|
863
|
@ </span> |
|
864
|
}else if( zFName ){ |
|
865
|
int fnid = db_int(0,"SELECT fnid FROM filename WHERE name=%Q",zFName); |
|
866
|
if( fnid<=0 ) fossil_fatal("no such file: \"%s\"", zFName); |
|
867
|
db_prepare(&q, |
|
868
|
"SELECT" |
|
869
|
/* 0 */ " datetime(event.mtime,toLocal())," |
|
870
|
/* 1 */ " (SELECT uuid FROM blob WHERE rid=mlink.mid)," |
|
871
|
/* 2 */ " (SELECT uuid FROM blob WHERE rid=mlink.pmid)," |
|
872
|
/* 3 */ " isaux," |
|
873
|
/* 4 */ " (SELECT uuid FROM blob WHERE rid=mlink.fid)," |
|
874
|
/* 5 */ " (SELECT uuid FROM blob WHERE rid=mlink.pid)," |
|
875
|
/* 6 */ " mlink.pid," |
|
876
|
/* 7 */ " mperm," |
|
877
|
/* 8 */ " (SELECT name FROM filename WHERE fnid=mlink.pfnid)" |
|
878
|
" FROM mlink, event" |
|
879
|
" WHERE mlink.fnid=%d" |
|
880
|
" AND event.objid=mlink.mid" |
|
881
|
" ORDER BY 1 DESC", |
|
882
|
fnid |
|
883
|
); |
|
884
|
style_table_sorter(); |
|
885
|
@ <h1>MLINK table for file |
|
886
|
@ <a href='%R/finfo?name=%t(zFName)'>%h(zFName)</a></h1> |
|
887
|
@ <div class='brlist'> |
|
888
|
@ <table class='sortable' data-column-types='tttxtttt' data-init-sort='1'> |
|
889
|
@ <thead><tr> |
|
890
|
@ <th>Date</th> |
|
891
|
@ <th>Check-in</th> |
|
892
|
@ <th>Parent<br>Check-in</th> |
|
893
|
@ <th>Merge?</th> |
|
894
|
@ <th>New</th> |
|
895
|
@ <th>Old</th> |
|
896
|
@ <th>Exe<br>Bit?</th> |
|
897
|
@ <th>Prior<br>Name</th> |
|
898
|
@ </tr></thead> |
|
899
|
@ <tbody> |
|
900
|
while( db_step(&q)==SQLITE_ROW ){ |
|
901
|
const char *zDate = db_column_text(&q,0); |
|
902
|
const char *zCkin = db_column_text(&q,1); |
|
903
|
const char *zParent = db_column_text(&q,2); |
|
904
|
int isMerge = db_column_int(&q,3); |
|
905
|
const char *zFid = db_column_text(&q,4); |
|
906
|
const char *zPid = db_column_text(&q,5); |
|
907
|
int isExe = db_column_int(&q,7); |
|
908
|
const char *zPrior = db_column_text(&q,8); |
|
909
|
@ <tr> |
|
910
|
@ <td><a href='%R/timeline?c=%!S(zCkin)'>%s(zDate)</a></td> |
|
911
|
@ <td><a href='%R/info/%!S(zCkin)'>%S(zCkin)</a></td> |
|
912
|
if( zParent ){ |
|
913
|
@ <td><a href='%R/info/%!S(zParent)'>%S(zParent)</a></td> |
|
914
|
}else{ |
|
915
|
@ <td><i>(New)</i></td> |
|
916
|
} |
|
917
|
@ <td align='center'>%s(isMerge?"✓":"")</td> |
|
918
|
if( zFid ){ |
|
919
|
@ <td><a href='%R/info/%!S(zFid)'>%S(zFid)</a></td> |
|
920
|
}else{ |
|
921
|
@ <td><i>(Deleted)</i></td> |
|
922
|
} |
|
923
|
if( zPid ){ |
|
924
|
@ <td><a href='%R/info/%!S(zPid)'>%S(zPid)</a> |
|
925
|
}else if( db_column_int(&q,6)<0 ){ |
|
926
|
@ <td><i>(Added by merge)</i></td> |
|
927
|
}else{ |
|
928
|
@ <td><i>(New)</i></td> |
|
929
|
} |
|
930
|
@ <td align='center'>%s(isExe?"✓":"")</td> |
|
931
|
if( zPrior ){ |
|
932
|
@ <td><a href='%R/finfo?name=%t(zPrior)'>%h(zPrior)</a></td> |
|
933
|
}else{ |
|
934
|
@ <td></td> |
|
935
|
} |
|
936
|
@ </tr> |
|
937
|
} |
|
938
|
db_finalize(&q); |
|
939
|
@ </tbody> |
|
940
|
@ </table> |
|
941
|
@ </div> |
|
942
|
}else{ |
|
943
|
int mid = name_to_rid_www("ci"); |
|
944
|
db_prepare(&q, |
|
945
|
"SELECT" |
|
946
|
/* 0 */ " (SELECT name FROM filename WHERE fnid=mlink.fnid)," |
|
947
|
/* 1 */ " (SELECT uuid FROM blob WHERE rid=mlink.fid)," |
|
948
|
/* 2 */ " pid," |
|
949
|
/* 3 */ " (SELECT uuid FROM blob WHERE rid=mlink.pid)," |
|
950
|
/* 4 */ " (SELECT name FROM filename WHERE fnid=mlink.pfnid)," |
|
951
|
/* 5 */ " (SELECT uuid FROM blob WHERE rid=mlink.pmid)," |
|
952
|
/* 6 */ " mperm," |
|
953
|
/* 7 */ " isaux" |
|
954
|
" FROM mlink WHERE mid=%d ORDER BY 1", |
|
955
|
mid |
|
956
|
); |
|
957
|
@ <h1>MLINK table for check-in %h(zCI)</h1> |
|
958
|
render_checkin_context(mid, 0, 1, 0); |
|
959
|
style_table_sorter(); |
|
960
|
@ <hr> |
|
961
|
@ <div class='brlist'> |
|
962
|
@ <table class='sortable' data-column-types='ttxtttt' data-init-sort='1'> |
|
963
|
@ <thead><tr> |
|
964
|
@ <th>File</th> |
|
965
|
@ <th>Parent<br>Check-in</th> |
|
966
|
@ <th>Merge?</th> |
|
967
|
@ <th>New</th> |
|
968
|
@ <th>Old</th> |
|
969
|
@ <th>Exe<br>Bit?</th> |
|
970
|
@ <th>Prior<br>Name</th> |
|
971
|
@ </tr></thead> |
|
972
|
@ <tbody> |
|
973
|
while( db_step(&q)==SQLITE_ROW ){ |
|
974
|
const char *zName = db_column_text(&q,0); |
|
975
|
const char *zFid = db_column_text(&q,1); |
|
976
|
const char *zPid = db_column_text(&q,3); |
|
977
|
const char *zPrior = db_column_text(&q,4); |
|
978
|
const char *zParent = db_column_text(&q,5); |
|
979
|
int isExec = db_column_int(&q,6); |
|
980
|
int isAux = db_column_int(&q,7); |
|
981
|
@ <tr> |
|
982
|
@ <td><a href='%R/finfo?name=%t(zName)'>%h(zName)</a></td> |
|
983
|
if( zParent ){ |
|
984
|
@ <td><a href='%R/info/%!S(zParent)'>%S(zParent)</a></td> |
|
985
|
}else{ |
|
986
|
@ <td><i>(New)</i></td> |
|
987
|
} |
|
988
|
@ <td align='center'>%s(isAux?"✓":"")</td> |
|
989
|
if( zFid ){ |
|
990
|
@ <td><a href='%R/info/%!S(zFid)'>%S(zFid)</a></td> |
|
991
|
}else{ |
|
992
|
@ <td><i>(Deleted)</i></td> |
|
993
|
} |
|
994
|
if( zPid ){ |
|
995
|
@ <td><a href='%R/info/%!S(zPid)'>%S(zPid)</a> |
|
996
|
}else if( db_column_int(&q,2)<0 ){ |
|
997
|
@ <td><i>(Added by merge)</i></td> |
|
998
|
}else{ |
|
999
|
@ <td><i>(New)</i></td> |
|
1000
|
} |
|
1001
|
@ <td align='center'>%s(isExec?"✓":"")</td> |
|
1002
|
if( zPrior ){ |
|
1003
|
@ <td><a href='%R/finfo?name=%t(zPrior)'>%h(zPrior)</a></td> |
|
1004
|
}else{ |
|
1005
|
@ <td></td> |
|
1006
|
} |
|
1007
|
@ </tr> |
|
1008
|
} |
|
1009
|
db_finalize(&q); |
|
1010
|
@ </tbody> |
|
1011
|
@ </table> |
|
1012
|
@ </div> |
|
1013
|
} |
|
1014
|
style_finish_page(); |
|
1015
|
} |
|
1016
|
|