|
dbda8d6…
|
drh
|
1 |
/* |
|
c19f34c…
|
drh
|
2 |
** Copyright (c) 2007 D. Richard Hipp |
|
dbda8d6…
|
drh
|
3 |
** |
|
dbda8d6…
|
drh
|
4 |
** This program is free software; you can redistribute it and/or |
|
c06edd2…
|
drh
|
5 |
** modify it under the terms of the Simplified BSD License (also |
|
c06edd2…
|
drh
|
6 |
** known as the "2-Clause License" or "FreeBSD License".) |
|
c06edd2…
|
drh
|
7 |
|
|
dbda8d6…
|
drh
|
8 |
** This program is distributed in the hope that it will be useful, |
|
c06edd2…
|
drh
|
9 |
** but without any warranty; without even the implied warranty of |
|
c06edd2…
|
drh
|
10 |
** merchantability or fitness for a particular purpose. |
|
dbda8d6…
|
drh
|
11 |
** |
|
dbda8d6…
|
drh
|
12 |
** Author contact information: |
|
dbda8d6…
|
drh
|
13 |
** [email protected] |
|
dbda8d6…
|
drh
|
14 |
** http://www.hwaci.com/drh/ |
|
dbda8d6…
|
drh
|
15 |
** |
|
dbda8d6…
|
drh
|
16 |
******************************************************************************* |
|
dbda8d6…
|
drh
|
17 |
** |
|
dbda8d6…
|
drh
|
18 |
** This file contains code to implement the "info" command. The |
|
dbda8d6…
|
drh
|
19 |
** "info" command gives command-line access to information about |
|
b5f4f91…
|
drh
|
20 |
** the current tree, or a particular artifact or check-in. |
|
dbda8d6…
|
drh
|
21 |
*/ |
|
dbda8d6…
|
drh
|
22 |
#include "config.h" |
|
dbda8d6…
|
drh
|
23 |
#include "info.h" |
|
dbda8d6…
|
drh
|
24 |
#include <assert.h> |
|
dbda8d6…
|
drh
|
25 |
|
|
6df39e3…
|
drh
|
26 |
/* |
|
01050d6…
|
jan.nijtmans
|
27 |
** Return a string (in memory obtained from malloc) holding a |
|
01050d6…
|
jan.nijtmans
|
28 |
** comma-separated list of tags that apply to check-in with |
|
4943c0e…
|
drh
|
29 |
** record-id rid. If the "propagatingOnly" flag is true, then only |
|
4943c0e…
|
drh
|
30 |
** show branch tags (tags that propagate to children). |
|
6df39e3…
|
drh
|
31 |
** |
|
6df39e3…
|
drh
|
32 |
** Return NULL if there are no such tags. |
|
6df39e3…
|
drh
|
33 |
*/ |
|
4943c0e…
|
drh
|
34 |
char *info_tags_of_checkin(int rid, int propagatingOnly){ |
|
6df39e3…
|
drh
|
35 |
char *zTags; |
|
6df39e3…
|
drh
|
36 |
zTags = db_text(0, "SELECT group_concat(substr(tagname, 5), ', ')" |
|
6df39e3…
|
drh
|
37 |
" FROM tagxref, tag" |
|
4943c0e…
|
drh
|
38 |
" WHERE tagxref.rid=%d AND tagxref.tagtype>%d" |
|
6df39e3…
|
drh
|
39 |
" AND tag.tagid=tagxref.tagid" |
|
6df39e3…
|
drh
|
40 |
" AND tag.tagname GLOB 'sym-*'", |
|
4943c0e…
|
drh
|
41 |
rid, propagatingOnly!=0); |
|
6df39e3…
|
drh
|
42 |
return zTags; |
|
6df39e3…
|
drh
|
43 |
} |
|
6df39e3…
|
drh
|
44 |
|
|
08db9e1…
|
drh
|
45 |
|
|
08db9e1…
|
drh
|
46 |
/* |
|
08db9e1…
|
drh
|
47 |
** Print common information about a particular record. |
|
08db9e1…
|
drh
|
48 |
** |
|
8ad5e46…
|
wyoung
|
49 |
** * The artifact hash |
|
08db9e1…
|
drh
|
50 |
** * The record ID |
|
08db9e1…
|
drh
|
51 |
** * mtime and ctime |
|
08db9e1…
|
drh
|
52 |
** * who signed it |
|
5c40f85…
|
jan.nijtmans
|
53 |
** |
|
08db9e1…
|
drh
|
54 |
*/ |
|
f78cba5…
|
drh
|
55 |
void show_common_info( |
|
5ea9ad3…
|
drh
|
56 |
int rid, /* The rid for the check-in to display info for */ |
|
bc36fdc…
|
danield
|
57 |
const char *zRecDesc, /* Brief record description; e.g. "check-out:" */ |
|
5ea9ad3…
|
drh
|
58 |
int showComment, /* True to show the check-in comment */ |
|
5ea9ad3…
|
drh
|
59 |
int showFamily /* True to show parents and children */ |
|
5ea9ad3…
|
drh
|
60 |
){ |
|
08db9e1…
|
drh
|
61 |
Stmt q; |
|
08db9e1…
|
drh
|
62 |
char *zComment = 0; |
|
08db9e1…
|
drh
|
63 |
char *zTags; |
|
76630dd…
|
drh
|
64 |
char *zDate; |
|
76630dd…
|
drh
|
65 |
char *zUuid; |
|
76630dd…
|
drh
|
66 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
76630dd…
|
drh
|
67 |
if( zUuid ){ |
|
01050d6…
|
jan.nijtmans
|
68 |
zDate = db_text(0, |
|
76630dd…
|
drh
|
69 |
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", |
|
76630dd…
|
drh
|
70 |
rid |
|
76630dd…
|
drh
|
71 |
); |
|
08db9e1…
|
drh
|
72 |
/* 01234567890123 */ |
|
8ad5e46…
|
wyoung
|
73 |
fossil_print("%-13s %.40s %s\n", zRecDesc, zUuid, zDate ? zDate : ""); |
|
5ea9ad3…
|
drh
|
74 |
free(zDate); |
|
d6cb724…
|
jan.nijtmans
|
75 |
if( showComment ){ |
|
d6cb724…
|
jan.nijtmans
|
76 |
zComment = db_text(0, |
|
d6cb724…
|
jan.nijtmans
|
77 |
"SELECT coalesce(ecomment,comment) || " |
|
d6cb724…
|
jan.nijtmans
|
78 |
" ' (user: ' || coalesce(euser,user,'?') || ')' " |
|
d6cb724…
|
jan.nijtmans
|
79 |
" FROM event WHERE objid=%d", |
|
d6cb724…
|
jan.nijtmans
|
80 |
rid |
|
d6cb724…
|
jan.nijtmans
|
81 |
); |
|
d6cb724…
|
jan.nijtmans
|
82 |
} |
|
d6cb724…
|
jan.nijtmans
|
83 |
free(zUuid); |
|
d6cb724…
|
jan.nijtmans
|
84 |
} |
|
5ea9ad3…
|
drh
|
85 |
if( showFamily ){ |
|
9caa350…
|
drh
|
86 |
db_prepare(&q, "SELECT uuid, pid, isprim FROM plink JOIN blob ON pid=rid " |
|
9caa350…
|
drh
|
87 |
" WHERE cid=%d" |
|
9caa350…
|
drh
|
88 |
" ORDER BY isprim DESC, mtime DESC /*sort*/", rid); |
|
5ea9ad3…
|
drh
|
89 |
while( db_step(&q)==SQLITE_ROW ){ |
|
5ea9ad3…
|
drh
|
90 |
const char *zUuid = db_column_text(&q, 0); |
|
9caa350…
|
drh
|
91 |
const char *zType = db_column_int(&q, 2) ? "parent:" : "merged-from:"; |
|
01050d6…
|
jan.nijtmans
|
92 |
zDate = db_text("", |
|
5ea9ad3…
|
drh
|
93 |
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", |
|
5ea9ad3…
|
drh
|
94 |
db_column_int(&q, 1) |
|
5ea9ad3…
|
drh
|
95 |
); |
|
5c87495…
|
drh
|
96 |
fossil_print("%-13s %.40s %s\n", zType, zUuid, zDate); |
|
5ea9ad3…
|
drh
|
97 |
free(zDate); |
|
5ea9ad3…
|
drh
|
98 |
} |
|
5ea9ad3…
|
drh
|
99 |
db_finalize(&q); |
|
9caa350…
|
drh
|
100 |
db_prepare(&q, "SELECT uuid, cid, isprim FROM plink JOIN blob ON cid=rid " |
|
9caa350…
|
drh
|
101 |
" WHERE pid=%d" |
|
9caa350…
|
drh
|
102 |
" ORDER BY isprim DESC, mtime DESC /*sort*/", rid); |
|
5ea9ad3…
|
drh
|
103 |
while( db_step(&q)==SQLITE_ROW ){ |
|
5ea9ad3…
|
drh
|
104 |
const char *zUuid = db_column_text(&q, 0); |
|
9caa350…
|
drh
|
105 |
const char *zType = db_column_int(&q, 2) ? "child:" : "merged-into:"; |
|
01050d6…
|
jan.nijtmans
|
106 |
zDate = db_text("", |
|
5ea9ad3…
|
drh
|
107 |
"SELECT datetime(mtime) || ' UTC' FROM event WHERE objid=%d", |
|
5ea9ad3…
|
drh
|
108 |
db_column_int(&q, 1) |
|
5ea9ad3…
|
drh
|
109 |
); |
|
5c87495…
|
drh
|
110 |
fossil_print("%-13s %.40s %s\n", zType, zUuid, zDate); |
|
5ea9ad3…
|
drh
|
111 |
free(zDate); |
|
5ea9ad3…
|
drh
|
112 |
} |
|
5ea9ad3…
|
drh
|
113 |
db_finalize(&q); |
|
5ea9ad3…
|
drh
|
114 |
} |
|
4943c0e…
|
drh
|
115 |
zTags = info_tags_of_checkin(rid, 0); |
|
4943c0e…
|
drh
|
116 |
if( zTags && zTags[0] ){ |
|
d8ec765…
|
drh
|
117 |
fossil_print("tags: %s\n", zTags); |
|
08db9e1…
|
drh
|
118 |
} |
|
08db9e1…
|
drh
|
119 |
free(zTags); |
|
08db9e1…
|
drh
|
120 |
if( zComment ){ |
|
d8ec765…
|
drh
|
121 |
fossil_print("comment: "); |
|
2476b81…
|
drh
|
122 |
comment_print(zComment, 0, 14, -1, get_comment_format()); |
|
08db9e1…
|
drh
|
123 |
free(zComment); |
|
08db9e1…
|
drh
|
124 |
} |
|
08db9e1…
|
drh
|
125 |
} |
|
08db9e1…
|
drh
|
126 |
|
|
e604d48…
|
drh
|
127 |
/* |
|
e604d48…
|
drh
|
128 |
** Print information about the URLs used to access a repository and |
|
e604d48…
|
drh
|
129 |
** checkouts in a repository. |
|
e604d48…
|
drh
|
130 |
*/ |
|
e604d48…
|
drh
|
131 |
static void extraRepoInfo(void){ |
|
e604d48…
|
drh
|
132 |
Stmt s; |
|
e604d48…
|
drh
|
133 |
db_prepare(&s, "SELECT substr(name,7), date(mtime,'unixepoch')" |
|
e604d48…
|
drh
|
134 |
" FROM config" |
|
12ab581…
|
drh
|
135 |
" WHERE name GLOB 'ckout:*' ORDER BY mtime DESC"); |
|
e604d48…
|
drh
|
136 |
while( db_step(&s)==SQLITE_ROW ){ |
|
e604d48…
|
drh
|
137 |
const char *zName; |
|
e604d48…
|
drh
|
138 |
const char *zCkout = db_column_text(&s, 0); |
|
c666579…
|
drh
|
139 |
if( !vfile_top_of_checkout(zCkout) ) continue; |
|
e604d48…
|
drh
|
140 |
if( g.localOpen ){ |
|
e604d48…
|
drh
|
141 |
if( fossil_strcmp(zCkout, g.zLocalRoot)==0 ) continue; |
|
e604d48…
|
drh
|
142 |
zName = "alt-root:"; |
|
e604d48…
|
drh
|
143 |
}else{ |
|
e604d48…
|
drh
|
144 |
zName = "check-out:"; |
|
e604d48…
|
drh
|
145 |
} |
|
e604d48…
|
drh
|
146 |
fossil_print("%-11s %-54s %s\n", zName, zCkout, |
|
e604d48…
|
drh
|
147 |
db_column_text(&s, 1)); |
|
e604d48…
|
drh
|
148 |
} |
|
e604d48…
|
drh
|
149 |
db_finalize(&s); |
|
e604d48…
|
drh
|
150 |
db_prepare(&s, "SELECT substr(name,9), date(mtime,'unixepoch')" |
|
e604d48…
|
drh
|
151 |
" FROM config" |
|
12ab581…
|
drh
|
152 |
" WHERE name GLOB 'baseurl:*' ORDER BY mtime DESC"); |
|
e604d48…
|
drh
|
153 |
while( db_step(&s)==SQLITE_ROW ){ |
|
e604d48…
|
drh
|
154 |
fossil_print("access-url: %-54s %s\n", db_column_text(&s, 0), |
|
e604d48…
|
drh
|
155 |
db_column_text(&s, 1)); |
|
e604d48…
|
drh
|
156 |
} |
|
e604d48…
|
drh
|
157 |
db_finalize(&s); |
|
e604d48…
|
drh
|
158 |
} |
|
e604d48…
|
drh
|
159 |
|
|
dddc58d…
|
drh
|
160 |
/* |
|
dddc58d…
|
drh
|
161 |
** Show the parent project, if any |
|
dddc58d…
|
drh
|
162 |
*/ |
|
dddc58d…
|
drh
|
163 |
static void showParentProject(void){ |
|
dddc58d…
|
drh
|
164 |
const char *zParentCode; |
|
dddc58d…
|
drh
|
165 |
zParentCode = db_get("parent-project-code",0); |
|
dddc58d…
|
drh
|
166 |
if( zParentCode ){ |
|
9167b2d…
|
drh
|
167 |
fossil_print("derived-from: %s %s\n", zParentCode, |
|
9167b2d…
|
drh
|
168 |
db_get("parent-project-name","")); |
|
dddc58d…
|
drh
|
169 |
} |
|
dddc58d…
|
drh
|
170 |
} |
|
08db9e1…
|
drh
|
171 |
|
|
08db9e1…
|
drh
|
172 |
/* |
|
08db9e1…
|
drh
|
173 |
** COMMAND: info |
|
08db9e1…
|
drh
|
174 |
** |
|
6cf0053…
|
drh
|
175 |
** Usage: %fossil info ?VERSION | REPOSITORY_FILENAME? ?OPTIONS? |
|
08db9e1…
|
drh
|
176 |
** |
|
08db9e1…
|
drh
|
177 |
** With no arguments, provide information about the current tree. |
|
08db9e1…
|
drh
|
178 |
** If an argument is specified, provide information about the object |
|
7c0f4ec…
|
jan.nijtmans
|
179 |
** in the repository of the current tree that the argument refers |
|
08db9e1…
|
drh
|
180 |
** to. Or if the argument is the name of a repository, show |
|
08db9e1…
|
drh
|
181 |
** information about that repository. |
|
828bf98…
|
drh
|
182 |
** |
|
9167b2d…
|
drh
|
183 |
** If the argument is a repository name, then the --verbose option shows |
|
3d58d89…
|
drh
|
184 |
** all known check-out locations for that repository and all URLs used |
|
9167b2d…
|
drh
|
185 |
** to access the repository. The --verbose is (currently) a no-op if |
|
99a319b…
|
wyoung
|
186 |
** the argument is the name of an object within the repository. |
|
9167b2d…
|
drh
|
187 |
** |
|
828bf98…
|
drh
|
188 |
** Use the "finfo" command to get information about a specific |
|
bc36fdc…
|
danield
|
189 |
** file in a check-out. |
|
6cf0053…
|
drh
|
190 |
** |
|
6cf0053…
|
drh
|
191 |
** Options: |
|
decd537…
|
stephan
|
192 |
** -R|--repository REPO Extract info from repository REPO |
|
9167b2d…
|
drh
|
193 |
** -v|--verbose Show extra information about repositories |
|
6cf0053…
|
drh
|
194 |
** |
|
c965636…
|
drh
|
195 |
** See also: [[annotate]], [[artifact]], [[finfo]], [[timeline]] |
|
08db9e1…
|
drh
|
196 |
*/ |
|
08db9e1…
|
drh
|
197 |
void info_cmd(void){ |
|
08db9e1…
|
drh
|
198 |
i64 fsize; |
|
5214a2a…
|
jan.nijtmans
|
199 |
int verboseFlag = find_option("verbose","v",0)!=0; |
|
5214a2a…
|
jan.nijtmans
|
200 |
if( !verboseFlag ){ |
|
5214a2a…
|
jan.nijtmans
|
201 |
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */ |
|
5214a2a…
|
jan.nijtmans
|
202 |
} |
|
74ac0c9…
|
drh
|
203 |
|
|
1772357…
|
drh
|
204 |
if( g.argc==3 |
|
0ee8c8c…
|
drh
|
205 |
&& file_isfile(g.argv[2], ExtFILE) |
|
1772357…
|
drh
|
206 |
&& (fsize = file_size(g.argv[2], ExtFILE))>0 |
|
1772357…
|
drh
|
207 |
&& (fsize&0x1ff)==0 |
|
1772357…
|
drh
|
208 |
){ |
|
b06cd63…
|
mistachkin
|
209 |
db_open_config(0, 0); |
|
08db9e1…
|
drh
|
210 |
db_open_repository(g.argv[2]); |
|
0c51600…
|
mistachkin
|
211 |
db_record_repository_filename(g.argv[2]); |
|
d8ec765…
|
drh
|
212 |
fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); |
|
d8ec765…
|
drh
|
213 |
fossil_print("project-code: %s\n", db_get("project-code", "<none>")); |
|
dddc58d…
|
drh
|
214 |
showParentProject(); |
|
e604d48…
|
drh
|
215 |
extraRepoInfo(); |
|
08db9e1…
|
drh
|
216 |
return; |
|
08db9e1…
|
drh
|
217 |
} |
|
6e71a28…
|
drh
|
218 |
db_find_and_open_repository(OPEN_OK_NOT_FOUND,0); |
|
5826f9c…
|
drh
|
219 |
verify_all_options(); |
|
08db9e1…
|
drh
|
220 |
if( g.argc==2 ){ |
|
08db9e1…
|
drh
|
221 |
int vid; |
|
6e71a28…
|
drh
|
222 |
if( g.repositoryOpen ){ |
|
6e71a28…
|
drh
|
223 |
db_record_repository_filename(0); |
|
6e71a28…
|
drh
|
224 |
fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>")); |
|
6e71a28…
|
drh
|
225 |
}else{ |
|
6e71a28…
|
drh
|
226 |
db_open_config(0,1); |
|
6e71a28…
|
drh
|
227 |
} |
|
4fe2214…
|
drh
|
228 |
if( g.localOpen ){ |
|
a7248d8…
|
drh
|
229 |
fossil_print("repository: %s\n", db_repository_filename()); |
|
4fe2214…
|
drh
|
230 |
fossil_print("local-root: %s\n", g.zLocalRoot); |
|
4fe2214…
|
drh
|
231 |
} |
|
1da8afd…
|
drh
|
232 |
if( verboseFlag && g.repositoryOpen ){ |
|
1da8afd…
|
drh
|
233 |
extraRepoInfo(); |
|
1da8afd…
|
drh
|
234 |
} |
|
a5dc533…
|
jan.nijtmans
|
235 |
if( g.zConfigDbName ){ |
|
a5dc533…
|
jan.nijtmans
|
236 |
fossil_print("config-db: %s\n", g.zConfigDbName); |
|
a5dc533…
|
jan.nijtmans
|
237 |
} |
|
6e71a28…
|
drh
|
238 |
if( g.repositoryOpen ){ |
|
6e71a28…
|
drh
|
239 |
fossil_print("project-code: %s\n", db_get("project-code", "")); |
|
6e71a28…
|
drh
|
240 |
showParentProject(); |
|
6e71a28…
|
drh
|
241 |
vid = g.localOpen ? db_lget_int("checkout", 0) : 0; |
|
6e71a28…
|
drh
|
242 |
if( vid ){ |
|
6e71a28…
|
drh
|
243 |
show_common_info(vid, "checkout:", 1, 1); |
|
6e71a28…
|
drh
|
244 |
} |
|
6e71a28…
|
drh
|
245 |
fossil_print("check-ins: %d\n", |
|
d94362b…
|
drh
|
246 |
db_int(-1, "SELECT count(*) FROM event WHERE type='ci' /*scan*/")); |
|
6e71a28…
|
drh
|
247 |
} |
|
1da8afd…
|
drh
|
248 |
if( verboseFlag || !g.repositoryOpen ){ |
|
1da8afd…
|
drh
|
249 |
Blob vx; |
|
1da8afd…
|
drh
|
250 |
char *z; |
|
1da8afd…
|
drh
|
251 |
fossil_version_blob(&vx, 0); |
|
1da8afd…
|
drh
|
252 |
z = strstr(blob_str(&vx), "version"); |
|
1da8afd…
|
drh
|
253 |
if( z ){ |
|
1da8afd…
|
drh
|
254 |
z += 8; |
|
1da8afd…
|
drh
|
255 |
}else{ |
|
1da8afd…
|
drh
|
256 |
z = blob_str(&vx); |
|
1da8afd…
|
drh
|
257 |
} |
|
01fcc6a…
|
drh
|
258 |
fossil_print("fossil: %z\n", file_fullexename(g.nameOfExe)); |
|
1da8afd…
|
drh
|
259 |
fossil_print("version: %s", z); |
|
1da8afd…
|
drh
|
260 |
blob_reset(&vx); |
|
1da8afd…
|
drh
|
261 |
} |
|
c6a0e66…
|
drh
|
262 |
}else if( g.repositoryOpen ){ |
|
08db9e1…
|
drh
|
263 |
int rid; |
|
08db9e1…
|
drh
|
264 |
rid = name_to_rid(g.argv[2]); |
|
08db9e1…
|
drh
|
265 |
if( rid==0 ){ |
|
2c42b21…
|
andygoth
|
266 |
fossil_fatal("no such object: %s", g.argv[2]); |
|
b5f4f91…
|
drh
|
267 |
} |
|
8ad5e46…
|
wyoung
|
268 |
show_common_info(rid, "hash:", 1, 1); |
|
c6a0e66…
|
drh
|
269 |
}else{ |
|
403a3ae…
|
drh
|
270 |
fossil_fatal("Could not find or open a Fossil repository"); |
|
e2d5372…
|
drh
|
271 |
} |
|
e2d5372…
|
drh
|
272 |
} |
|
e2d5372…
|
drh
|
273 |
|
|
e2d5372…
|
drh
|
274 |
/* |
|
e2d5372…
|
drh
|
275 |
** Show the context graph (immediate parents and children) for |
|
e454028…
|
drh
|
276 |
** check-in rid and rid2. rid2 might be zero, in which case only |
|
e454028…
|
drh
|
277 |
** show the context for rid1. |
|
e632a09…
|
drh
|
278 |
*/ |
|
e454028…
|
drh
|
279 |
void render_checkin_context( |
|
e454028…
|
drh
|
280 |
int rid, int rid2, /* One or two checkins for which to show context */ |
|
e454028…
|
drh
|
281 |
int mRCCFlags, /* Flags. 1: parents only, 2: shadow-select rid */ |
|
e454028…
|
drh
|
282 |
int mFlags /* Graph flags */ |
|
e454028…
|
drh
|
283 |
){ |
|
e632a09…
|
drh
|
284 |
Blob sql; |
|
e632a09…
|
drh
|
285 |
Stmt q; |
|
e632a09…
|
drh
|
286 |
int rx[2]; |
|
e632a09…
|
drh
|
287 |
int i, n; |
|
e454028…
|
drh
|
288 |
TimelineXtra xtra; |
|
e454028…
|
drh
|
289 |
|
|
e632a09…
|
drh
|
290 |
rx[0] = rid; |
|
e632a09…
|
drh
|
291 |
rx[1] = rid2; |
|
e632a09…
|
drh
|
292 |
n = rid2 ? 2 : 1; |
|
e632a09…
|
drh
|
293 |
blob_zero(&sql); |
|
e632a09…
|
drh
|
294 |
blob_append(&sql, timeline_query_for_www(), -1); |
|
e632a09…
|
drh
|
295 |
|
|
e632a09…
|
drh
|
296 |
db_multi_exec( |
|
e632a09…
|
drh
|
297 |
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);" |
|
e632a09…
|
drh
|
298 |
"DELETE FROM ok;" |
|
e632a09…
|
drh
|
299 |
); |
|
e632a09…
|
drh
|
300 |
for(i=0; i<n; i++){ |
|
e632a09…
|
drh
|
301 |
db_multi_exec( |
|
e632a09…
|
drh
|
302 |
"INSERT OR IGNORE INTO ok VALUES(%d);" |
|
e632a09…
|
drh
|
303 |
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;", |
|
e632a09…
|
drh
|
304 |
rx[i], rx[i] |
|
e632a09…
|
drh
|
305 |
); |
|
e632a09…
|
drh
|
306 |
} |
|
e454028…
|
drh
|
307 |
if( (mRCCFlags & 0x01)==0 ){ |
|
e632a09…
|
drh
|
308 |
for(i=0; i<n; i++){ |
|
e632a09…
|
drh
|
309 |
db_multi_exec( |
|
e632a09…
|
drh
|
310 |
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;", rx[i] |
|
e632a09…
|
drh
|
311 |
); |
|
e632a09…
|
drh
|
312 |
if( db_table_exists("repository","cherrypick") ){ |
|
e632a09…
|
drh
|
313 |
db_multi_exec( |
|
e632a09…
|
drh
|
314 |
"INSERT OR IGNORE INTO ok " |
|
e632a09…
|
drh
|
315 |
" SELECT parentid FROM cherrypick WHERE childid=%d;" |
|
e632a09…
|
drh
|
316 |
"INSERT OR IGNORE INTO ok " |
|
e632a09…
|
drh
|
317 |
" SELECT childid FROM cherrypick WHERE parentid=%d;", |
|
e632a09…
|
drh
|
318 |
rx[i], rx[i] |
|
e632a09…
|
drh
|
319 |
); |
|
e632a09…
|
drh
|
320 |
} |
|
e632a09…
|
drh
|
321 |
} |
|
e632a09…
|
drh
|
322 |
} |
|
e632a09…
|
drh
|
323 |
blob_append_sql(&sql, " AND event.objid IN ok ORDER BY mtime DESC"); |
|
e632a09…
|
drh
|
324 |
db_prepare(&q, "%s", blob_sql_text(&sql)); |
|
e454028…
|
drh
|
325 |
memset(&xtra, 0, sizeof(xtra)); |
|
e454028…
|
drh
|
326 |
if( mRCCFlags & 0x02 ){ |
|
e454028…
|
drh
|
327 |
xtra.currentRid = rid; |
|
e454028…
|
drh
|
328 |
}else{ |
|
e454028…
|
drh
|
329 |
xtra.selectedRid = rid; |
|
e454028…
|
drh
|
330 |
xtra.secondRid = rid2; |
|
e454028…
|
drh
|
331 |
} |
|
e454028…
|
drh
|
332 |
mFlags |= TIMELINE_GRAPH|TIMELINE_FILLGAPS|TIMELINE_NOSCROLL| |
|
e454028…
|
drh
|
333 |
TIMELINE_XMERGE|TIMELINE_CHPICK; |
|
e454028…
|
drh
|
334 |
www_print_timeline(&q, mFlags, &xtra); |
|
ae1dac8…
|
drh
|
335 |
db_finalize(&q); |
|
37ae94b…
|
drh
|
336 |
blob_reset(&sql); |
|
e2d5372…
|
drh
|
337 |
} |
|
e2d5372…
|
drh
|
338 |
|
|
e2d5372…
|
drh
|
339 |
|
|
e2d5372…
|
drh
|
340 |
/* |
|
e2d5372…
|
drh
|
341 |
** Append the difference between artifacts to the output |
|
e2d5372…
|
drh
|
342 |
*/ |
|
e2d5372…
|
drh
|
343 |
static void append_diff( |
|
e2d5372…
|
drh
|
344 |
const char *zFrom, /* Diff from this artifact */ |
|
e2d5372…
|
drh
|
345 |
const char *zTo, /* ... to this artifact */ |
|
1347a1d…
|
drh
|
346 |
DiffConfig *pCfg /* The diff configuration */ |
|
e2d5372…
|
drh
|
347 |
){ |
|
e2d5372…
|
drh
|
348 |
int fromid; |
|
e2d5372…
|
drh
|
349 |
int toid; |
|
ea52b7d…
|
drh
|
350 |
Blob from, to; |
|
e2d5372…
|
drh
|
351 |
if( zFrom ){ |
|
e2d5372…
|
drh
|
352 |
fromid = uuid_to_rid(zFrom, 0); |
|
e2d5372…
|
drh
|
353 |
content_get(fromid, &from); |
|
c275a16…
|
drh
|
354 |
pCfg->zLeftHash = zFrom; |
|
e2d5372…
|
drh
|
355 |
}else{ |
|
e2d5372…
|
drh
|
356 |
blob_zero(&from); |
|
c275a16…
|
drh
|
357 |
pCfg->zLeftHash = 0; |
|
e2d5372…
|
drh
|
358 |
} |
|
e2d5372…
|
drh
|
359 |
if( zTo ){ |
|
e2d5372…
|
drh
|
360 |
toid = uuid_to_rid(zTo, 0); |
|
e2d5372…
|
drh
|
361 |
content_get(toid, &to); |
|
e2d5372…
|
drh
|
362 |
}else{ |
|
e2d5372…
|
drh
|
363 |
blob_zero(&to); |
|
e2d5372…
|
drh
|
364 |
} |
|
1347a1d…
|
drh
|
365 |
if( pCfg->diffFlags & DIFF_SIDEBYSIDE ){ |
|
1347a1d…
|
drh
|
366 |
pCfg->diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
|
e2d5372…
|
drh
|
367 |
}else{ |
|
1347a1d…
|
drh
|
368 |
pCfg->diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
|
e2d5372…
|
drh
|
369 |
} |
|
1347a1d…
|
drh
|
370 |
text_diff(&from, &to, cgi_output_blob(), pCfg); |
|
c275a16…
|
drh
|
371 |
pCfg->zLeftHash = 0; |
|
e2d5372…
|
drh
|
372 |
blob_reset(&from); |
|
e2d5372…
|
drh
|
373 |
blob_reset(&to); |
|
e2d5372…
|
drh
|
374 |
} |
|
c275a16…
|
drh
|
375 |
|
|
c275a16…
|
drh
|
376 |
/* |
|
94e94bc…
|
drh
|
377 |
** The append_file_change_line() routine updates an array of counts |
|
94e94bc…
|
drh
|
378 |
** for various kinds of changes. |
|
94e94bc…
|
drh
|
379 |
*/ |
|
94e94bc…
|
drh
|
380 |
#define FCHNG_NEW 0 |
|
94e94bc…
|
drh
|
381 |
#define FCHNG_DELETE 1 |
|
94e94bc…
|
drh
|
382 |
#define FCHNG_RENAME 2 |
|
94e94bc…
|
drh
|
383 |
#define FCHNG_MODE 3 |
|
94e94bc…
|
drh
|
384 |
#define FCHNG_EDIT 4 |
|
94e94bc…
|
drh
|
385 |
#define N_FCHNG 5 |
|
94e94bc…
|
drh
|
386 |
|
|
94e94bc…
|
drh
|
387 |
/* |
|
e2d5372…
|
drh
|
388 |
** Write a line of web-page output that shows changes that have occurred |
|
e2d5372…
|
drh
|
389 |
** to a file between two check-ins. |
|
e2d5372…
|
drh
|
390 |
*/ |
|
e2d5372…
|
drh
|
391 |
static void append_file_change_line( |
|
bc36fdc…
|
danield
|
392 |
const char *zCkin, /* The check-in on which the change occurs */ |
|
e2d5372…
|
drh
|
393 |
const char *zName, /* Name of the file that has changed */ |
|
e2d5372…
|
drh
|
394 |
const char *zOld, /* blob.uuid before change. NULL for added files */ |
|
e2d5372…
|
drh
|
395 |
const char *zNew, /* blob.uuid after change. NULL for deletes */ |
|
e2d5372…
|
drh
|
396 |
const char *zOldName, /* Prior name. NULL if no name change. */ |
|
1347a1d…
|
drh
|
397 |
DiffConfig *pCfg, /* Flags for text_diff() or NULL to omit all */ |
|
94e94bc…
|
drh
|
398 |
int mperm, /* executable or symlink permission for zNew */ |
|
94e94bc…
|
drh
|
399 |
int *aChng /* Change count array */ |
|
e2d5372…
|
drh
|
400 |
){ |
|
a11d245…
|
stephan
|
401 |
@ <div class='file-change-line'><span> |
|
a11d245…
|
stephan
|
402 |
/* Maintenance reminder: the extra level of SPAN is for |
|
a11d245…
|
stephan
|
403 |
** arranging new elements via JS. */ |
|
e2d5372…
|
drh
|
404 |
if( !g.perm.Hyperlink ){ |
|
e2d5372…
|
drh
|
405 |
if( zNew==0 ){ |
|
e2d5372…
|
drh
|
406 |
@ Deleted %h(zName). |
|
94e94bc…
|
drh
|
407 |
aChng[FCHNG_DELETE]++; |
|
e2d5372…
|
drh
|
408 |
}else if( zOld==0 ){ |
|
e2d5372…
|
drh
|
409 |
@ Added %h(zName). |
|
94e94bc…
|
drh
|
410 |
aChng[FCHNG_NEW]++; |
|
e2d5372…
|
drh
|
411 |
}else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){ |
|
e2d5372…
|
drh
|
412 |
@ Name change from %h(zOldName) to %h(zName). |
|
94e94bc…
|
drh
|
413 |
aChng[FCHNG_RENAME]++; |
|
e2d5372…
|
drh
|
414 |
}else if( fossil_strcmp(zNew, zOld)==0 ){ |
|
e2d5372…
|
drh
|
415 |
if( mperm==PERM_EXE ){ |
|
e2d5372…
|
drh
|
416 |
@ %h(zName) became executable. |
|
e2d5372…
|
drh
|
417 |
}else if( mperm==PERM_LNK ){ |
|
e2d5372…
|
drh
|
418 |
@ %h(zName) became a symlink. |
|
e2d5372…
|
drh
|
419 |
}else{ |
|
e2d5372…
|
drh
|
420 |
@ %h(zName) became a regular file. |
|
e2d5372…
|
drh
|
421 |
} |
|
94e94bc…
|
drh
|
422 |
aChng[FCHNG_MODE]++; |
|
e2d5372…
|
drh
|
423 |
}else{ |
|
e2d5372…
|
drh
|
424 |
@ Changes to %h(zName). |
|
94e94bc…
|
drh
|
425 |
aChng[FCHNG_EDIT]++; |
|
e2d5372…
|
drh
|
426 |
} |
|
a11d245…
|
stephan
|
427 |
@ </span></div> |
|
1347a1d…
|
drh
|
428 |
if( pCfg ){ |
|
1347a1d…
|
drh
|
429 |
append_diff(zOld, zNew, pCfg); |
|
e2d5372…
|
drh
|
430 |
} |
|
e2d5372…
|
drh
|
431 |
}else{ |
|
2871b39…
|
danield
|
432 |
const char *zCkin2 = |
|
2871b39…
|
danield
|
433 |
mprintf(validate16(zCkin, -1) ? "%!S" : "%T"/*works-like:"%s"*/, zCkin); |
|
e2d5372…
|
drh
|
434 |
if( zOld && zNew ){ |
|
e2d5372…
|
drh
|
435 |
if( fossil_strcmp(zOld, zNew)!=0 ){ |
|
495a4d7…
|
mark
|
436 |
if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){ |
|
495a4d7…
|
mark
|
437 |
@ Renamed and modified |
|
2871b39…
|
danield
|
438 |
@ %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zOldName,zOld,zCkin2))\ |
|
495a4d7…
|
mark
|
439 |
@ %h(zOldName)</a> |
|
495a4d7…
|
mark
|
440 |
@ %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a> |
|
2871b39…
|
danield
|
441 |
@ to %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zName,zNew,zCkin2))\ |
|
495a4d7…
|
mark
|
442 |
@ %h(zName)</a> |
|
495a4d7…
|
mark
|
443 |
@ %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>. |
|
94e94bc…
|
drh
|
444 |
aChng[FCHNG_RENAME]++; |
|
495a4d7…
|
mark
|
445 |
}else{ |
|
2871b39…
|
danield
|
446 |
@ Modified %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zName,zNew,zCkin2))\ |
|
495a4d7…
|
mark
|
447 |
@ %h(zName)</a> |
|
495a4d7…
|
mark
|
448 |
@ from %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a> |
|
495a4d7…
|
mark
|
449 |
@ to %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>. |
|
495a4d7…
|
mark
|
450 |
} |
|
94e94bc…
|
drh
|
451 |
aChng[FCHNG_EDIT]++; |
|
e2d5372…
|
drh
|
452 |
}else if( zOldName!=0 && fossil_strcmp(zName,zOldName)!=0 ){ |
|
e2d5372…
|
drh
|
453 |
@ Name change |
|
2871b39…
|
danield
|
454 |
@ from %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zOldName,zOld,zCkin2))\ |
|
b54d939…
|
drh
|
455 |
@ %h(zOldName)</a> |
|
2871b39…
|
danield
|
456 |
@ to %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zName,zNew,zCkin2))\ |
|
b54d939…
|
drh
|
457 |
@ %h(zName)</a>. |
|
94e94bc…
|
drh
|
458 |
aChng[FCHNG_RENAME]++; |
|
e2d5372…
|
drh
|
459 |
}else{ |
|
2871b39…
|
danield
|
460 |
@ %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zName,zNew,zCkin2))\ |
|
b54d939…
|
drh
|
461 |
@ %h(zName)</a> became |
|
e2d5372…
|
drh
|
462 |
if( mperm==PERM_EXE ){ |
|
e2d5372…
|
drh
|
463 |
@ executable with contents |
|
e2d5372…
|
drh
|
464 |
}else if( mperm==PERM_LNK ){ |
|
e2d5372…
|
drh
|
465 |
@ a symlink with target |
|
e2d5372…
|
drh
|
466 |
}else{ |
|
e2d5372…
|
drh
|
467 |
@ a regular file with contents |
|
e2d5372…
|
drh
|
468 |
} |
|
e2d5372…
|
drh
|
469 |
@ %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>. |
|
94e94bc…
|
drh
|
470 |
aChng[FCHNG_MODE]++; |
|
e2d5372…
|
drh
|
471 |
} |
|
e2d5372…
|
drh
|
472 |
}else if( zOld ){ |
|
2871b39…
|
danield
|
473 |
@ Deleted %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zName,zOld,zCkin2))\ |
|
b54d939…
|
drh
|
474 |
@ %h(zName)</a> version %z(href("%R/artifact/%!S",zOld))[%S(zOld)]</a>. |
|
94e94bc…
|
drh
|
475 |
aChng[FCHNG_DELETE]++; |
|
b54d939…
|
drh
|
476 |
}else{ |
|
2871b39…
|
danield
|
477 |
@ Added %z(href("%R/finfo?name=%T&m=%!S&ci=%s",zName,zNew,zCkin2))\ |
|
b54d939…
|
drh
|
478 |
@ %h(zName)</a> version %z(href("%R/artifact/%!S",zNew))[%S(zNew)]</a>. |
|
94e94bc…
|
drh
|
479 |
aChng[FCHNG_NEW]++; |
|
b54d939…
|
drh
|
480 |
} |
|
8b73fbb…
|
mgagnon
|
481 |
if( zOld && zNew && fossil_strcmp(zOld,zNew)!=0 ){ |
|
8b73fbb…
|
mgagnon
|
482 |
if( pCfg ){ |
|
d463c7e…
|
stephan
|
483 |
@ </span></div> |
|
8b73fbb…
|
mgagnon
|
484 |
append_diff(zOld, zNew, pCfg); |
|
a11d245…
|
stephan
|
485 |
}else{ |
|
8b73fbb…
|
mgagnon
|
486 |
@ %z(href("%R/fdiff?v1=%!S&v2=%!S",zOld,zNew))[diff]</a> |
|
d463c7e…
|
stephan
|
487 |
@ </span></div> |
|
8b73fbb…
|
mgagnon
|
488 |
} |
|
d463c7e…
|
stephan
|
489 |
}else{ |
|
d463c7e…
|
stephan
|
490 |
@ </span></div> |
|
e2d5372…
|
drh
|
491 |
} |
|
e2d5372…
|
drh
|
492 |
} |
|
e2d5372…
|
drh
|
493 |
} |
|
e2d5372…
|
drh
|
494 |
|
|
e2d5372…
|
drh
|
495 |
/* |
|
e2d5372…
|
drh
|
496 |
** Generate javascript to enhance HTML diffs. |
|
e2d5372…
|
drh
|
497 |
*/ |
|
f9761ab…
|
florian
|
498 |
void append_diff_javascript(int diffType){ |
|
f9761ab…
|
florian
|
499 |
if( diffType==0 ) return; |
|
51c1efd…
|
stephan
|
500 |
builtin_fossil_js_bundle_or("diff", NULL); |
|
e2d5372…
|
drh
|
501 |
} |
|
e2d5372…
|
drh
|
502 |
|
|
e2d5372…
|
drh
|
503 |
/* |
|
e2d5372…
|
drh
|
504 |
** Construct an appropriate diffFlag for text_diff() based on query |
|
e2d5372…
|
drh
|
505 |
** parameters and the to boolean arguments. |
|
e2d5372…
|
drh
|
506 |
*/ |
|
1347a1d…
|
drh
|
507 |
DiffConfig *construct_diff_flags(int diffType, DiffConfig *pCfg){ |
|
e2d5372…
|
drh
|
508 |
u64 diffFlags = 0; /* Zero means do not show any diff */ |
|
e2d5372…
|
drh
|
509 |
if( diffType>0 ){ |
|
e2d5372…
|
drh
|
510 |
int x; |
|
ca6fa4b…
|
drh
|
511 |
if( diffType==2 ) diffFlags = DIFF_SIDEBYSIDE; |
|
fa27979…
|
stephan
|
512 |
if( P_NoBot("w") ) diffFlags |= DIFF_IGNORE_ALLWS; |
|
fa27979…
|
stephan
|
513 |
if( PD_NoBot("noopt",0)!=0 ) diffFlags |= DIFF_NOOPT; |
|
ca6fa4b…
|
drh
|
514 |
diffFlags |= DIFF_STRIP_EOLCR; |
|
ca6fa4b…
|
drh
|
515 |
diff_config_init(pCfg, diffFlags); |
|
ca6fa4b…
|
drh
|
516 |
|
|
e2d5372…
|
drh
|
517 |
/* "dc" query parameter determines lines of context */ |
|
e2d5372…
|
drh
|
518 |
x = atoi(PD("dc","7")); |
|
ca6fa4b…
|
drh
|
519 |
if( x>0 ) pCfg->nContext = x; |
|
e2d5372…
|
drh
|
520 |
|
|
e2d5372…
|
drh
|
521 |
/* The "noopt" parameter disables diff optimization */ |
|
1347a1d…
|
drh
|
522 |
return pCfg; |
|
1347a1d…
|
drh
|
523 |
}else{ |
|
1347a1d…
|
drh
|
524 |
diff_config_init(pCfg, 0); |
|
1347a1d…
|
drh
|
525 |
return 0; |
|
b5f4f91…
|
drh
|
526 |
} |
|
b5f4f91…
|
drh
|
527 |
} |
|
b5f4f91…
|
drh
|
528 |
|
|
b5f4f91…
|
drh
|
529 |
/* |
|
e2d5372…
|
drh
|
530 |
** WEBPAGE: ci_tags |
|
e2d5372…
|
drh
|
531 |
** URL: /ci_tags?name=ARTIFACTID |
|
e2d5372…
|
drh
|
532 |
** |
|
e2d5372…
|
drh
|
533 |
** Show all tags and properties for a given check-in. |
|
e2d5372…
|
drh
|
534 |
** |
|
e2d5372…
|
drh
|
535 |
** This information used to be part of the main /ci page, but it is of |
|
e2d5372…
|
drh
|
536 |
** marginal usefulness. Better to factor it out into a sub-screen. |
|
b5f4f91…
|
drh
|
537 |
*/ |
|
e2d5372…
|
drh
|
538 |
void ci_tags_page(void){ |
|
e2d5372…
|
drh
|
539 |
const char *zHash; |
|
e2d5372…
|
drh
|
540 |
int rid; |
|
b5f4f91…
|
drh
|
541 |
Stmt q; |
|
b5f4f91…
|
drh
|
542 |
int cnt = 0; |
|
e2d5372…
|
drh
|
543 |
Blob sql; |
|
41f0838…
|
stephan
|
544 |
char const *zType; |
|
e454028…
|
drh
|
545 |
TimelineXtra xtra; |
|
e2d5372…
|
drh
|
546 |
|
|
e2d5372…
|
drh
|
547 |
login_check_credentials(); |
|
e2d5372…
|
drh
|
548 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
e2d5372…
|
drh
|
549 |
rid = name_to_rid_www("name"); |
|
e2d5372…
|
drh
|
550 |
if( rid==0 ){ |
|
e2d5372…
|
drh
|
551 |
style_header("Check-in Information Error"); |
|
ba3323d…
|
stephan
|
552 |
@ No such object: %h(PD("name","")) |
|
112c713…
|
drh
|
553 |
style_finish_page(); |
|
e2d5372…
|
drh
|
554 |
return; |
|
e2d5372…
|
drh
|
555 |
} |
|
57f1e87…
|
drh
|
556 |
cgi_check_for_malice(); |
|
e2d5372…
|
drh
|
557 |
zHash = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
e2d5372…
|
drh
|
558 |
style_header("Tags and Properties"); |
|
7c64fe0…
|
drh
|
559 |
zType = whatis_rid_type_label(rid); |
|
41f0838…
|
stephan
|
560 |
if(!zType) zType = "Artifact"; |
|
41f0838…
|
stephan
|
561 |
@ <h1>Tags and Properties for %s(zType) \ |
|
e2d5372…
|
drh
|
562 |
@ %z(href("%R/ci/%!S",zHash))%S(zHash)</a></h1> |
|
08db9e1…
|
drh
|
563 |
db_prepare(&q, |
|
08db9e1…
|
drh
|
564 |
"SELECT tag.tagid, tagname, " |
|
08db9e1…
|
drh
|
565 |
" (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d)," |
|
ea63a2d…
|
drh
|
566 |
" value, datetime(tagxref.mtime,toLocal()), tagtype," |
|
042a08b…
|
drh
|
567 |
" (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)" |
|
08db9e1…
|
drh
|
568 |
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid" |
|
b709be6…
|
drh
|
569 |
" WHERE tagxref.rid=%d" |
|
ea63a2d…
|
drh
|
570 |
" ORDER BY tagname /*sort*/", rid, rid, rid |
|
08db9e1…
|
drh
|
571 |
); |
|
08db9e1…
|
drh
|
572 |
while( db_step(&q)==SQLITE_ROW ){ |
|
08db9e1…
|
drh
|
573 |
const char *zTagname = db_column_text(&q, 1); |
|
08db9e1…
|
drh
|
574 |
const char *zSrcUuid = db_column_text(&q, 2); |
|
08db9e1…
|
drh
|
575 |
const char *zValue = db_column_text(&q, 3); |
|
08db9e1…
|
drh
|
576 |
const char *zDate = db_column_text(&q, 4); |
|
08db9e1…
|
drh
|
577 |
int tagtype = db_column_int(&q, 5); |
|
08db9e1…
|
drh
|
578 |
const char *zOrigUuid = db_column_text(&q, 6); |
|
08db9e1…
|
drh
|
579 |
cnt++; |
|
08db9e1…
|
drh
|
580 |
if( cnt==1 ){ |
|
08db9e1…
|
drh
|
581 |
@ <ul> |
|
08db9e1…
|
drh
|
582 |
} |
|
08db9e1…
|
drh
|
583 |
@ <li> |
|
08db9e1…
|
drh
|
584 |
if( tagtype==0 ){ |
|
3243e63…
|
drh
|
585 |
@ <span class="infoTagCancelled">%h(zTagname)</span> cancelled |
|
08db9e1…
|
drh
|
586 |
}else if( zValue ){ |
|
3243e63…
|
drh
|
587 |
@ <span class="infoTag">%h(zTagname)=%h(zValue)</span> |
|
08db9e1…
|
drh
|
588 |
}else { |
|
3243e63…
|
drh
|
589 |
@ <span class="infoTag">%h(zTagname)</span> |
|
08db9e1…
|
drh
|
590 |
} |
|
08db9e1…
|
drh
|
591 |
if( tagtype==2 ){ |
|
08db9e1…
|
drh
|
592 |
if( zOrigUuid && zOrigUuid[0] ){ |
|
08db9e1…
|
drh
|
593 |
@ inherited from |
|
8ad5e46…
|
wyoung
|
594 |
hyperlink_to_version(zOrigUuid); |
|
08db9e1…
|
drh
|
595 |
}else{ |
|
08db9e1…
|
drh
|
596 |
@ propagates to descendants |
|
08db9e1…
|
drh
|
597 |
} |
|
08db9e1…
|
drh
|
598 |
} |
|
08db9e1…
|
drh
|
599 |
if( zSrcUuid && zSrcUuid[0] ){ |
|
042a08b…
|
drh
|
600 |
if( tagtype==0 ){ |
|
042a08b…
|
drh
|
601 |
@ by |
|
042a08b…
|
drh
|
602 |
}else{ |
|
042a08b…
|
drh
|
603 |
@ added by |
|
042a08b…
|
drh
|
604 |
} |
|
8ad5e46…
|
wyoung
|
605 |
hyperlink_to_version(zSrcUuid); |
|
b5f4f91…
|
drh
|
606 |
@ on |
|
b5f4f91…
|
drh
|
607 |
hyperlink_to_date(zDate,0); |
|
08db9e1…
|
drh
|
608 |
} |
|
3243e63…
|
drh
|
609 |
@ </li> |
|
08db9e1…
|
drh
|
610 |
} |
|
08db9e1…
|
drh
|
611 |
db_finalize(&q); |
|
08db9e1…
|
drh
|
612 |
if( cnt ){ |
|
08db9e1…
|
drh
|
613 |
@ </ul> |
|
08db9e1…
|
drh
|
614 |
} |
|
e2d5372…
|
drh
|
615 |
@ <div class="section">Context</div> |
|
e2d5372…
|
drh
|
616 |
db_multi_exec( |
|
e2d5372…
|
drh
|
617 |
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);" |
|
e2d5372…
|
drh
|
618 |
"DELETE FROM ok;" |
|
e2d5372…
|
drh
|
619 |
"INSERT INTO ok VALUES(%d);" |
|
e2d5372…
|
drh
|
620 |
"INSERT OR IGNORE INTO ok " |
|
e2d5372…
|
drh
|
621 |
" SELECT tagxref.srcid" |
|
e2d5372…
|
drh
|
622 |
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid" |
|
e2d5372…
|
drh
|
623 |
" WHERE tagxref.rid=%d;" |
|
e2d5372…
|
drh
|
624 |
"INSERT OR IGNORE INTO ok " |
|
e2d5372…
|
drh
|
625 |
" SELECT tagxref.origid" |
|
e2d5372…
|
drh
|
626 |
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid" |
|
e2d5372…
|
drh
|
627 |
" WHERE tagxref.rid=%d;", |
|
e2d5372…
|
drh
|
628 |
rid, rid, rid |
|
e2d5372…
|
drh
|
629 |
); |
|
e632a09…
|
drh
|
630 |
#if 0 |
|
e2d5372…
|
drh
|
631 |
db_multi_exec( |
|
e2d5372…
|
drh
|
632 |
"SELECT tag.tagid, tagname, " |
|
e2d5372…
|
drh
|
633 |
" (SELECT uuid FROM blob WHERE rid=tagxref.srcid AND rid!=%d)," |
|
e2d5372…
|
drh
|
634 |
" value, datetime(tagxref.mtime,toLocal()), tagtype," |
|
e2d5372…
|
drh
|
635 |
" (SELECT uuid FROM blob WHERE rid=tagxref.origid AND rid!=%d)" |
|
e2d5372…
|
drh
|
636 |
" FROM tagxref JOIN tag ON tagxref.tagid=tag.tagid" |
|
e2d5372…
|
drh
|
637 |
" WHERE tagxref.rid=%d" |
|
e2d5372…
|
drh
|
638 |
" ORDER BY tagname /*sort*/", rid, rid, rid |
|
e2d5372…
|
drh
|
639 |
); |
|
e632a09…
|
drh
|
640 |
#endif |
|
e2d5372…
|
drh
|
641 |
blob_zero(&sql); |
|
e2d5372…
|
drh
|
642 |
blob_append(&sql, timeline_query_for_www(), -1); |
|
e2d5372…
|
drh
|
643 |
blob_append_sql(&sql, " AND event.objid IN ok ORDER BY mtime DESC"); |
|
e2d5372…
|
drh
|
644 |
db_prepare(&q, "%s", blob_sql_text(&sql)); |
|
e454028…
|
drh
|
645 |
memset(&xtra, 0, sizeof(xtra)); |
|
e454028…
|
drh
|
646 |
xtra.selectedRid = rid; |
|
cee4bcf…
|
drh
|
647 |
www_print_timeline(&q, TIMELINE_DISJOINT|TIMELINE_GRAPH|TIMELINE_NOSCROLL, |
|
e454028…
|
drh
|
648 |
&xtra); |
|
d35d201…
|
drh
|
649 |
db_finalize(&q); |
|
d35d201…
|
drh
|
650 |
style_finish_page(); |
|
e454028…
|
drh
|
651 |
} |
|
e454028…
|
drh
|
652 |
|
|
e454028…
|
drh
|
653 |
/* |
|
94e94bc…
|
drh
|
654 |
** Generate JS code that will adjust the change counts in the title |
|
94e94bc…
|
drh
|
655 |
** of the "changes_section" panel where "changes_section" is a JS id. |
|
94e94bc…
|
drh
|
656 |
** |
|
94e94bc…
|
drh
|
657 |
** The change counts are taken from g.diffCnt[] for edits, and from |
|
94e94bc…
|
drh
|
658 |
** the aChng[] parameter for additions, deletions, and modifications. |
|
94e94bc…
|
drh
|
659 |
** The aChng parameter may be NULL, in which case those factors are |
|
94e94bc…
|
drh
|
660 |
** ignored. |
|
94e94bc…
|
drh
|
661 |
*/ |
|
94e94bc…
|
drh
|
662 |
static void adjust_changes_section_title( |
|
94e94bc…
|
drh
|
663 |
int iLine, /* Souce code line number of caller */ |
|
94e94bc…
|
drh
|
664 |
int *aChng /* Change categories */ |
|
94e94bc…
|
drh
|
665 |
){ |
|
94e94bc…
|
drh
|
666 |
sqlite3_str *pTxt = sqlite3_str_new(0); |
|
94e94bc…
|
drh
|
667 |
if( g.diffCnt[0]>0 ){ |
|
94e94bc…
|
drh
|
668 |
sqlite3_str_appendf(pTxt, "%d file%s edited [+%d -%d lines]", |
|
94e94bc…
|
drh
|
669 |
g.diffCnt[0], g.diffCnt[0]==1 ? "" : "s", |
|
94e94bc…
|
drh
|
670 |
g.diffCnt[1], g.diffCnt[2]); |
|
94e94bc…
|
drh
|
671 |
} |
|
94e94bc…
|
drh
|
672 |
if( aChng ){ |
|
94e94bc…
|
drh
|
673 |
static const int aiType[] = |
|
94e94bc…
|
drh
|
674 |
{ FCHNG_NEW, FCHNG_DELETE, FCHNG_RENAME, FCHNG_MODE }; |
|
94e94bc…
|
drh
|
675 |
static const char *azType[] = |
|
94e94bc…
|
drh
|
676 |
{ "added", "deleted", "renamed", "mode change"}; |
|
94e94bc…
|
drh
|
677 |
int i; |
|
94e94bc…
|
drh
|
678 |
for(i=0; i<4; i++){ |
|
94e94bc…
|
drh
|
679 |
int j = aiType[i]; |
|
94e94bc…
|
drh
|
680 |
if( aChng[j] ){ |
|
94e94bc…
|
drh
|
681 |
const char *zFiles = ""; |
|
94e94bc…
|
drh
|
682 |
if( sqlite3_str_length(pTxt)>0 ){ |
|
94e94bc…
|
drh
|
683 |
sqlite3_str_append(pTxt,", ", 2); |
|
94e94bc…
|
drh
|
684 |
}else{ |
|
94e94bc…
|
drh
|
685 |
zFiles = i<3 && aChng[j]>1 ? " files" : " file"; |
|
94e94bc…
|
drh
|
686 |
} |
|
94e94bc…
|
drh
|
687 |
sqlite3_str_appendf(pTxt,"%d%s %s", aChng[j], zFiles, azType[i]); |
|
94e94bc…
|
drh
|
688 |
if( i==3 && aChng[j]>1 ) sqlite3_str_appendf(pTxt, "s"); |
|
94e94bc…
|
drh
|
689 |
} |
|
94e94bc…
|
drh
|
690 |
} |
|
94e94bc…
|
drh
|
691 |
} |
|
94e94bc…
|
drh
|
692 |
if( sqlite3_str_length(pTxt)>0 ){ |
|
94e94bc…
|
drh
|
693 |
@ <script nonce='%h(style_nonce())'>;/* info.c:%d(iLine) */ |
|
94e94bc…
|
drh
|
694 |
@ document.getElementById('changes_section').textContent = \ |
|
94e94bc…
|
drh
|
695 |
@ 'Changes (%h(sqlite3_str_value(pTxt)))' |
|
94e94bc…
|
drh
|
696 |
@ </script> |
|
94e94bc…
|
drh
|
697 |
} |
|
94e94bc…
|
drh
|
698 |
sqlite3_str_free(pTxt); |
|
94e94bc…
|
drh
|
699 |
} |
|
94e94bc…
|
drh
|
700 |
|
|
94e94bc…
|
drh
|
701 |
/* |
|
3807891…
|
drh
|
702 |
** Render a web-page diff of the changes in the working check-out |
|
d35d201…
|
drh
|
703 |
*/ |
|
3807891…
|
drh
|
704 |
static void ckout_normal_diff(int vid){ |
|
d35d201…
|
drh
|
705 |
int diffType; /* 0: no diff, 1: unified, 2: side-by-side */ |
|
d35d201…
|
drh
|
706 |
DiffConfig DCfg,*pCfg; /* Diff details */ |
|
7cf712a…
|
drh
|
707 |
const char *zW; /* The "w" query parameter */ |
|
4d2d62d…
|
drh
|
708 |
int nChng; /* Number of changes */ |
|
d35d201…
|
drh
|
709 |
Stmt q; |
|
d35d201…
|
drh
|
710 |
|
|
d35d201…
|
drh
|
711 |
diffType = preferred_diff_type(); |
|
d35d201…
|
drh
|
712 |
pCfg = construct_diff_flags(diffType, &DCfg); |
|
4d2d62d…
|
drh
|
713 |
nChng = db_int(0, "SELECT count(*) FROM vfile" |
|
4d2d62d…
|
drh
|
714 |
" WHERE vid=%d AND (deleted OR chnged OR rid==0)", vid); |
|
4d2d62d…
|
drh
|
715 |
if( nChng==0 ){ |
|
4d2d62d…
|
drh
|
716 |
@ <p>No uncommitted changes</p> |
|
4d2d62d…
|
drh
|
717 |
return; |
|
4d2d62d…
|
drh
|
718 |
} |
|
d35d201…
|
drh
|
719 |
db_prepare(&q, |
|
d35d201…
|
drh
|
720 |
/* 0 1 2 3 4 5 6 */ |
|
d35d201…
|
drh
|
721 |
"SELECT pathname, deleted, chnged , rid==0, rid, islink, uuid" |
|
d35d201…
|
drh
|
722 |
" FROM vfile LEFT JOIN blob USING(rid)" |
|
d35d201…
|
drh
|
723 |
" WHERE vid=%d" |
|
d35d201…
|
drh
|
724 |
" AND (deleted OR chnged OR rid==0)" |
|
d35d201…
|
drh
|
725 |
" ORDER BY pathname /*scan*/", |
|
d35d201…
|
drh
|
726 |
vid |
|
d35d201…
|
drh
|
727 |
); |
|
7cf712a…
|
drh
|
728 |
if( DCfg.diffFlags & DIFF_SIDEBYSIDE ){ |
|
7cf712a…
|
drh
|
729 |
DCfg.diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
|
d35d201…
|
drh
|
730 |
}else{ |
|
7cf712a…
|
drh
|
731 |
DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
|
d35d201…
|
drh
|
732 |
} |
|
cb4d170…
|
danield
|
733 |
@ <div class="section" id="changes_section">Changes</div> |
|
cb4d170…
|
danield
|
734 |
DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */ |
|
a718a76…
|
stephan
|
735 |
@ <div class="sectionmenu info-changes-menu"> |
|
7cf712a…
|
drh
|
736 |
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; |
|
7cf712a…
|
drh
|
737 |
if( diffType!=1 ){ |
|
4d2d62d…
|
drh
|
738 |
@ %z(chref("button","%R?diff=1%s",zW))Unified Diff</a> |
|
7cf712a…
|
drh
|
739 |
} |
|
7cf712a…
|
drh
|
740 |
if( diffType!=2 ){ |
|
4d2d62d…
|
drh
|
741 |
@ %z(chref("button","%R?diff=2%s",zW))Side-by-Side Diff</a> |
|
7cf712a…
|
drh
|
742 |
} |
|
7cf712a…
|
drh
|
743 |
if( diffType!=0 ){ |
|
7cf712a…
|
drh
|
744 |
if( *zW ){ |
|
7cf712a…
|
drh
|
745 |
@ %z(chref("button","%R?diff=%d",diffType))\ |
|
7cf712a…
|
drh
|
746 |
@ Show Whitespace Changes</a> |
|
7cf712a…
|
drh
|
747 |
}else{ |
|
7cf712a…
|
drh
|
748 |
@ %z(chref("button","%R?diff=%d&w",diffType))Ignore Whitespace</a> |
|
7cf712a…
|
drh
|
749 |
} |
|
7cf712a…
|
drh
|
750 |
} |
|
a718a76…
|
stephan
|
751 |
@ </div> |
|
d35d201…
|
drh
|
752 |
while( db_step(&q)==SQLITE_ROW ){ |
|
d35d201…
|
drh
|
753 |
const char *zTreename = db_column_text(&q,0); |
|
d35d201…
|
drh
|
754 |
int isDeleted = db_column_int(&q, 1); |
|
d35d201…
|
drh
|
755 |
int isChnged = db_column_int(&q,2); |
|
d35d201…
|
drh
|
756 |
int isNew = db_column_int(&q,3); |
|
d35d201…
|
drh
|
757 |
int srcid = db_column_int(&q, 4); |
|
d35d201…
|
drh
|
758 |
int isLink = db_column_int(&q, 5); |
|
d35d201…
|
drh
|
759 |
const char *zUuid = db_column_text(&q, 6); |
|
d35d201…
|
drh
|
760 |
int showDiff = 1; |
|
d35d201…
|
drh
|
761 |
|
|
7cf712a…
|
drh
|
762 |
DCfg.diffFlags &= (~DIFF_FILE_MASK); |
|
a718a76…
|
stephan
|
763 |
@ <div class='file-change-line'><span> |
|
d35d201…
|
drh
|
764 |
if( isDeleted ){ |
|
a718a76…
|
stephan
|
765 |
@ DELETED %h(zTreename) |
|
7cf712a…
|
drh
|
766 |
DCfg.diffFlags |= DIFF_FILE_DELETED; |
|
d35d201…
|
drh
|
767 |
showDiff = 0; |
|
d35d201…
|
drh
|
768 |
}else if( file_access(zTreename, F_OK) ){ |
|
a718a76…
|
stephan
|
769 |
@ MISSING %h(zTreename) |
|
d35d201…
|
drh
|
770 |
showDiff = 0; |
|
d35d201…
|
drh
|
771 |
}else if( isNew ){ |
|
a718a76…
|
stephan
|
772 |
@ ADDED %h(zTreename) |
|
7cf712a…
|
drh
|
773 |
DCfg.diffFlags |= DIFF_FILE_ADDED; |
|
d35d201…
|
drh
|
774 |
srcid = 0; |
|
d35d201…
|
drh
|
775 |
showDiff = 0; |
|
d35d201…
|
drh
|
776 |
}else if( isChnged==3 ){ |
|
a718a76…
|
stephan
|
777 |
@ ADDED_BY_MERGE %h(zTreename) |
|
7cf712a…
|
drh
|
778 |
DCfg.diffFlags |= DIFF_FILE_ADDED; |
|
d35d201…
|
drh
|
779 |
srcid = 0; |
|
d35d201…
|
drh
|
780 |
showDiff = 0; |
|
d35d201…
|
drh
|
781 |
}else if( isChnged==5 ){ |
|
a718a76…
|
stephan
|
782 |
@ ADDED_BY_INTEGRATE %h(zTreename) |
|
7cf712a…
|
drh
|
783 |
DCfg.diffFlags |= DIFF_FILE_ADDED; |
|
d35d201…
|
drh
|
784 |
srcid = 0; |
|
d35d201…
|
drh
|
785 |
showDiff = 0; |
|
d35d201…
|
drh
|
786 |
}else{ |
|
a718a76…
|
stephan
|
787 |
@ CHANGED %h(zTreename) |
|
d35d201…
|
drh
|
788 |
} |
|
a718a76…
|
stephan
|
789 |
@ </span></div> |
|
7cf712a…
|
drh
|
790 |
if( showDiff && pCfg ){ |
|
d35d201…
|
drh
|
791 |
Blob old, new; |
|
d35d201…
|
drh
|
792 |
if( !isLink != !file_islink(zTreename) ){ |
|
d35d201…
|
drh
|
793 |
@ %s(DIFF_CANNOT_COMPUTE_SYMLINK) |
|
d35d201…
|
drh
|
794 |
continue; |
|
d35d201…
|
drh
|
795 |
} |
|
d35d201…
|
drh
|
796 |
if( srcid>0 ){ |
|
d35d201…
|
drh
|
797 |
content_get(srcid, &old); |
|
d35d201…
|
drh
|
798 |
pCfg->zLeftHash = zUuid; |
|
d35d201…
|
drh
|
799 |
}else{ |
|
d35d201…
|
drh
|
800 |
blob_zero(&old); |
|
d35d201…
|
drh
|
801 |
pCfg->zLeftHash = 0; |
|
d35d201…
|
drh
|
802 |
} |
|
d35d201…
|
drh
|
803 |
blob_read_from_file(&new, zTreename, ExtFILE); |
|
d35d201…
|
drh
|
804 |
text_diff(&old, &new, cgi_output_blob(), pCfg); |
|
d35d201…
|
drh
|
805 |
blob_reset(&old); |
|
d35d201…
|
drh
|
806 |
blob_reset(&new); |
|
d35d201…
|
drh
|
807 |
} |
|
d35d201…
|
drh
|
808 |
} |
|
d35d201…
|
drh
|
809 |
db_finalize(&q); |
|
94e94bc…
|
drh
|
810 |
adjust_changes_section_title(__LINE__, 0); |
|
3807891…
|
drh
|
811 |
append_diff_javascript(diffType); |
|
3807891…
|
drh
|
812 |
} |
|
3807891…
|
drh
|
813 |
|
|
3807891…
|
drh
|
814 |
/* |
|
3807891…
|
drh
|
815 |
** Render a web-page diff of the changes in the working check-out to |
|
3807891…
|
drh
|
816 |
** an external reference. |
|
3807891…
|
drh
|
817 |
*/ |
|
3807891…
|
drh
|
818 |
static void ckout_external_base_diff(int vid, const char *zExBase){ |
|
3807891…
|
drh
|
819 |
int diffType; /* 0: no diff, 1: unified, 2: side-by-side */ |
|
3807891…
|
drh
|
820 |
DiffConfig DCfg,*pCfg; /* Diff details */ |
|
3807891…
|
drh
|
821 |
const char *zW; /* The "w" query parameter */ |
|
3807891…
|
drh
|
822 |
Stmt q; |
|
3807891…
|
drh
|
823 |
|
|
3807891…
|
drh
|
824 |
diffType = preferred_diff_type(); |
|
3807891…
|
drh
|
825 |
pCfg = construct_diff_flags(diffType, &DCfg); |
|
3807891…
|
drh
|
826 |
db_prepare(&q, |
|
3807891…
|
drh
|
827 |
"SELECT pathname FROM vfile WHERE vid=%d ORDER BY pathname", vid |
|
3807891…
|
drh
|
828 |
); |
|
3807891…
|
drh
|
829 |
if( DCfg.diffFlags & DIFF_SIDEBYSIDE ){ |
|
3807891…
|
drh
|
830 |
DCfg.diffFlags |= DIFF_HTML | DIFF_NOTTOOBIG; |
|
3807891…
|
drh
|
831 |
}else{ |
|
3807891…
|
drh
|
832 |
DCfg.diffFlags |= DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG; |
|
3807891…
|
drh
|
833 |
} |
|
cb4d170…
|
danield
|
834 |
@ <div class="section" id="changes_section">Changes</div> |
|
cb4d170…
|
danield
|
835 |
DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */ |
|
3807891…
|
drh
|
836 |
@ <div class="sectionmenu info-changes-menu"> |
|
3807891…
|
drh
|
837 |
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; |
|
3807891…
|
drh
|
838 |
if( diffType!=1 ){ |
|
3807891…
|
drh
|
839 |
@ %z(chref("button","%R?diff=1&exbase=%h%s",zExBase,zW))\ |
|
3807891…
|
drh
|
840 |
@ Unified Diff</a> |
|
3807891…
|
drh
|
841 |
} |
|
3807891…
|
drh
|
842 |
if( diffType!=2 ){ |
|
3807891…
|
drh
|
843 |
@ %z(chref("button","%R?diff=2&exbase=%h%s",zExBase,zW))\ |
|
3807891…
|
drh
|
844 |
@ Side-by-Side Diff</a> |
|
3807891…
|
drh
|
845 |
} |
|
3807891…
|
drh
|
846 |
if( diffType!=0 ){ |
|
3807891…
|
drh
|
847 |
if( *zW ){ |
|
3807891…
|
drh
|
848 |
@ %z(chref("button","%R?diff=%d&exbase=%h",diffType,zExBase))\ |
|
3807891…
|
drh
|
849 |
@ Show Whitespace Changes</a> |
|
3807891…
|
drh
|
850 |
}else{ |
|
3807891…
|
drh
|
851 |
@ %z(chref("button","%R?diff=%d&exbase=%h&w",diffType,zExBase))\ |
|
3807891…
|
drh
|
852 |
@ Ignore Whitespace</a> |
|
3807891…
|
drh
|
853 |
} |
|
3807891…
|
drh
|
854 |
} |
|
3807891…
|
drh
|
855 |
@ </div> |
|
3807891…
|
drh
|
856 |
while( db_step(&q)==SQLITE_ROW ){ |
|
3807891…
|
drh
|
857 |
const char *zFile; /* Name of file in the repository */ |
|
3807891…
|
drh
|
858 |
char *zLhs; /* Full name of left-hand side file */ |
|
3807891…
|
drh
|
859 |
char *zRhs; /* Full name of right-hand side file */ |
|
3807891…
|
drh
|
860 |
Blob rhs; /* Full text of RHS */ |
|
3807891…
|
drh
|
861 |
Blob lhs; /* Full text of LHS */ |
|
3807891…
|
drh
|
862 |
|
|
3807891…
|
drh
|
863 |
zFile = db_column_text(&q,0); |
|
3807891…
|
drh
|
864 |
zLhs = mprintf("%s/%s", zExBase, zFile); |
|
3807891…
|
drh
|
865 |
zRhs = mprintf("%s%s", g.zLocalRoot, zFile); |
|
3807891…
|
drh
|
866 |
if( file_size(zLhs, ExtFILE)<0 ){ |
|
3807891…
|
drh
|
867 |
@ <div class='file-change-line'><span> |
|
3807891…
|
drh
|
868 |
@ Missing from external baseline: %h(zFile) |
|
3807891…
|
drh
|
869 |
@ </span></div> |
|
3807891…
|
drh
|
870 |
}else{ |
|
3807891…
|
drh
|
871 |
blob_read_from_file(&lhs, zLhs, ExtFILE); |
|
3807891…
|
drh
|
872 |
blob_read_from_file(&rhs, zRhs, ExtFILE); |
|
3807891…
|
drh
|
873 |
if( blob_size(&lhs)!=blob_size(&rhs) |
|
3807891…
|
drh
|
874 |
|| memcmp(blob_buffer(&lhs), blob_buffer(&rhs), blob_size(&lhs))!=0 |
|
3807891…
|
drh
|
875 |
){ |
|
3807891…
|
drh
|
876 |
@ <div class='file-change-line'><span> |
|
3807891…
|
drh
|
877 |
@ Changes to %h(zFile) |
|
3807891…
|
drh
|
878 |
@ </span></div> |
|
3807891…
|
drh
|
879 |
if( pCfg ){ |
|
3807891…
|
drh
|
880 |
char *zFullFN; |
|
3807891…
|
drh
|
881 |
char *zHexFN; |
|
3807891…
|
drh
|
882 |
zFullFN = file_canonical_name_dup(zLhs); |
|
593ceca…
|
drh
|
883 |
zHexFN = mprintf("x%H", zFullFN); |
|
3807891…
|
drh
|
884 |
fossil_free(zFullFN); |
|
3807891…
|
drh
|
885 |
pCfg->zLeftHash = zHexFN; |
|
3807891…
|
drh
|
886 |
text_diff(&lhs, &rhs, cgi_output_blob(), pCfg); |
|
3807891…
|
drh
|
887 |
pCfg->zLeftHash = 0; |
|
3807891…
|
drh
|
888 |
fossil_free(zHexFN); |
|
3807891…
|
drh
|
889 |
} |
|
3807891…
|
drh
|
890 |
} |
|
3807891…
|
drh
|
891 |
blob_reset(&lhs); |
|
3807891…
|
drh
|
892 |
blob_reset(&rhs); |
|
3807891…
|
drh
|
893 |
} |
|
3807891…
|
drh
|
894 |
fossil_free(zLhs); |
|
3807891…
|
drh
|
895 |
fossil_free(zRhs); |
|
3807891…
|
drh
|
896 |
} |
|
3807891…
|
drh
|
897 |
db_finalize(&q); |
|
94e94bc…
|
drh
|
898 |
adjust_changes_section_title(__LINE__, 0); |
|
d35d201…
|
drh
|
899 |
append_diff_javascript(diffType); |
|
3807891…
|
drh
|
900 |
} |
|
3807891…
|
drh
|
901 |
|
|
3807891…
|
drh
|
902 |
/* |
|
3807891…
|
drh
|
903 |
** WEBPAGE: ckout |
|
3807891…
|
drh
|
904 |
** |
|
3807891…
|
drh
|
905 |
** Show information about the current checkout. This page only functions |
|
3807891…
|
drh
|
906 |
** if the web server is run on a loopback interface (in other words, was |
|
7f1958a…
|
drh
|
907 |
** started using "fossil ui" or similar) from within an open check-out. |
|
7f1958a…
|
drh
|
908 |
** |
|
7f1958a…
|
drh
|
909 |
** If the "exbase=PATH" query parameter is provided, then the diff shown |
|
7f1958a…
|
drh
|
910 |
** uses the files in PATH as the baseline. This is the same as using |
|
7f1958a…
|
drh
|
911 |
** the "--from PATH" argument to the "fossil diff" command-line. In fact, |
|
7f1958a…
|
drh
|
912 |
** when using "fossil ui --from PATH", the --from argument becomes the value |
|
593ceca…
|
drh
|
913 |
** of the exbase query parameter for the start page. Note that if PATH |
|
593ceca…
|
drh
|
914 |
** is a pure hexadecimal string, it is decoded first before being used as |
|
593ceca…
|
drh
|
915 |
** the pathname. Real pathnames should contain at least one directory |
|
593ceca…
|
drh
|
916 |
** separator character. |
|
7f1958a…
|
drh
|
917 |
** |
|
7f1958a…
|
drh
|
918 |
** Other query parameters related to diffs are also accepted. |
|
3807891…
|
drh
|
919 |
*/ |
|
3807891…
|
drh
|
920 |
void ckout_page(void){ |
|
3807891…
|
drh
|
921 |
int vid; |
|
3807891…
|
drh
|
922 |
const char *zHome; /* Home directory */ |
|
3807891…
|
drh
|
923 |
int nHome; |
|
3807891…
|
drh
|
924 |
const char *zExBase; |
|
3807891…
|
drh
|
925 |
char *zHostname; |
|
3807891…
|
drh
|
926 |
char *zCwd; |
|
3807891…
|
drh
|
927 |
|
|
2dda151…
|
florian
|
928 |
if( !cgi_is_loopback(g.zIpAddr) || !db_open_local(0) ){ |
|
3807891…
|
drh
|
929 |
cgi_redirectf("%R/home"); |
|
3807891…
|
drh
|
930 |
return; |
|
3807891…
|
drh
|
931 |
} |
|
3807891…
|
drh
|
932 |
file_chdir(g.zLocalRoot, 0); |
|
3807891…
|
drh
|
933 |
vid = db_lget_int("checkout", 0); |
|
3807891…
|
drh
|
934 |
db_unprotect(PROTECT_ALL); |
|
3807891…
|
drh
|
935 |
vfile_check_signature(vid, CKSIG_ENOTFILE); |
|
3807891…
|
drh
|
936 |
db_protect_pop(); |
|
3807891…
|
drh
|
937 |
style_set_current_feature("vinfo"); |
|
3807891…
|
drh
|
938 |
zHostname = fossil_hostname(); |
|
3807891…
|
drh
|
939 |
zCwd = file_getcwd(0,0); |
|
3807891…
|
drh
|
940 |
zHome = fossil_getenv("HOME"); |
|
3807891…
|
drh
|
941 |
if( zHome ){ |
|
3807891…
|
drh
|
942 |
nHome = (int)strlen(zHome); |
|
3807891…
|
drh
|
943 |
if( strncmp(zCwd, zHome, nHome)==0 && zCwd[nHome]=='/' ){ |
|
3807891…
|
drh
|
944 |
zCwd = mprintf("~%s", zCwd+nHome); |
|
3807891…
|
drh
|
945 |
} |
|
3807891…
|
drh
|
946 |
}else{ |
|
3807891…
|
drh
|
947 |
nHome = 0; |
|
3807891…
|
drh
|
948 |
} |
|
3807891…
|
drh
|
949 |
if( zHostname ){ |
|
3807891…
|
drh
|
950 |
style_header("Checkout Status: %h on %h", zCwd, zHostname); |
|
3807891…
|
drh
|
951 |
}else{ |
|
3807891…
|
drh
|
952 |
style_header("Checkout Status: %h", zCwd); |
|
3807891…
|
drh
|
953 |
} |
|
e454028…
|
drh
|
954 |
render_checkin_context(vid, 0, 2, 0); |
|
3807891…
|
drh
|
955 |
@ <hr> |
|
3807891…
|
drh
|
956 |
zExBase = P("exbase"); |
|
3807891…
|
drh
|
957 |
if( zExBase && zExBase[0] ){ |
|
593ceca…
|
drh
|
958 |
char *zPath = decode16_dup(zExBase); |
|
593ceca…
|
drh
|
959 |
char *zCBase = file_canonical_name_dup(zPath?zPath:zExBase); |
|
3807891…
|
drh
|
960 |
if( nHome && strncmp(zCBase, zHome, nHome)==0 && zCBase[nHome]=='/' ){ |
|
3807891…
|
drh
|
961 |
@ <p>Using external baseline: ~%h(zCBase+nHome)</p> |
|
3807891…
|
drh
|
962 |
}else{ |
|
3807891…
|
drh
|
963 |
@ <p>Using external baseline: %h(zCBase)</p> |
|
3807891…
|
drh
|
964 |
} |
|
3807891…
|
drh
|
965 |
ckout_external_base_diff(vid, zCBase); |
|
3807891…
|
drh
|
966 |
fossil_free(zCBase); |
|
593ceca…
|
drh
|
967 |
fossil_free(zPath); |
|
3807891…
|
drh
|
968 |
}else{ |
|
3807891…
|
drh
|
969 |
ckout_normal_diff(vid); |
|
3807891…
|
drh
|
970 |
} |
|
112c713…
|
drh
|
971 |
style_finish_page(); |
|
e2d5372…
|
drh
|
972 |
} |
|
3807891…
|
drh
|
973 |
|
|
3807891…
|
drh
|
974 |
/* |
|
face931…
|
drh
|
975 |
** SETTING: path-to-tag width=40 |
|
face931…
|
drh
|
976 |
** |
|
face931…
|
drh
|
977 |
** If the path-to-tag setting is defined and is not an empty string |
|
ae4bbd8…
|
drh
|
978 |
** then the /info page for checkin HASH will display a link to |
|
ae4bbd8…
|
drh
|
979 |
** a timeline showing an abbreviated path from the HASH checkin to |
|
face931…
|
drh
|
980 |
** the next checkin that has a tag which is the value of this setting. |
|
face931…
|
drh
|
981 |
** |
|
ae4bbd8…
|
drh
|
982 |
** A typical value for this setting is "release", in which case a |
|
ae4bbd8…
|
drh
|
983 |
** "path-to-release" link is shown on /info pages of checkins. |
|
face931…
|
drh
|
984 |
*/ |
|
face931…
|
drh
|
985 |
|
|
face931…
|
drh
|
986 |
/* |
|
e2d5372…
|
drh
|
987 |
** WEBPAGE: vinfo |
|
e2d5372…
|
drh
|
988 |
** WEBPAGE: ci |
|
5b39367…
|
drh
|
989 |
** |
|
5b39367…
|
drh
|
990 |
** Display information about a single check-in identified by |
|
5b39367…
|
drh
|
991 |
** the "name" query parameter. |
|
5b39367…
|
drh
|
992 |
** |
|
5b39367…
|
drh
|
993 |
** The exact same information is shown on the /info page if the name query |
|
5b39367…
|
drh
|
994 |
** parameter to /info describes a check-in. The /info page is preferred. |
|
5b39367…
|
drh
|
995 |
** The /ci and /vinfo pages are retained for historical compatibility. |
|
5b39367…
|
drh
|
996 |
** |
|
5b39367…
|
drh
|
997 |
** The value of the "name" query parameter can be a unique prefix for |
|
5b39367…
|
drh
|
998 |
** the HASH of the check-in, or a tag or branch name that identifies |
|
5b39367…
|
drh
|
999 |
** the check-in. |
|
08db9e1…
|
drh
|
1000 |
*/ |
|
9be1b00…
|
drh
|
1001 |
void ci_page(void){ |
|
cca1ada…
|
drh
|
1002 |
Stmt q1, q2, q3; |
|
08db9e1…
|
drh
|
1003 |
int rid; |
|
08db9e1…
|
drh
|
1004 |
int isLeaf; |
|
0a1f4ed…
|
drh
|
1005 |
int diffType; /* 0: no diff, 1: unified, 2: side-by-side */ |
|
c49030f…
|
drh
|
1006 |
const char *zName; /* Name of the check-in to be displayed */ |
|
8ad5e46…
|
wyoung
|
1007 |
const char *zUuid; /* Hash of zName, found via blob.uuid */ |
|
8ad5e46…
|
wyoung
|
1008 |
const char *zParent; /* Hash of the parent check-in (if any) */ |
|
31dd2c0…
|
drh
|
1009 |
const char *zRe; /* regex parameter */ |
|
31dd2c0…
|
drh
|
1010 |
ReCompiled *pRe = 0; /* regex */ |
|
1347a1d…
|
drh
|
1011 |
const char *zW; /* URL param for ignoring whitespace */ |
|
1c9e023…
|
jan.nijtmans
|
1012 |
const char *zPage = "vinfo"; /* Page that shows diffs */ |
|
1347a1d…
|
drh
|
1013 |
const char *zBrName; /* Branch name */ |
|
1347a1d…
|
drh
|
1014 |
DiffConfig DCfg,*pCfg; /* Type of diff */ |
|
94e94bc…
|
drh
|
1015 |
int aChng[N_FCHNG]; /* Counts of change types */ |
|
08db9e1…
|
drh
|
1016 |
|
|
94e94bc…
|
drh
|
1017 |
memset(aChng, 0, sizeof(aChng)); |
|
08db9e1…
|
drh
|
1018 |
login_check_credentials(); |
|
653dd40…
|
drh
|
1019 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
112c713…
|
drh
|
1020 |
style_set_current_feature("vinfo"); |
|
96722b6…
|
drh
|
1021 |
zName = P("name"); |
|
96722b6…
|
drh
|
1022 |
rid = name_to_rid_www("name"); |
|
08db9e1…
|
drh
|
1023 |
if( rid==0 ){ |
|
08db9e1…
|
drh
|
1024 |
style_header("Check-in Information Error"); |
|
ba3323d…
|
stephan
|
1025 |
@ No such object: %h(zName) |
|
112c713…
|
drh
|
1026 |
style_finish_page(); |
|
08db9e1…
|
drh
|
1027 |
return; |
|
08db9e1…
|
drh
|
1028 |
} |
|
31dd2c0…
|
drh
|
1029 |
zRe = P("regex"); |
|
82888a0…
|
drh
|
1030 |
if( zRe ) fossil_re_compile(&pRe, zRe, 0); |
|
4bdf71b…
|
drh
|
1031 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
4bdf71b…
|
drh
|
1032 |
zParent = db_text(0, |
|
4bdf71b…
|
drh
|
1033 |
"SELECT uuid FROM plink, blob" |
|
4bdf71b…
|
drh
|
1034 |
" WHERE plink.cid=%d AND blob.rid=plink.pid AND plink.isprim", |
|
4bdf71b…
|
drh
|
1035 |
rid |
|
4bdf71b…
|
drh
|
1036 |
); |
|
6fe8d46…
|
drh
|
1037 |
isLeaf = !db_exists("SELECT 1 FROM plink WHERE pid=%d", rid); |
|
cca1ada…
|
drh
|
1038 |
db_prepare(&q1, |
|
68b2737…
|
drh
|
1039 |
"SELECT uuid," /* 0 */ |
|
68b2737…
|
drh
|
1040 |
" datetime(mtime,toLocal(),'subsec')," /* 1 */ |
|
68b2737…
|
drh
|
1041 |
" user," /* 2 */ |
|
68b2737…
|
drh
|
1042 |
" comment," /* 3 */ |
|
68b2737…
|
drh
|
1043 |
" datetime(omtime,toLocal(),'subsec')," /* 4 */ |
|
68b2737…
|
drh
|
1044 |
" mtime," /* 5 */ |
|
68b2737…
|
drh
|
1045 |
" strftime('%%Y-%%m-%%dT%%H:%%M:%%fZ',mtime)" /* 6 */ |
|
08db9e1…
|
drh
|
1046 |
" FROM blob, event" |
|
08db9e1…
|
drh
|
1047 |
" WHERE blob.rid=%d" |
|
08db9e1…
|
drh
|
1048 |
" AND event.objid=%d", |
|
ea63a2d…
|
drh
|
1049 |
rid, rid |
|
08db9e1…
|
drh
|
1050 |
); |
|
e632a09…
|
drh
|
1051 |
zBrName = branch_of_rid(rid); |
|
534c10f…
|
stephan
|
1052 |
|
|
29bab27…
|
drh
|
1053 |
diffType = preferred_diff_type(); |
|
57f1e87…
|
drh
|
1054 |
cgi_check_for_malice(); |
|
cca1ada…
|
drh
|
1055 |
if( db_step(&q1)==SQLITE_ROW ){ |
|
cca1ada…
|
drh
|
1056 |
const char *zUuid = db_column_text(&q1, 0); |
|
26dac28…
|
drh
|
1057 |
int nUuid = db_column_bytes(&q1, 0); |
|
08db9e1…
|
drh
|
1058 |
char *zEUser, *zEComment; |
|
08db9e1…
|
drh
|
1059 |
const char *zUser; |
|
4290984…
|
drh
|
1060 |
const char *zOrigUser; |
|
08db9e1…
|
drh
|
1061 |
const char *zComment; |
|
68b2737…
|
drh
|
1062 |
const char *zDate, *zZulu; |
|
576f6db…
|
drh
|
1063 |
const char *zOrigDate; |
|
5602385…
|
drh
|
1064 |
int okWiki = 0; |
|
867fe0e…
|
drh
|
1065 |
Blob wiki_read_links = BLOB_INITIALIZER; |
|
867fe0e…
|
drh
|
1066 |
Blob wiki_add_links = BLOB_INITIALIZER; |
|
01050d6…
|
jan.nijtmans
|
1067 |
|
|
2116238…
|
drh
|
1068 |
Th_StoreUnsafe("current_checkin", zName); |
|
c1d20c3…
|
mistachkin
|
1069 |
style_header("Check-in [%S]", zUuid); |
|
08db9e1…
|
drh
|
1070 |
login_anonymous_available(); |
|
08db9e1…
|
drh
|
1071 |
zEUser = db_text(0, |
|
40bea3f…
|
andybradford
|
1072 |
"SELECT value FROM tagxref" |
|
40bea3f…
|
andybradford
|
1073 |
" WHERE tagid=%d AND rid=%d AND tagtype>0", |
|
08db9e1…
|
drh
|
1074 |
TAG_USER, rid); |
|
01050d6…
|
jan.nijtmans
|
1075 |
zEComment = db_text(0, |
|
08db9e1…
|
drh
|
1076 |
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d", |
|
08db9e1…
|
drh
|
1077 |
TAG_COMMENT, rid); |
|
4290984…
|
drh
|
1078 |
zOrigUser = db_column_text(&q1, 2); |
|
4290984…
|
drh
|
1079 |
zUser = zEUser ? zEUser : zOrigUser; |
|
cca1ada…
|
drh
|
1080 |
zComment = db_column_text(&q1, 3); |
|
cca1ada…
|
drh
|
1081 |
zDate = db_column_text(&q1,1); |
|
cca1ada…
|
drh
|
1082 |
zOrigDate = db_column_text(&q1, 4); |
|
4290984…
|
drh
|
1083 |
if( zOrigDate==0 ) zOrigDate = zDate; |
|
68b2737…
|
drh
|
1084 |
zZulu = db_column_text(&q1, 6); |
|
4588959…
|
drh
|
1085 |
@ <details open> |
|
4588959…
|
drh
|
1086 |
@ <summary class="section">Overview</summary> |
|
ab55339…
|
drh
|
1087 |
@ <div class="accordion_panel"> |
|
3243e63…
|
drh
|
1088 |
@ <table class="label-value"> |
|
f5bcc25…
|
drh
|
1089 |
@ <tr><th>Comment:</th><td class="infoComment">\ |
|
f5bcc25…
|
drh
|
1090 |
@ %!W(zEComment?zEComment:zComment)</td></tr> |
|
4290984…
|
drh
|
1091 |
|
|
4290984…
|
drh
|
1092 |
/* The Download: line */ |
|
4290984…
|
drh
|
1093 |
if( g.perm.Zip ){ |
|
4290984…
|
drh
|
1094 |
@ <tr><th>Downloads:</th><td> |
|
6ce705b…
|
drh
|
1095 |
if( robot_would_be_restricted("download") ){ |
|
6ce705b…
|
drh
|
1096 |
@ See separate %z(href("%R/rchvdwnld/%!S",zUuid))download page</a> |
|
6ce705b…
|
drh
|
1097 |
}else{ |
|
6ce705b…
|
drh
|
1098 |
char *zBase = archive_base_name(rid); |
|
6ce705b…
|
drh
|
1099 |
@ %z(href("%R/tarball/%s.tar.gz",zBase))Tarball</a> |
|
6ce705b…
|
drh
|
1100 |
@ | %z(href("%R/zip/%s.zip",zBase))ZIP archive</a> |
|
6ce705b…
|
drh
|
1101 |
if( g.zLogin!=0 ){ |
|
6ce705b…
|
drh
|
1102 |
@ | %z(href("%R/sqlar/%s.sqlar",zBase))\ |
|
6ce705b…
|
drh
|
1103 |
@ SQL archive</a></td></tr> |
|
6ce705b…
|
drh
|
1104 |
} |
|
6ce705b…
|
drh
|
1105 |
fossil_free(zBase); |
|
6ce705b…
|
drh
|
1106 |
} |
|
4290984…
|
drh
|
1107 |
} |
|
4290984…
|
drh
|
1108 |
|
|
4290984…
|
drh
|
1109 |
@ <tr><th>Timelines:</th><td> |
|
4290984…
|
drh
|
1110 |
@ %z(href("%R/timeline?f=%!S&unhide",zUuid))family</a> |
|
4290984…
|
drh
|
1111 |
if( zParent ){ |
|
4290984…
|
drh
|
1112 |
@ | %z(href("%R/timeline?p=%!S&unhide",zUuid))ancestors</a> |
|
4290984…
|
drh
|
1113 |
} |
|
4290984…
|
drh
|
1114 |
if( !isLeaf ){ |
|
face931…
|
drh
|
1115 |
char *zPathTo = db_get("path-to-tag",0); |
|
4290984…
|
drh
|
1116 |
@ | %z(href("%R/timeline?d=%!S&unhide",zUuid))descendants</a> |
|
face931…
|
drh
|
1117 |
if( zPathTo!=0 && zPathTo[0]!=0 ){ |
|
face931…
|
drh
|
1118 |
@ | %z(href("%R/timeline?from=%!S&ft=%t&min",zUuid,zPathTo))\ |
|
face931…
|
drh
|
1119 |
@ path-to-%h(zPathTo)</a> |
|
face931…
|
drh
|
1120 |
} |
|
4290984…
|
drh
|
1121 |
} |
|
4290984…
|
drh
|
1122 |
if( zParent && !isLeaf ){ |
|
4290984…
|
drh
|
1123 |
@ | %z(href("%R/timeline?dp=%!S&unhide",zUuid))both</a> |
|
4290984…
|
drh
|
1124 |
} |
|
4290984…
|
drh
|
1125 |
db_prepare(&q2,"SELECT substr(tag.tagname,5) FROM tagxref, tag " |
|
4290984…
|
drh
|
1126 |
" WHERE rid=%d AND tagtype>0 " |
|
4290984…
|
drh
|
1127 |
" AND tag.tagid=tagxref.tagid " |
|
4290984…
|
drh
|
1128 |
" AND +tag.tagname GLOB 'sym-*'", rid); |
|
4290984…
|
drh
|
1129 |
while( db_step(&q2)==SQLITE_ROW ){ |
|
4290984…
|
drh
|
1130 |
const char *zTagName = db_column_text(&q2, 0); |
|
5602385…
|
drh
|
1131 |
if( fossil_strcmp(zTagName,zBrName)==0 ){ |
|
759fbda…
|
drh
|
1132 |
cgi_printf(" | "); |
|
68b2737…
|
drh
|
1133 |
style_copy_button(1, "name-br", 0, 0, 0, "%z%h</a>", |
|
759fbda…
|
drh
|
1134 |
href("%R/timeline?r=%T&unhide",zTagName), zTagName); |
|
759fbda…
|
drh
|
1135 |
cgi_printf("\n"); |
|
867fe0e…
|
drh
|
1136 |
if( wiki_tagid2("branch",zTagName)!=0 ){ |
|
867fe0e…
|
drh
|
1137 |
blob_appendf(&wiki_read_links, " | %z%h</a>", |
|
8251067…
|
stephan
|
1138 |
href("%R/%s?name=branch/%h", |
|
8251067…
|
stephan
|
1139 |
(g.perm.Write && g.perm.WrWiki) |
|
8251067…
|
stephan
|
1140 |
? "wikiedit" : "wiki", |
|
8251067…
|
stephan
|
1141 |
zTagName), zTagName); |
|
867fe0e…
|
drh
|
1142 |
}else if( g.perm.Write && g.perm.WrWiki ){ |
|
867fe0e…
|
drh
|
1143 |
blob_appendf(&wiki_add_links, " | %z%h</a>", |
|
867fe0e…
|
drh
|
1144 |
href("%R/wikiedit?name=branch/%h",zTagName), zTagName); |
|
5602385…
|
drh
|
1145 |
} |
|
5602385…
|
drh
|
1146 |
}else{ |
|
5602385…
|
drh
|
1147 |
@ | %z(href("%R/timeline?t=%T&unhide",zTagName))%h(zTagName)</a> |
|
867fe0e…
|
drh
|
1148 |
if( wiki_tagid2("tag",zTagName)!=0 ){ |
|
867fe0e…
|
drh
|
1149 |
blob_appendf(&wiki_read_links, " | %z%h</a>", |
|
5602385…
|
drh
|
1150 |
href("%R/wiki?name=tag/%h",zTagName), zTagName); |
|
867fe0e…
|
drh
|
1151 |
}else if( g.perm.Write && g.perm.WrWiki ){ |
|
867fe0e…
|
drh
|
1152 |
blob_appendf(&wiki_add_links, " | %z%h</a>", |
|
867fe0e…
|
drh
|
1153 |
href("%R/wikiedit?name=tag/%h",zTagName), zTagName); |
|
5602385…
|
drh
|
1154 |
} |
|
5602385…
|
drh
|
1155 |
} |
|
4290984…
|
drh
|
1156 |
} |
|
4290984…
|
drh
|
1157 |
db_finalize(&q2); |
|
4290984…
|
drh
|
1158 |
@ </td></tr> |
|
4290984…
|
drh
|
1159 |
|
|
4290984…
|
drh
|
1160 |
@ <tr><th>Files:</th> |
|
4290984…
|
drh
|
1161 |
@ <td> |
|
4290984…
|
drh
|
1162 |
@ %z(href("%R/tree?ci=%!S",zUuid))files</a> |
|
4290984…
|
drh
|
1163 |
@ | %z(href("%R/fileage?name=%!S",zUuid))file ages</a> |
|
4290984…
|
drh
|
1164 |
@ | %z(href("%R/tree?nofiles&type=tree&ci=%!S",zUuid))folders</a> |
|
4290984…
|
drh
|
1165 |
@ </td> |
|
4290984…
|
drh
|
1166 |
@ </tr> |
|
4290984…
|
drh
|
1167 |
|
|
6908832…
|
drh
|
1168 |
@ <tr><th>%s(hname_alg(nUuid)):</th><td> |
|
68b2737…
|
drh
|
1169 |
style_copy_button(1, "hash-ci", 0, 2, 0, "%.32s<wbr>%s", zUuid, zUuid+32); |
|
b344d3c…
|
drh
|
1170 |
if( g.perm.Setup ){ |
|
759fbda…
|
drh
|
1171 |
@ (Record ID: %d(rid)) |
|
b344d3c…
|
drh
|
1172 |
} |
|
4290984…
|
drh
|
1173 |
@ </td></tr> |
|
4290984…
|
drh
|
1174 |
@ <tr><th>User & Date:</th><td> |
|
4290984…
|
drh
|
1175 |
hyperlink_to_user(zUser,zDate," on "); |
|
68b2737…
|
drh
|
1176 |
style_copy_button(1, 0, 0, 0, zZulu, |
|
e399337…
|
drh
|
1177 |
"%z%h</a>", href("%R/timeline?c=%T",zDate), zDate); |
|
e399337…
|
drh
|
1178 |
@ </td></tr> |
|
e399337…
|
drh
|
1179 |
// hyperlink_to_date(zDate, "</td></tr>"); |
|
4f95ea8…
|
drh
|
1180 |
if( zEComment ){ |
|
d94362b…
|
drh
|
1181 |
@ <tr><th>Original Comment:</th> |
|
d94362b…
|
drh
|
1182 |
@ <td class="infoComment">%!W(zComment)</td></tr> |
|
4290984…
|
drh
|
1183 |
} |
|
4290984…
|
drh
|
1184 |
if( fossil_strcmp(zDate, zOrigDate)!=0 |
|
4290984…
|
drh
|
1185 |
|| fossil_strcmp(zOrigUser, zUser)!=0 |
|
4290984…
|
drh
|
1186 |
){ |
|
4290984…
|
drh
|
1187 |
@ <tr><th>Original User & Date:</th><td> |
|
4290984…
|
drh
|
1188 |
hyperlink_to_user(zOrigUser,zOrigDate," on "); |
|
4290984…
|
drh
|
1189 |
hyperlink_to_date(zOrigDate, "</td></tr>"); |
|
576f6db…
|
drh
|
1190 |
} |
|
b344d3c…
|
drh
|
1191 |
if( g.perm.Admin ){ |
|
cca1ada…
|
drh
|
1192 |
db_prepare(&q2, |
|
a92d5a5…
|
drh
|
1193 |
"SELECT rcvfrom.ipaddr, user.login, datetime(rcvfrom.mtime)," |
|
a92d5a5…
|
drh
|
1194 |
" blob.rcvid" |
|
766bec0…
|
drh
|
1195 |
" FROM blob JOIN rcvfrom USING(rcvid) LEFT JOIN user USING(uid)" |
|
766bec0…
|
drh
|
1196 |
" WHERE blob.rid=%d", |
|
766bec0…
|
drh
|
1197 |
rid |
|
766bec0…
|
drh
|
1198 |
); |
|
cca1ada…
|
drh
|
1199 |
if( db_step(&q2)==SQLITE_ROW ){ |
|
cca1ada…
|
drh
|
1200 |
const char *zIpAddr = db_column_text(&q2, 0); |
|
cca1ada…
|
drh
|
1201 |
const char *zUser = db_column_text(&q2, 1); |
|
cca1ada…
|
drh
|
1202 |
const char *zDate = db_column_text(&q2, 2); |
|
a92d5a5…
|
drh
|
1203 |
int rcvid = db_column_int(&q2,3); |
|
4290984…
|
drh
|
1204 |
if( zUser==0 || zUser[0]==0 ) zUser = "unknown"; |
|
4290984…
|
drh
|
1205 |
@ <tr><th>Received From:</th> |
|
a92d5a5…
|
drh
|
1206 |
@ <td>%h(zUser) @ %h(zIpAddr) on %s(zDate) \ |
|
a92d5a5…
|
drh
|
1207 |
@ (<a href="%R/rcvfrom?rcvid=%d(rcvid)">Rcvid %d(rcvid)</a>)</td></tr> |
|
4290984…
|
drh
|
1208 |
} |
|
4290984…
|
drh
|
1209 |
db_finalize(&q2); |
|
4290984…
|
drh
|
1210 |
} |
|
5602385…
|
drh
|
1211 |
|
|
c40863a…
|
drh
|
1212 |
/* Only show links to edit wiki pages if the users can read wiki |
|
867fe0e…
|
drh
|
1213 |
** and if the wiki pages already exist */ |
|
c40863a…
|
drh
|
1214 |
if( g.perm.WrWiki |
|
c40863a…
|
drh
|
1215 |
&& g.perm.RdWiki |
|
c40863a…
|
drh
|
1216 |
&& g.perm.Write |
|
867fe0e…
|
drh
|
1217 |
&& ((okWiki = wiki_tagid2("checkin",zUuid))!=0 || |
|
867fe0e…
|
drh
|
1218 |
blob_size(&wiki_read_links)>0) |
|
867fe0e…
|
drh
|
1219 |
&& db_get_boolean("wiki-about",1) |
|
867fe0e…
|
drh
|
1220 |
){ |
|
867fe0e…
|
drh
|
1221 |
const char *zLinks = blob_str(&wiki_read_links); |
|
c40863a…
|
drh
|
1222 |
@ <tr><th>Edit Wiki:</th><td>\ |
|
867fe0e…
|
drh
|
1223 |
if( okWiki ){ |
|
bc36fdc…
|
danield
|
1224 |
@ %z(href("%R/wikiedit?name=checkin/%s",zUuid))this check-in</a>\ |
|
867fe0e…
|
drh
|
1225 |
}else if( zLinks[0] ){ |
|
867fe0e…
|
drh
|
1226 |
zLinks += 3; |
|
867fe0e…
|
drh
|
1227 |
} |
|
867fe0e…
|
drh
|
1228 |
@ %s(zLinks)</td></tr> |
|
867fe0e…
|
drh
|
1229 |
} |
|
867fe0e…
|
drh
|
1230 |
|
|
867fe0e…
|
drh
|
1231 |
/* Only show links to create new wiki pages if the users can write wiki |
|
867fe0e…
|
drh
|
1232 |
** and if the wiki pages do not already exist */ |
|
867fe0e…
|
drh
|
1233 |
if( g.perm.WrWiki |
|
867fe0e…
|
drh
|
1234 |
&& g.perm.RdWiki |
|
867fe0e…
|
drh
|
1235 |
&& g.perm.Write |
|
867fe0e…
|
drh
|
1236 |
&& (blob_size(&wiki_add_links)>0 || !okWiki) |
|
5602385…
|
drh
|
1237 |
&& db_get_boolean("wiki-about",1) |
|
5602385…
|
drh
|
1238 |
){ |
|
867fe0e…
|
drh
|
1239 |
const char *zLinks = blob_str(&wiki_add_links); |
|
867fe0e…
|
drh
|
1240 |
@ <tr><th>Add Wiki:</th><td>\ |
|
867fe0e…
|
drh
|
1241 |
if( !okWiki ){ |
|
bc36fdc…
|
danield
|
1242 |
@ %z(href("%R/wikiedit?name=checkin/%s",zUuid))this check-in</a>\ |
|
867fe0e…
|
drh
|
1243 |
}else if( zLinks[0] ){ |
|
867fe0e…
|
drh
|
1244 |
zLinks += 3; |
|
5602385…
|
drh
|
1245 |
} |
|
5602385…
|
drh
|
1246 |
@ %s(zLinks)</td></tr> |
|
5602385…
|
drh
|
1247 |
} |
|
5602385…
|
drh
|
1248 |
|
|
4290984…
|
drh
|
1249 |
if( g.perm.Hyperlink ){ |
|
ca0d66b…
|
danield
|
1250 |
const char *zMainBranch = db_main_branch(); |
|
4290984…
|
drh
|
1251 |
@ <tr><th>Other Links:</th> |
|
4290984…
|
drh
|
1252 |
@ <td> |
|
3a6dd83…
|
drh
|
1253 |
if( fossil_strcmp(zBrName, zMainBranch)!=0 ){ |
|
e632a09…
|
drh
|
1254 |
@ %z(href("%R/vdiff?branch=%!S", zUuid))branch diff</a> | |
|
e632a09…
|
drh
|
1255 |
} |
|
e632a09…
|
drh
|
1256 |
@ %z(href("%R/artifact/%!S",zUuid))manifest</a> |
|
e2d5372…
|
drh
|
1257 |
@ | %z(href("%R/ci_tags/%!S",zUuid))tags</a> |
|
dead084…
|
drh
|
1258 |
if( g.perm.Admin ){ |
|
dead084…
|
drh
|
1259 |
@ | %z(href("%R/mlink?ci=%!S",zUuid))mlink table</a> |
|
dead084…
|
drh
|
1260 |
} |
|
653dd40…
|
drh
|
1261 |
if( g.anon.Write ){ |
|
1fee037…
|
drh
|
1262 |
@ | %z(href("%R/ci_edit?r=%!S",zUuid))edit</a> |
|
e161527…
|
jan.nijtmans
|
1263 |
} |
|
e161527…
|
jan.nijtmans
|
1264 |
@ </td> |
|
e161527…
|
jan.nijtmans
|
1265 |
@ </tr> |
|
e161527…
|
jan.nijtmans
|
1266 |
} |
|
e161527…
|
jan.nijtmans
|
1267 |
@ </table> |
|
867fe0e…
|
drh
|
1268 |
blob_reset(&wiki_read_links); |
|
867fe0e…
|
drh
|
1269 |
blob_reset(&wiki_add_links); |
|
08db9e1…
|
drh
|
1270 |
}else{ |
|
e8d3e32…
|
drh
|
1271 |
style_header("Check-in Information"); |
|
08db9e1…
|
drh
|
1272 |
login_anonymous_available(); |
|
08db9e1…
|
drh
|
1273 |
} |
|
cca1ada…
|
drh
|
1274 |
db_finalize(&q1); |
|
4588959…
|
drh
|
1275 |
@ </details> |
|
5602385…
|
drh
|
1276 |
if( !PB("nowiki") ){ |
|
5602385…
|
drh
|
1277 |
wiki_render_associated("checkin", zUuid, 0); |
|
5602385…
|
drh
|
1278 |
} |
|
4588959…
|
drh
|
1279 |
render_backlink_graph(zUuid, "References"); |
|
4588959…
|
drh
|
1280 |
@ <details open><summary class="section">Context</summary> |
|
4588959…
|
drh
|
1281 |
@ <div class="accordion_panel"> |
|
e454028…
|
drh
|
1282 |
render_checkin_context(rid, 0, 2, 0); |
|
4588959…
|
drh
|
1283 |
@ </div></details> |
|
4588959…
|
drh
|
1284 |
@ <details open> |
|
4588959…
|
drh
|
1285 |
@ <summary class="section" id="changes_section">Changes</summary> |
|
44a7149…
|
florian
|
1286 |
@ <div class="accordion_panel"> |
|
c03ce0f…
|
stephan
|
1287 |
@ <div class="sectionmenu info-changes-menu"> |
|
c03ce0f…
|
stephan
|
1288 |
/* ^^^ .info-changes-menu is used by diff scroll sync */ |
|
1347a1d…
|
drh
|
1289 |
pCfg = construct_diff_flags(diffType, &DCfg); |
|
18151a8…
|
danield
|
1290 |
DCfg.diffFlags |= DIFF_NUMSTAT; /* Show stats in the 'Changes' section */ |
|
5feac63…
|
stephan
|
1291 |
DCfg.pRe = pRe; |
|
1347a1d…
|
drh
|
1292 |
zW = (DCfg.diffFlags&DIFF_IGNORE_ALLWS)?"&w":""; |
|
0a1f4ed…
|
drh
|
1293 |
if( diffType!=1 ){ |
|
0a1f4ed…
|
drh
|
1294 |
@ %z(chref("button","%R/%s/%T?diff=1%s",zPage,zName,zW))\ |
|
4d2d62d…
|
drh
|
1295 |
@ Unified Diff</a> |
|
0a1f4ed…
|
drh
|
1296 |
} |
|
0a1f4ed…
|
drh
|
1297 |
if( diffType!=2 ){ |
|
0a1f4ed…
|
drh
|
1298 |
@ %z(chref("button","%R/%s/%T?diff=2%s",zPage,zName,zW))\ |
|
4d2d62d…
|
drh
|
1299 |
@ Side-by-Side Diff</a> |
|
0a1f4ed…
|
drh
|
1300 |
} |
|
0a1f4ed…
|
drh
|
1301 |
if( diffType!=0 ){ |
|
79c90ac…
|
jan.nijtmans
|
1302 |
if( *zW ){ |
|
b6e0293…
|
florian
|
1303 |
@ %z(chref("button","%R/%s/%T?diff=%d",zPage,zName,diffType)) |
|
79c90ac…
|
jan.nijtmans
|
1304 |
@ Show Whitespace Changes</a> |
|
79c90ac…
|
jan.nijtmans
|
1305 |
}else{ |
|
b6e0293…
|
florian
|
1306 |
@ %z(chref("button","%R/%s/%T?diff=%d&w",zPage,zName,diffType)) |
|
79c90ac…
|
jan.nijtmans
|
1307 |
@ Ignore Whitespace</a> |
|
79c90ac…
|
jan.nijtmans
|
1308 |
} |
|
79c90ac…
|
jan.nijtmans
|
1309 |
} |
|
4bdf71b…
|
drh
|
1310 |
if( zParent ){ |
|
8394d2f…
|
drh
|
1311 |
@ %z(chref("button","%R/vpatch?from=%!S&to=%!S",zParent,zUuid)) |
|
79c90ac…
|
jan.nijtmans
|
1312 |
@ Patch</a> |
|
79c90ac…
|
jan.nijtmans
|
1313 |
} |
|
3fdc2c0…
|
drh
|
1314 |
if( g.perm.Admin ){ |
|
8394d2f…
|
drh
|
1315 |
@ %z(chref("button","%R/mlink?ci=%!S",zUuid))MLink Table</a> |
|
3fdc2c0…
|
drh
|
1316 |
} |
|
ab55339…
|
drh
|
1317 |
@ </div> |
|
79c90ac…
|
jan.nijtmans
|
1318 |
if( pRe ){ |
|
79c90ac…
|
jan.nijtmans
|
1319 |
@ <p><b>Only differences that match regular expression "%h(zRe)" |
|
79c90ac…
|
jan.nijtmans
|
1320 |
@ are shown.</b></p> |
|
79c90ac…
|
jan.nijtmans
|
1321 |
} |
|
79c90ac…
|
jan.nijtmans
|
1322 |
db_prepare(&q3, |
|
79c90ac…
|
jan.nijtmans
|
1323 |
"SELECT name," |
|
79c90ac…
|
jan.nijtmans
|
1324 |
" mperm," |
|
79c90ac…
|
jan.nijtmans
|
1325 |
" (SELECT uuid FROM blob WHERE rid=mlink.pid)," |
|
79c90ac…
|
jan.nijtmans
|
1326 |
" (SELECT uuid FROM blob WHERE rid=mlink.fid)," |
|
79c90ac…
|
jan.nijtmans
|
1327 |
" (SELECT name FROM filename WHERE filename.fnid=mlink.pfnid)" |
|
79c90ac…
|
jan.nijtmans
|
1328 |
" FROM mlink JOIN filename ON filename.fnid=mlink.fnid" |
|
3c34db8…
|
mgagnon
|
1329 |
" WHERE mlink.mid=%d AND NOT mlink.isaux" |
|
79c90ac…
|
jan.nijtmans
|
1330 |
" AND (mlink.fid>0" |
|
79c90ac…
|
jan.nijtmans
|
1331 |
" OR mlink.fnid NOT IN (SELECT pfnid FROM mlink WHERE mid=%d))" |
|
79c90ac…
|
jan.nijtmans
|
1332 |
" ORDER BY name /*sort*/", |
|
79c90ac…
|
jan.nijtmans
|
1333 |
rid, rid |
|
79c90ac…
|
jan.nijtmans
|
1334 |
); |
|
79c90ac…
|
jan.nijtmans
|
1335 |
while( db_step(&q3)==SQLITE_ROW ){ |
|
79c90ac…
|
jan.nijtmans
|
1336 |
const char *zName = db_column_text(&q3,0); |
|
79c90ac…
|
jan.nijtmans
|
1337 |
int mperm = db_column_int(&q3, 1); |
|
79c90ac…
|
jan.nijtmans
|
1338 |
const char *zOld = db_column_text(&q3,2); |
|
79c90ac…
|
jan.nijtmans
|
1339 |
const char *zNew = db_column_text(&q3,3); |
|
79c90ac…
|
jan.nijtmans
|
1340 |
const char *zOldName = db_column_text(&q3, 4); |
|
5feac63…
|
stephan
|
1341 |
append_file_change_line(zUuid, zName, zOld, zNew, zOldName, |
|
94e94bc…
|
drh
|
1342 |
pCfg,mperm,aChng); |
|
79c90ac…
|
jan.nijtmans
|
1343 |
} |
|
79c90ac…
|
jan.nijtmans
|
1344 |
db_finalize(&q3); |
|
4588959…
|
drh
|
1345 |
@ </div></details> |
|
3710202…
|
drh
|
1346 |
if( diffType!=0 ){ |
|
94e94bc…
|
drh
|
1347 |
adjust_changes_section_title(__LINE__, aChng); |
|
171127f…
|
florian
|
1348 |
} |
|
171127f…
|
florian
|
1349 |
append_diff_javascript(diffType); |
|
112c713…
|
drh
|
1350 |
style_finish_page(); |
|
08db9e1…
|
drh
|
1351 |
} |
|
08db9e1…
|
drh
|
1352 |
|
|
08db9e1…
|
drh
|
1353 |
/* |
|
08db9e1…
|
drh
|
1354 |
** WEBPAGE: winfo |
|
8ad5e46…
|
wyoung
|
1355 |
** URL: /winfo?name=HASH |
|
08db9e1…
|
drh
|
1356 |
** |
|
7ab0328…
|
drh
|
1357 |
** Display information about a wiki page. |
|
08db9e1…
|
drh
|
1358 |
*/ |
|
08db9e1…
|
drh
|
1359 |
void winfo_page(void){ |
|
08db9e1…
|
drh
|
1360 |
int rid; |
|
ba418ee…
|
drh
|
1361 |
Manifest *pWiki; |
|
ba418ee…
|
drh
|
1362 |
char *zUuid; |
|
ba418ee…
|
drh
|
1363 |
char *zDate; |
|
ba418ee…
|
drh
|
1364 |
Blob wiki; |
|
ba418ee…
|
drh
|
1365 |
int modPending; |
|
ba418ee…
|
drh
|
1366 |
const char *zModAction; |
|
423c6a9…
|
drh
|
1367 |
int tagid; |
|
423c6a9…
|
drh
|
1368 |
int ridNext; |
|
08db9e1…
|
drh
|
1369 |
|
|
08db9e1…
|
drh
|
1370 |
login_check_credentials(); |
|
653dd40…
|
drh
|
1371 |
if( !g.perm.RdWiki ){ login_needed(g.anon.RdWiki); return; } |
|
112c713…
|
drh
|
1372 |
style_set_current_feature("winfo"); |
|
96722b6…
|
drh
|
1373 |
rid = name_to_rid_www("name"); |
|
ec81aee…
|
jan.nijtmans
|
1374 |
if( rid==0 || (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))==0 ){ |
|
08db9e1…
|
drh
|
1375 |
style_header("Wiki Page Information Error"); |
|
ba418ee…
|
drh
|
1376 |
@ No such object: %h(P("name")) |
|
112c713…
|
drh
|
1377 |
style_finish_page(); |
|
08db9e1…
|
drh
|
1378 |
return; |
|
08db9e1…
|
drh
|
1379 |
} |
|
ba418ee…
|
drh
|
1380 |
if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){ |
|
ba418ee…
|
drh
|
1381 |
if( strcmp(zModAction,"delete")==0 ){ |
|
ba418ee…
|
drh
|
1382 |
moderation_disapprove(rid); |
|
636c334…
|
mistachkin
|
1383 |
/* |
|
636c334…
|
mistachkin
|
1384 |
** Next, check if the wiki page still exists; if not, we cannot |
|
636c334…
|
mistachkin
|
1385 |
** redirect to it. |
|
636c334…
|
mistachkin
|
1386 |
*/ |
|
636c334…
|
mistachkin
|
1387 |
if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)" |
|
636c334…
|
mistachkin
|
1388 |
" WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){ |
|
636c334…
|
mistachkin
|
1389 |
cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle); |
|
636c334…
|
mistachkin
|
1390 |
/*NOTREACHED*/ |
|
636c334…
|
mistachkin
|
1391 |
}else{ |
|
636c334…
|
mistachkin
|
1392 |
cgi_redirectf("%R/modreq"); |
|
636c334…
|
mistachkin
|
1393 |
/*NOTREACHED*/ |
|
636c334…
|
mistachkin
|
1394 |
} |
|
ba418ee…
|
drh
|
1395 |
} |
|
ba418ee…
|
drh
|
1396 |
if( strcmp(zModAction,"approve")==0 ){ |
|
5e28feb…
|
drh
|
1397 |
moderation_approve('w', rid); |
|
ba418ee…
|
drh
|
1398 |
} |
|
ba418ee…
|
drh
|
1399 |
} |
|
57f1e87…
|
drh
|
1400 |
cgi_check_for_malice(); |
|
ba418ee…
|
drh
|
1401 |
style_header("Update of \"%h\"", pWiki->zWikiTitle); |
|
ba418ee…
|
drh
|
1402 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
17ebe42…
|
stephan
|
1403 |
zDate = db_text(0, "SELECT datetime(%.17g,toLocal())", pWiki->rDate); |
|
356a484…
|
george
|
1404 |
style_submenu_element("Raw", "%R/artifact/%s", zUuid); |
|
356a484…
|
george
|
1405 |
style_submenu_element("History", "%R/whistory?name=%t", pWiki->zWikiTitle); |
|
356a484…
|
george
|
1406 |
style_submenu_element("Page", "%R/wiki?name=%t", pWiki->zWikiTitle); |
|
ba418ee…
|
drh
|
1407 |
login_anonymous_available(); |
|
ba418ee…
|
drh
|
1408 |
@ <div class="section">Overview</div> |
|
ba418ee…
|
drh
|
1409 |
@ <p><table class="label-value"> |
|
ba418ee…
|
drh
|
1410 |
@ <tr><th>Artifact ID:</th> |
|
1fee037…
|
drh
|
1411 |
@ <td>%z(href("%R/artifact/%!S",zUuid))%s(zUuid)</a> |
|
ba418ee…
|
drh
|
1412 |
if( g.perm.Setup ){ |
|
ba418ee…
|
drh
|
1413 |
@ (%d(rid)) |
|
ba418ee…
|
drh
|
1414 |
} |
|
99fcc43…
|
drh
|
1415 |
modPending = moderation_pending_www(rid); |
|
ba418ee…
|
drh
|
1416 |
@ </td></tr> |
|
423c6a9…
|
drh
|
1417 |
@ <tr><th>Page Name:</th>\ |
|
423c6a9…
|
drh
|
1418 |
@ <td>%z(href("%R/whistory?name=%h",pWiki->zWikiTitle))\ |
|
423c6a9…
|
drh
|
1419 |
@ %h(pWiki->zWikiTitle)</a></td></tr> |
|
ba418ee…
|
drh
|
1420 |
@ <tr><th>Date:</th><td> |
|
ba418ee…
|
drh
|
1421 |
hyperlink_to_date(zDate, "</td></tr>"); |
|
ba418ee…
|
drh
|
1422 |
@ <tr><th>Original User:</th><td> |
|
ba418ee…
|
drh
|
1423 |
hyperlink_to_user(pWiki->zUser, zDate, "</td></tr>"); |
|
bfe726f…
|
drh
|
1424 |
if( pWiki->zMimetype ){ |
|
bfe726f…
|
drh
|
1425 |
@ <tr><th>Mimetype:</th><td>%h(pWiki->zMimetype)</td></tr> |
|
bfe726f…
|
drh
|
1426 |
} |
|
ba418ee…
|
drh
|
1427 |
if( pWiki->nParent>0 ){ |
|
ba418ee…
|
drh
|
1428 |
int i; |
|
ba418ee…
|
drh
|
1429 |
@ <tr><th>Parent%s(pWiki->nParent==1?"":"s"):</th><td> |
|
ba418ee…
|
drh
|
1430 |
for(i=0; i<pWiki->nParent; i++){ |
|
ba418ee…
|
drh
|
1431 |
char *zParent = pWiki->azParent[i]; |
|
356a484…
|
george
|
1432 |
@ %z(href("%R/info/%!S",zParent))%s(zParent)</a> |
|
19eaa3c…
|
drh
|
1433 |
@ %z(href("%R/wdiff?id=%!S&pid=%!S",zUuid,zParent))(diff)</a> |
|
ba418ee…
|
drh
|
1434 |
} |
|
ba418ee…
|
drh
|
1435 |
@ </td></tr> |
|
423c6a9…
|
drh
|
1436 |
} |
|
423c6a9…
|
drh
|
1437 |
tagid = wiki_tagid(pWiki->zWikiTitle); |
|
423c6a9…
|
drh
|
1438 |
if( tagid>0 && (ridNext = wiki_next(tagid, pWiki->rDate))>0 ){ |
|
423c6a9…
|
drh
|
1439 |
char *zId = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", ridNext); |
|
423c6a9…
|
drh
|
1440 |
@ <tr><th>Next</th> |
|
423c6a9…
|
drh
|
1441 |
@ <td>%z(href("%R/info/%!S",zId))%s(zId)</a></td> |
|
ba418ee…
|
drh
|
1442 |
} |
|
ba418ee…
|
drh
|
1443 |
@ </table> |
|
ba418ee…
|
drh
|
1444 |
|
|
ba418ee…
|
drh
|
1445 |
if( g.perm.ModWiki && modPending ){ |
|
ba418ee…
|
drh
|
1446 |
@ <div class="section">Moderation</div> |
|
ba418ee…
|
drh
|
1447 |
@ <blockquote> |
|
ba418ee…
|
drh
|
1448 |
@ <form method="POST" action="%R/winfo/%s(zUuid)"> |
|
ba418ee…
|
drh
|
1449 |
@ <label><input type="radio" name="modaction" value="delete"> |
|
f5482a0…
|
wyoung
|
1450 |
@ Delete this change</label><br> |
|
ba418ee…
|
drh
|
1451 |
@ <label><input type="radio" name="modaction" value="approve"> |
|
f5482a0…
|
wyoung
|
1452 |
@ Approve this change</label><br> |
|
ba418ee…
|
drh
|
1453 |
@ <input type="submit" value="Submit"> |
|
ba418ee…
|
drh
|
1454 |
@ </form> |
|
ba418ee…
|
drh
|
1455 |
@ </blockquote> |
|
ba418ee…
|
drh
|
1456 |
} |
|
ba418ee…
|
drh
|
1457 |
|
|
ba418ee…
|
drh
|
1458 |
|
|
ba418ee…
|
drh
|
1459 |
@ <div class="section">Content</div> |
|
ba418ee…
|
drh
|
1460 |
blob_init(&wiki, pWiki->zWiki, -1); |
|
89b6dda…
|
drh
|
1461 |
safe_html_context(DOCSRC_WIKI); |
|
89b6dda…
|
drh
|
1462 |
wiki_render_by_mimetype(&wiki, pWiki->zMimetype); |
|
ba418ee…
|
drh
|
1463 |
blob_reset(&wiki); |
|
ba418ee…
|
drh
|
1464 |
manifest_destroy(pWiki); |
|
9b2b6f5…
|
stephan
|
1465 |
document_emit_js(); |
|
112c713…
|
drh
|
1466 |
style_finish_page(); |
|
ba418ee…
|
drh
|
1467 |
} |
|
ba418ee…
|
drh
|
1468 |
|
|
ba418ee…
|
drh
|
1469 |
/* |
|
c49030f…
|
drh
|
1470 |
** Find an check-in based on query parameter zParam and parse its |
|
1d713f3…
|
drh
|
1471 |
** manifest. Return the number of errors. |
|
1d713f3…
|
drh
|
1472 |
*/ |
|
d13054c…
|
drh
|
1473 |
static Manifest *vdiff_parse_manifest(const char *zParam, int *pRid){ |
|
1d713f3…
|
drh
|
1474 |
int rid; |
|
1d713f3…
|
drh
|
1475 |
|
|
1d713f3…
|
drh
|
1476 |
*pRid = rid = name_to_rid_www(zParam); |
|
1d713f3…
|
drh
|
1477 |
if( rid==0 ){ |
|
9f83e03…
|
drh
|
1478 |
const char *z = P(zParam); |
|
9f83e03…
|
drh
|
1479 |
if( z==0 || z[0]==0 ){ |
|
9f83e03…
|
drh
|
1480 |
webpage_error("Missing \"%s\" query parameter.", zParam); |
|
9f83e03…
|
drh
|
1481 |
}else{ |
|
9f83e03…
|
drh
|
1482 |
webpage_error("No such artifact: \"%s\"", z); |
|
9f83e03…
|
drh
|
1483 |
} |
|
9f83e03…
|
drh
|
1484 |
return 0; |
|
9f83e03…
|
drh
|
1485 |
} |
|
9f83e03…
|
drh
|
1486 |
if( !is_a_version(rid) ){ |
|
c49030f…
|
drh
|
1487 |
webpage_error("Artifact %s is not a check-in.", P(zParam)); |
|
9f83e03…
|
drh
|
1488 |
return 0; |
|
9f83e03…
|
drh
|
1489 |
} |
|
ec81aee…
|
jan.nijtmans
|
1490 |
return manifest_get(rid, CFTYPE_MANIFEST, 0); |
|
ec81aee…
|
jan.nijtmans
|
1491 |
} |
|
08db9e1…
|
drh
|
1492 |
|
|
08db9e1…
|
drh
|
1493 |
/* |
|
08db9e1…
|
drh
|
1494 |
** WEBPAGE: vdiff |
|
7ab0328…
|
drh
|
1495 |
** URL: /vdiff?from=TAG&to=TAG |
|
7ab0328…
|
drh
|
1496 |
** |
|
7ab0328…
|
drh
|
1497 |
** Show the difference between two check-ins identified by the from= and |
|
7ab0328…
|
drh
|
1498 |
** to= query parameters. |
|
b0036a3…
|
drh
|
1499 |
** |
|
b0036a3…
|
drh
|
1500 |
** Query parameters: |
|
b0036a3…
|
drh
|
1501 |
** |
|
e707906…
|
drh
|
1502 |
** from=TAG Left side of the comparison |
|
e707906…
|
drh
|
1503 |
** to=TAG Right side of the comparison |
|
e707906…
|
drh
|
1504 |
** branch=TAG Show all changes on a particular branch |
|
0a1f4ed…
|
drh
|
1505 |
** diff=INTEGER 0: none, 1: unified, 2: side-by-side |
|
e707906…
|
drh
|
1506 |
** glob=STRING only diff files matching this glob |
|
7ab0328…
|
drh
|
1507 |
** dc=N show N lines of context around each diff |
|
ab8ed31…
|
drh
|
1508 |
** w=BOOLEAN ignore whitespace when computing diffs |
|
2532f1b…
|
drh
|
1509 |
** nohdr omit the description at the top of the page |
|
2e51bb9…
|
drh
|
1510 |
** nc omit branch coloration from the header graph |
|
2e51bb9…
|
drh
|
1511 |
** inv "Invert". Exchange the roles of from= and to= |
|
e707906…
|
drh
|
1512 |
** |
|
6ec2c2e…
|
mistachkin
|
1513 |
** Show all differences between two check-ins. |
|
08db9e1…
|
drh
|
1514 |
*/ |
|
08db9e1…
|
drh
|
1515 |
void vdiff_page(void){ |
|
1d713f3…
|
drh
|
1516 |
int ridFrom, ridTo; |
|
0a1f4ed…
|
drh
|
1517 |
int diffType = 0; /* 0: none, 1: unified, 2: side-by-side */ |
|
d13054c…
|
drh
|
1518 |
Manifest *pFrom, *pTo; |
|
d13054c…
|
drh
|
1519 |
ManifestFile *pFileFrom, *pFileTo; |
|
9f83e03…
|
drh
|
1520 |
const char *zBranch; |
|
b0036a3…
|
drh
|
1521 |
const char *zFrom; |
|
b0036a3…
|
drh
|
1522 |
const char *zTo; |
|
31dd2c0…
|
drh
|
1523 |
const char *zRe; |
|
9b1932f…
|
stephan
|
1524 |
const char *zGlob; |
|
e576ce7…
|
stephan
|
1525 |
Glob * pGlob = 0; |
|
e632a09…
|
drh
|
1526 |
char *zMergeOrigin = 0; |
|
31dd2c0…
|
drh
|
1527 |
ReCompiled *pRe = 0; |
|
1347a1d…
|
drh
|
1528 |
DiffConfig DCfg, *pCfg = 0; |
|
2e51bb9…
|
drh
|
1529 |
int graphFlags = 0; |
|
7f288c6…
|
stephan
|
1530 |
Blob qp; /* non-glob= query parameters for generated links */ |
|
7f288c6…
|
stephan
|
1531 |
Blob qpGlob; /* glob= query parameter for generated links */ |
|
2e51bb9…
|
drh
|
1532 |
int bInvert = PB("inv"); |
|
94e94bc…
|
drh
|
1533 |
int aChng[N_FCHNG]; /* Count of versiou change types */ |
|
2e51bb9…
|
drh
|
1534 |
|
|
94e94bc…
|
drh
|
1535 |
memset(aChng, 0, sizeof(aChng)); |
|
08db9e1…
|
drh
|
1536 |
login_check_credentials(); |
|
653dd40…
|
drh
|
1537 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
16b3309…
|
drh
|
1538 |
if( robot_restrict("diff") ) return; |
|
08db9e1…
|
drh
|
1539 |
login_anonymous_available(); |
|
9413395…
|
drh
|
1540 |
fossil_nice_default(); |
|
2e51bb9…
|
drh
|
1541 |
blob_init(&qp, 0, 0); |
|
7f288c6…
|
stephan
|
1542 |
blob_init(&qpGlob, 0, 0); |
|
29bab27…
|
drh
|
1543 |
diffType = preferred_diff_type(); |
|
31dd2c0…
|
drh
|
1544 |
zRe = P("regex"); |
|
82888a0…
|
drh
|
1545 |
if( zRe ) fossil_re_compile(&pRe, zRe, 0); |
|
9f83e03…
|
drh
|
1546 |
zBranch = P("branch"); |
|
e632a09…
|
drh
|
1547 |
if( zBranch && zBranch[0]==0 ) zBranch = 0; |
|
e632a09…
|
drh
|
1548 |
if( zBranch ){ |
|
2e51bb9…
|
drh
|
1549 |
blob_appendf(&qp, "branch=%T", zBranch); |
|
e632a09…
|
drh
|
1550 |
zMergeOrigin = mprintf("merge-in:%s", zBranch); |
|
e632a09…
|
drh
|
1551 |
cgi_replace_parameter("from", zMergeOrigin); |
|
9f83e03…
|
drh
|
1552 |
cgi_replace_parameter("to", zBranch); |
|
e632a09…
|
drh
|
1553 |
}else{ |
|
2e51bb9…
|
drh
|
1554 |
if( bInvert ){ |
|
2e51bb9…
|
drh
|
1555 |
blob_appendf(&qp, "to=%T&from=%T",PD("from",""),PD("to","")); |
|
2e51bb9…
|
drh
|
1556 |
}else{ |
|
2e51bb9…
|
drh
|
1557 |
blob_appendf(&qp, "from=%T&to=%T",PD("from",""),PD("to","")); |
|
2e51bb9…
|
drh
|
1558 |
} |
|
9f83e03…
|
drh
|
1559 |
} |
|
d13054c…
|
drh
|
1560 |
pTo = vdiff_parse_manifest("to", &ridTo); |
|
d13054c…
|
drh
|
1561 |
if( pTo==0 ) return; |
|
9f83e03…
|
drh
|
1562 |
pFrom = vdiff_parse_manifest("from", &ridFrom); |
|
9f83e03…
|
drh
|
1563 |
if( pFrom==0 ) return; |
|
9b1932f…
|
stephan
|
1564 |
zGlob = P("glob"); |
|
938fda7…
|
stephan
|
1565 |
/* |
|
938fda7…
|
stephan
|
1566 |
** Maintenace reminder: we explicitly do _not_ use P_NoBot() |
|
938fda7…
|
stephan
|
1567 |
** for "from" and "to" because those args can contain legitimate |
|
3d1e634…
|
stephan
|
1568 |
** strings which may trigger the looks-like SQL checks, e.g. |
|
3d1e634…
|
stephan
|
1569 |
** from=merge-in:OR-clause-improvement |
|
3d1e634…
|
stephan
|
1570 |
** to=OR-clause-improvement |
|
938fda7…
|
stephan
|
1571 |
*/ |
|
938fda7…
|
stephan
|
1572 |
zFrom = P("from"); |
|
938fda7…
|
stephan
|
1573 |
zTo = P("to"); |
|
2e51bb9…
|
drh
|
1574 |
if( bInvert ){ |
|
2e51bb9…
|
drh
|
1575 |
Manifest *pTemp = pTo; |
|
2e51bb9…
|
drh
|
1576 |
const char *zTemp = zTo; |
|
2e51bb9…
|
drh
|
1577 |
pTo = pFrom; |
|
2e51bb9…
|
drh
|
1578 |
pFrom = pTemp; |
|
2e51bb9…
|
drh
|
1579 |
zTo = zFrom; |
|
2e51bb9…
|
drh
|
1580 |
zFrom = zTemp; |
|
e632a09…
|
drh
|
1581 |
} |
|
7f288c6…
|
stephan
|
1582 |
if( zGlob ){ |
|
2e51bb9…
|
drh
|
1583 |
if( !*zGlob ){ |
|
2e51bb9…
|
drh
|
1584 |
zGlob = NULL; |
|
2e51bb9…
|
drh
|
1585 |
}else{ |
|
7f288c6…
|
stephan
|
1586 |
blob_appendf(&qpGlob, "&glob=%T", zGlob); |
|
e576ce7…
|
stephan
|
1587 |
pGlob = glob_create(zGlob); |
|
2e51bb9…
|
drh
|
1588 |
} |
|
2e51bb9…
|
drh
|
1589 |
} |
|
2e51bb9…
|
drh
|
1590 |
if( PB("nc") ){ |
|
2e51bb9…
|
drh
|
1591 |
graphFlags |= TIMELINE_NOCOLOR; |
|
2e51bb9…
|
drh
|
1592 |
blob_appendf(&qp, "&nc"); |
|
2e51bb9…
|
drh
|
1593 |
} |
|
1347a1d…
|
drh
|
1594 |
pCfg = construct_diff_flags(diffType, &DCfg); |
|
1347a1d…
|
drh
|
1595 |
if( DCfg.diffFlags & DIFF_IGNORE_ALLWS ){ |
|
2e51bb9…
|
drh
|
1596 |
blob_appendf(&qp, "&w"); |
|
2e51bb9…
|
drh
|
1597 |
} |
|
57f1e87…
|
drh
|
1598 |
cgi_check_for_malice(); |
|
112c713…
|
drh
|
1599 |
style_set_current_feature("vdiff"); |
|
e632a09…
|
drh
|
1600 |
if( zBranch==0 ){ |
|
e632a09…
|
drh
|
1601 |
style_submenu_element("Path", "%R/timeline?me=%T&you=%T", zFrom, zTo); |
|
0a1f4ed…
|
drh
|
1602 |
} |
|
0a1f4ed…
|
drh
|
1603 |
if( diffType!=2 ){ |
|
7f288c6…
|
stephan
|
1604 |
style_submenu_element("Side-by-Side Diff", "%R/vdiff?diff=2&%b%b", &qp, |
|
7f288c6…
|
stephan
|
1605 |
&qpGlob); |
|
0a1f4ed…
|
drh
|
1606 |
} |
|
0a1f4ed…
|
drh
|
1607 |
if( diffType!=1 ) { |
|
7f288c6…
|
stephan
|
1608 |
style_submenu_element("Unified Diff", "%R/vdiff?diff=1&%b%b", &qp, &qpGlob); |
|
e632a09…
|
drh
|
1609 |
} |
|
e632a09…
|
drh
|
1610 |
if( zBranch==0 ){ |
|
7f288c6…
|
stephan
|
1611 |
style_submenu_element("Invert","%R/vdiff?diff=%d&inv&%b%b", diffType, |
|
7f288c6…
|
stephan
|
1612 |
&qp, &qpGlob); |
|
e632a09…
|
drh
|
1613 |
} |
|
2532f1b…
|
drh
|
1614 |
if( zGlob ){ |
|
7f288c6…
|
stephan
|
1615 |
style_submenu_element("Clear glob", "%R/vdiff?diff=%d&%b", diffType, &qp); |
|
037e06b…
|
drh
|
1616 |
}else{ |
|
2e51bb9…
|
drh
|
1617 |
style_submenu_element("Patch", "%R/vpatch?from=%T&to=%T%s", zFrom, zTo, |
|
1347a1d…
|
drh
|
1618 |
(DCfg.diffFlags & DIFF_IGNORE_ALLWS)?"&w":""); |
|
037e06b…
|
drh
|
1619 |
} |
|
0a1f4ed…
|
drh
|
1620 |
if( diffType!=0 ){ |
|
037e06b…
|
drh
|
1621 |
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0); |
|
037e06b…
|
drh
|
1622 |
} |
|
e632a09…
|
drh
|
1623 |
if( zBranch ){ |
|
e632a09…
|
drh
|
1624 |
style_header("Changes On Branch %h", zBranch); |
|
e632a09…
|
drh
|
1625 |
}else{ |
|
e632a09…
|
drh
|
1626 |
style_header("Check-in Differences"); |
|
e632a09…
|
drh
|
1627 |
} |
|
2532f1b…
|
drh
|
1628 |
if( P("nohdr")==0 ){ |
|
e632a09…
|
drh
|
1629 |
if( zBranch ){ |
|
e632a09…
|
drh
|
1630 |
char *zRealBranch = branch_of_rid(ridTo); |
|
e632a09…
|
drh
|
1631 |
char *zToUuid = rid_to_uuid(ridTo); |
|
e632a09…
|
drh
|
1632 |
char *zFromUuid = rid_to_uuid(ridFrom); |
|
e632a09…
|
drh
|
1633 |
@ <h2>Changes In Branch \ |
|
e632a09…
|
drh
|
1634 |
@ %z(href("%R/timeline?r=%T",zRealBranch))%h(zRealBranch)</a> |
|
e632a09…
|
drh
|
1635 |
if( ridTo != symbolic_name_to_rid(zRealBranch,"ci") ){ |
|
e632a09…
|
drh
|
1636 |
@ Through %z(href("%R/info/%!S",zToUuid))[%S(zToUuid)]</a> |
|
e632a09…
|
drh
|
1637 |
} |
|
e632a09…
|
drh
|
1638 |
@ Excluding Merge-Ins</h2> |
|
e632a09…
|
drh
|
1639 |
@ <p>This is equivalent to a diff from |
|
e632a09…
|
drh
|
1640 |
@ <span class='timelineSelected'>\ |
|
e632a09…
|
drh
|
1641 |
@ %z(href("%R/info/%!S",zFromUuid))%S(zFromUuid)</a></span> |
|
e632a09…
|
drh
|
1642 |
@ to <span class='timelineSelected timelineSecondary'>\ |
|
e632a09…
|
drh
|
1643 |
@ %z(href("%R/info/%!S",zToUuid))%S(zToUuid)</a></span></p> |
|
e632a09…
|
drh
|
1644 |
}else{ |
|
e632a09…
|
drh
|
1645 |
@ <h2>Difference From <span class='timelineSelected'>\ |
|
e632a09…
|
drh
|
1646 |
@ %z(href("%R/info/%h",zFrom))%h(zFrom)</a></span> |
|
e632a09…
|
drh
|
1647 |
@ To <span class='timelineSelected timelineSecondary'>\ |
|
e632a09…
|
drh
|
1648 |
@ %z(href("%R/info/%h",zTo))%h(zTo)</a></span></h2> |
|
e632a09…
|
drh
|
1649 |
} |
|
2e51bb9…
|
drh
|
1650 |
render_checkin_context(ridFrom, ridTo, 0, graphFlags); |
|
2532f1b…
|
drh
|
1651 |
if( pRe ){ |
|
2532f1b…
|
drh
|
1652 |
@ <p><b>Only differences that match regular expression "%h(zRe)" |
|
2532f1b…
|
drh
|
1653 |
@ are shown.</b></p> |
|
2532f1b…
|
drh
|
1654 |
} |
|
2532f1b…
|
drh
|
1655 |
if( zGlob ){ |
|
2532f1b…
|
drh
|
1656 |
@ <p><b>Only files matching the glob "%h(zGlob)" are shown.</b></p> |
|
2532f1b…
|
drh
|
1657 |
} |
|
f5482a0…
|
wyoung
|
1658 |
@<hr><p> |
|
2532f1b…
|
drh
|
1659 |
} |
|
2e51bb9…
|
drh
|
1660 |
blob_reset(&qp); |
|
7f288c6…
|
stephan
|
1661 |
blob_reset(&qpGlob); |
|
d13054c…
|
drh
|
1662 |
|
|
d13054c…
|
drh
|
1663 |
manifest_file_rewind(pFrom); |
|
d13054c…
|
drh
|
1664 |
pFileFrom = manifest_file_next(pFrom, 0); |
|
d13054c…
|
drh
|
1665 |
manifest_file_rewind(pTo); |
|
d13054c…
|
drh
|
1666 |
pFileTo = manifest_file_next(pTo, 0); |
|
1347a1d…
|
drh
|
1667 |
DCfg.pRe = pRe; |
|
d13054c…
|
drh
|
1668 |
while( pFileFrom || pFileTo ){ |
|
1d713f3…
|
drh
|
1669 |
int cmp; |
|
d13054c…
|
drh
|
1670 |
if( pFileFrom==0 ){ |
|
1d713f3…
|
drh
|
1671 |
cmp = +1; |
|
d13054c…
|
drh
|
1672 |
}else if( pFileTo==0 ){ |
|
1d713f3…
|
drh
|
1673 |
cmp = -1; |
|
1d713f3…
|
drh
|
1674 |
}else{ |
|
31c52c7…
|
drh
|
1675 |
cmp = fossil_strcmp(pFileFrom->zName, pFileTo->zName); |
|
31c52c7…
|
drh
|
1676 |
} |
|
31c52c7…
|
drh
|
1677 |
if( cmp<0 ){ |
|
e576ce7…
|
stephan
|
1678 |
if( !pGlob || glob_match(pGlob, pFileFrom->zName) ){ |
|
b54d939…
|
drh
|
1679 |
append_file_change_line(zFrom, pFileFrom->zName, |
|
94e94bc…
|
drh
|
1680 |
pFileFrom->zUuid, 0, 0, pCfg, 0,aChng); |
|
9b1932f…
|
stephan
|
1681 |
} |
|
ba418ee…
|
drh
|
1682 |
pFileFrom = manifest_file_next(pFrom, 0); |
|
ba418ee…
|
drh
|
1683 |
}else if( cmp>0 ){ |
|
e576ce7…
|
stephan
|
1684 |
if( !pGlob || glob_match(pGlob, pFileTo->zName) ){ |
|
b54d939…
|
drh
|
1685 |
append_file_change_line(zTo, pFileTo->zName, |
|
1347a1d…
|
drh
|
1686 |
0, pFileTo->zUuid, 0, pCfg, |
|
94e94bc…
|
drh
|
1687 |
manifest_file_mperm(pFileTo),aChng); |
|
9b1932f…
|
stephan
|
1688 |
} |
|
ba418ee…
|
drh
|
1689 |
pFileTo = manifest_file_next(pTo, 0); |
|
ba418ee…
|
drh
|
1690 |
}else if( fossil_strcmp(pFileFrom->zUuid, pFileTo->zUuid)==0 ){ |
|
ba418ee…
|
drh
|
1691 |
pFileFrom = manifest_file_next(pFrom, 0); |
|
ba418ee…
|
drh
|
1692 |
pFileTo = manifest_file_next(pTo, 0); |
|
ba418ee…
|
drh
|
1693 |
}else{ |
|
e576ce7…
|
stephan
|
1694 |
if(!pGlob || (glob_match(pGlob, pFileFrom->zName) |
|
e576ce7…
|
stephan
|
1695 |
|| glob_match(pGlob, pFileTo->zName)) ){ |
|
b54d939…
|
drh
|
1696 |
append_file_change_line(zFrom, pFileFrom->zName, |
|
9b1932f…
|
stephan
|
1697 |
pFileFrom->zUuid, |
|
1347a1d…
|
drh
|
1698 |
pFileTo->zUuid, 0, pCfg, |
|
94e94bc…
|
drh
|
1699 |
manifest_file_mperm(pFileTo),aChng); |
|
9b1932f…
|
stephan
|
1700 |
} |
|
ba418ee…
|
drh
|
1701 |
pFileFrom = manifest_file_next(pFrom, 0); |
|
ba418ee…
|
drh
|
1702 |
pFileTo = manifest_file_next(pTo, 0); |
|
ba418ee…
|
drh
|
1703 |
} |
|
ba418ee…
|
drh
|
1704 |
} |
|
e576ce7…
|
stephan
|
1705 |
glob_free(pGlob); |
|
ba418ee…
|
drh
|
1706 |
manifest_destroy(pFrom); |
|
ba418ee…
|
drh
|
1707 |
manifest_destroy(pTo); |
|
f9761ab…
|
florian
|
1708 |
append_diff_javascript(diffType); |
|
112c713…
|
drh
|
1709 |
style_finish_page(); |
|
ba418ee…
|
drh
|
1710 |
} |
|
ba418ee…
|
drh
|
1711 |
|
|
ba418ee…
|
drh
|
1712 |
#if INTERFACE |
|
ba418ee…
|
drh
|
1713 |
/* |
|
ba418ee…
|
drh
|
1714 |
** Possible return values from object_description() |
|
ba418ee…
|
drh
|
1715 |
*/ |
|
ba418ee…
|
drh
|
1716 |
#define OBJTYPE_CHECKIN 0x0001 |
|
ba418ee…
|
drh
|
1717 |
#define OBJTYPE_CONTENT 0x0002 |
|
ba418ee…
|
drh
|
1718 |
#define OBJTYPE_WIKI 0x0004 |
|
ba418ee…
|
drh
|
1719 |
#define OBJTYPE_TICKET 0x0008 |
|
ba418ee…
|
drh
|
1720 |
#define OBJTYPE_ATTACHMENT 0x0010 |
|
ba418ee…
|
drh
|
1721 |
#define OBJTYPE_EVENT 0x0020 |
|
ba418ee…
|
drh
|
1722 |
#define OBJTYPE_TAG 0x0040 |
|
ba418ee…
|
drh
|
1723 |
#define OBJTYPE_SYMLINK 0x0080 |
|
ba418ee…
|
drh
|
1724 |
#define OBJTYPE_EXE 0x0100 |
|
99fcc43…
|
drh
|
1725 |
#define OBJTYPE_FORUM 0x0200 |
|
0ac4cea…
|
drh
|
1726 |
|
|
0ac4cea…
|
drh
|
1727 |
/* |
|
0ac4cea…
|
drh
|
1728 |
** Possible flags for the second parameter to |
|
0ac4cea…
|
drh
|
1729 |
** object_description() |
|
0ac4cea…
|
drh
|
1730 |
*/ |
|
2b07e4e…
|
drh
|
1731 |
#define OBJDESC_DETAIL 0x0001 /* Show more detail */ |
|
8af35d3…
|
drh
|
1732 |
#define OBJDESC_BASE 0x0002 /* Set <base> using this object */ |
|
ba418ee…
|
drh
|
1733 |
#endif |
|
ba418ee…
|
drh
|
1734 |
|
|
ba418ee…
|
drh
|
1735 |
/* |
|
ba418ee…
|
drh
|
1736 |
** Write a description of an object to the www reply. |
|
ba418ee…
|
drh
|
1737 |
*/ |
|
ba418ee…
|
drh
|
1738 |
int object_description( |
|
2b07e4e…
|
drh
|
1739 |
int rid, /* The artifact ID for the object to describe */ |
|
0ac4cea…
|
drh
|
1740 |
u32 objdescFlags, /* Flags to control display */ |
|
2b07e4e…
|
drh
|
1741 |
const char *zFileName, /* For file objects, use this name. Can be NULL */ |
|
2b07e4e…
|
drh
|
1742 |
Blob *pDownloadName /* Fill with a good download name. Can be NULL */ |
|
ba418ee…
|
drh
|
1743 |
){ |
|
ba418ee…
|
drh
|
1744 |
Stmt q; |
|
ba418ee…
|
drh
|
1745 |
int cnt = 0; |
|
ba418ee…
|
drh
|
1746 |
int nWiki = 0; |
|
ba418ee…
|
drh
|
1747 |
int objType = 0; |
|
ba418ee…
|
drh
|
1748 |
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
3c2d418…
|
drh
|
1749 |
int showDetail = (objdescFlags & OBJDESC_DETAIL)!=0; |
|
ba418ee…
|
drh
|
1750 |
char *prevName = 0; |
|
8af35d3…
|
drh
|
1751 |
int bNeedBase = (objdescFlags & OBJDESC_BASE)!=0; |
|
ba418ee…
|
drh
|
1752 |
|
|
ba418ee…
|
drh
|
1753 |
db_prepare(&q, |
|
e7192bb…
|
andygoth
|
1754 |
"SELECT filename.name, datetime(event.mtime,toLocal())," |
|
ba418ee…
|
drh
|
1755 |
" coalesce(event.ecomment,event.comment)," |
|
ba418ee…
|
drh
|
1756 |
" coalesce(event.euser,event.user)," |
|
ba418ee…
|
drh
|
1757 |
" b.uuid, mlink.mperm," |
|
ba418ee…
|
drh
|
1758 |
" coalesce((SELECT value FROM tagxref" |
|
f8bc3ce…
|
drh
|
1759 |
" WHERE tagid=%d AND tagtype>0 AND rid=mlink.mid),'trunk')," |
|
4c26899…
|
drh
|
1760 |
" a.size" |
|
08db9e1…
|
drh
|
1761 |
" FROM mlink, filename, event, blob a, blob b" |
|
08db9e1…
|
drh
|
1762 |
" WHERE filename.fnid=mlink.fnid" |
|
08db9e1…
|
drh
|
1763 |
" AND event.objid=mlink.mid" |
|
08db9e1…
|
drh
|
1764 |
" AND a.rid=mlink.fid" |
|
08db9e1…
|
drh
|
1765 |
" AND b.rid=mlink.mid" |
|
49402fc…
|
drh
|
1766 |
" AND mlink.fid=%d" |
|
fff43eb…
|
drh
|
1767 |
" ORDER BY filename.name, event.mtime /*sort*/", |
|
49402fc…
|
drh
|
1768 |
TAG_BRANCH, rid |
|
08db9e1…
|
drh
|
1769 |
); |
|
49402fc…
|
drh
|
1770 |
@ <ul> |
|
08db9e1…
|
drh
|
1771 |
while( db_step(&q)==SQLITE_ROW ){ |
|
08db9e1…
|
drh
|
1772 |
const char *zName = db_column_text(&q, 0); |
|
08db9e1…
|
drh
|
1773 |
const char *zDate = db_column_text(&q, 1); |
|
ee544f4…
|
drh
|
1774 |
const char *zCom = db_column_text(&q, 2); |
|
ee544f4…
|
drh
|
1775 |
const char *zUser = db_column_text(&q, 3); |
|
ee544f4…
|
drh
|
1776 |
const char *zVers = db_column_text(&q, 4); |
|
e4f1c1f…
|
drh
|
1777 |
int mPerm = db_column_int(&q, 5); |
|
e4f1c1f…
|
drh
|
1778 |
const char *zBr = db_column_text(&q, 6); |
|
4c26899…
|
drh
|
1779 |
int szFile = db_column_int(&q,7); |
|
0ac4cea…
|
drh
|
1780 |
int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0; |
|
2b07e4e…
|
drh
|
1781 |
if( zFileName && fossil_strcmp(zName,zFileName)!=0 ) continue; |
|
3c2d418…
|
drh
|
1782 |
if( sameFilename && !showDetail ){ |
|
3c2d418…
|
drh
|
1783 |
if( cnt==1 ){ |
|
1fee037…
|
drh
|
1784 |
@ %z(href("%R/whatis/%!S",zUuid))[more...]</a> |
|
3c2d418…
|
drh
|
1785 |
} |
|
3c2d418…
|
drh
|
1786 |
cnt++; |
|
3c2d418…
|
drh
|
1787 |
continue; |
|
3c2d418…
|
drh
|
1788 |
} |
|
0ac4cea…
|
drh
|
1789 |
if( !sameFilename ){ |
|
ca30907…
|
drh
|
1790 |
if( prevName && showDetail ) { |
|
49402fc…
|
drh
|
1791 |
@ </ul> |
|
49402fc…
|
drh
|
1792 |
} |
|
e4f1c1f…
|
drh
|
1793 |
if( mPerm==PERM_LNK ){ |
|
e4f1c1f…
|
drh
|
1794 |
@ <li>Symbolic link |
|
ba418ee…
|
drh
|
1795 |
objType |= OBJTYPE_SYMLINK; |
|
e4f1c1f…
|
drh
|
1796 |
}else if( mPerm==PERM_EXE ){ |
|
e4f1c1f…
|
drh
|
1797 |
@ <li>Executable file |
|
ba418ee…
|
drh
|
1798 |
objType |= OBJTYPE_EXE; |
|
433cde1…
|
drh
|
1799 |
}else{ |
|
01050d6…
|
jan.nijtmans
|
1800 |
@ <li>File |
|
8af35d3…
|
drh
|
1801 |
if( bNeedBase ){ |
|
8af35d3…
|
drh
|
1802 |
bNeedBase = 0; |
|
8af35d3…
|
drh
|
1803 |
style_set_current_page("doc/%S/%s",zVers,zName); |
|
8af35d3…
|
drh
|
1804 |
} |
|
433cde1…
|
drh
|
1805 |
} |
|
ba418ee…
|
drh
|
1806 |
objType |= OBJTYPE_CONTENT; |
|
b54d939…
|
drh
|
1807 |
@ %z(href("%R/finfo?name=%T&ci=%!S&m=%!S",zName,zVers,zUuid))\ |
|
b54d939…
|
drh
|
1808 |
@ %h(zName)</a> |
|
a81a47f…
|
drh
|
1809 |
tag_private_status(rid); |
|
3c2d418…
|
drh
|
1810 |
if( showDetail ){ |
|
0ac4cea…
|
drh
|
1811 |
@ <ul> |
|
0ac4cea…
|
drh
|
1812 |
} |
|
49402fc…
|
drh
|
1813 |
prevName = fossil_strdup(zName); |
|
49402fc…
|
drh
|
1814 |
} |
|
3c2d418…
|
drh
|
1815 |
if( showDetail ){ |
|
0ac4cea…
|
drh
|
1816 |
@ <li> |
|
0ac4cea…
|
drh
|
1817 |
hyperlink_to_date(zDate,""); |
|
6ec2c2e…
|
mistachkin
|
1818 |
@ — part of check-in |
|
8ad5e46…
|
wyoung
|
1819 |
hyperlink_to_version(zVers); |
|
3c2d418…
|
drh
|
1820 |
}else{ |
|
6ec2c2e…
|
mistachkin
|
1821 |
@ — part of check-in |
|
8ad5e46…
|
wyoung
|
1822 |
hyperlink_to_version(zVers); |
|
3c2d418…
|
drh
|
1823 |
@ at |
|
3c2d418…
|
drh
|
1824 |
hyperlink_to_date(zDate,""); |
|
0ac4cea…
|
drh
|
1825 |
} |
|
49402fc…
|
drh
|
1826 |
if( zBr && zBr[0] ){ |
|
433cde1…
|
drh
|
1827 |
@ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a> |
|
433cde1…
|
drh
|
1828 |
} |
|
3b92154…
|
drh
|
1829 |
@ — %!W(zCom) (user: |
|
4c26899…
|
drh
|
1830 |
hyperlink_to_user(zUser,zDate,","); |
|
4c26899…
|
drh
|
1831 |
@ size: %d(szFile)) |
|
433cde1…
|
drh
|
1832 |
if( g.perm.Hyperlink ){ |
|
1fee037…
|
drh
|
1833 |
@ %z(href("%R/annotate?filename=%T&checkin=%!S",zName,zVers)) |
|
030a048…
|
drh
|
1834 |
@ [annotate]</a> |
|
1fee037…
|
drh
|
1835 |
@ %z(href("%R/blame?filename=%T&checkin=%!S",zName,zVers)) |
|
d7160dc…
|
jan.nijtmans
|
1836 |
@ [blame]</a> |
|
dffcebe…
|
drh
|
1837 |
@ %z(href("%R/timeline?uf=%!S",zUuid))[check-ins using]</a> |
|
1243bf3…
|
stephan
|
1838 |
if( fileedit_is_editable(zName) ){ |
|
1243bf3…
|
stephan
|
1839 |
@ %z(href("%R/fileedit?filename=%T&checkin=%!S",zName,zVers))[edit]</a> |
|
1243bf3…
|
stephan
|
1840 |
} |
|
030a048…
|
drh
|
1841 |
} |
|
08db9e1…
|
drh
|
1842 |
cnt++; |
|
923d644…
|
drh
|
1843 |
if( pDownloadName && blob_size(pDownloadName)==0 ){ |
|
923d644…
|
drh
|
1844 |
blob_append(pDownloadName, zName, -1); |
|
923d644…
|
drh
|
1845 |
} |
|
08db9e1…
|
drh
|
1846 |
} |
|
3c2d418…
|
drh
|
1847 |
if( prevName && showDetail ){ |
|
7e609e0…
|
drh
|
1848 |
@ </ul> |
|
7e609e0…
|
drh
|
1849 |
} |
|
4f8c897…
|
drh
|
1850 |
@ </ul> |
|
49402fc…
|
drh
|
1851 |
free(prevName); |
|
08db9e1…
|
drh
|
1852 |
db_finalize(&q); |
|
01050d6…
|
jan.nijtmans
|
1853 |
db_prepare(&q, |
|
e7192bb…
|
andygoth
|
1854 |
"SELECT substr(tagname, 6, 10000), datetime(event.mtime, toLocal())," |
|
ee544f4…
|
drh
|
1855 |
" coalesce(event.euser, event.user)" |
|
ee544f4…
|
drh
|
1856 |
" FROM tagxref, tag, event" |
|
08db9e1…
|
drh
|
1857 |
" WHERE tagxref.rid=%d" |
|
01050d6…
|
jan.nijtmans
|
1858 |
" AND tag.tagid=tagxref.tagid" |
|
08db9e1…
|
drh
|
1859 |
" AND tag.tagname LIKE 'wiki-%%'" |
|
ee544f4…
|
drh
|
1860 |
" AND event.objid=tagxref.rid", |
|
d0305b3…
|
aku
|
1861 |
rid |
|
d0305b3…
|
aku
|
1862 |
); |
|
d0305b3…
|
aku
|
1863 |
while( db_step(&q)==SQLITE_ROW ){ |
|
d0305b3…
|
aku
|
1864 |
const char *zPagename = db_column_text(&q, 0); |
|
d0305b3…
|
aku
|
1865 |
const char *zDate = db_column_text(&q, 1); |
|
d0305b3…
|
aku
|
1866 |
const char *zUser = db_column_text(&q, 2); |
|
d14adf1…
|
kejoki
|
1867 |
if( cnt>0 ){ |
|
d14adf1…
|
kejoki
|
1868 |
@ Also wiki page |
|
d14adf1…
|
kejoki
|
1869 |
}else{ |
|
d14adf1…
|
kejoki
|
1870 |
@ Wiki page |
|
d14adf1…
|
kejoki
|
1871 |
} |
|
ba418ee…
|
drh
|
1872 |
objType |= OBJTYPE_WIKI; |
|
433cde1…
|
drh
|
1873 |
@ [%z(href("%R/wiki?name=%t",zPagename))%h(zPagename)</a>] by |
|
b5f4f91…
|
drh
|
1874 |
hyperlink_to_user(zUser,zDate," on"); |
|
b5f4f91…
|
drh
|
1875 |
hyperlink_to_date(zDate,"."); |
|
d0305b3…
|
aku
|
1876 |
nWiki++; |
|
d0305b3…
|
aku
|
1877 |
cnt++; |
|
923d644…
|
drh
|
1878 |
if( pDownloadName && blob_size(pDownloadName)==0 ){ |
|
ba418ee…
|
drh
|
1879 |
blob_appendf(pDownloadName, "%s.txt", zPagename); |
|
923d644…
|
drh
|
1880 |
} |
|
d0305b3…
|
aku
|
1881 |
} |
|
d0305b3…
|
aku
|
1882 |
db_finalize(&q); |
|
d0305b3…
|
aku
|
1883 |
if( nWiki==0 ){ |
|
d0305b3…
|
aku
|
1884 |
db_prepare(&q, |
|
e7192bb…
|
andygoth
|
1885 |
"SELECT datetime(mtime, toLocal()), user, comment, type, uuid, tagid" |
|
d0305b3…
|
aku
|
1886 |
" FROM event, blob" |
|
d0305b3…
|
aku
|
1887 |
" WHERE event.objid=%d" |
|
d0305b3…
|
aku
|
1888 |
" AND blob.rid=%d", |
|
d0305b3…
|
aku
|
1889 |
rid, rid |
|
d0305b3…
|
aku
|
1890 |
); |
|
d0305b3…
|
aku
|
1891 |
while( db_step(&q)==SQLITE_ROW ){ |
|
d0305b3…
|
aku
|
1892 |
const char *zDate = db_column_text(&q, 0); |
|
d0305b3…
|
aku
|
1893 |
const char *zUser = db_column_text(&q, 1); |
|
d0305b3…
|
aku
|
1894 |
const char *zCom = db_column_text(&q, 2); |
|
ee544f4…
|
drh
|
1895 |
const char *zType = db_column_text(&q, 3); |
|
ee544f4…
|
drh
|
1896 |
const char *zUuid = db_column_text(&q, 4); |
|
05cd9fa…
|
rberteig
|
1897 |
int eventTagId = db_column_int(&q, 5); |
|
d14adf1…
|
kejoki
|
1898 |
if( cnt>0 ){ |
|
d14adf1…
|
kejoki
|
1899 |
@ Also |
|
d14adf1…
|
kejoki
|
1900 |
} |
|
588bb7c…
|
aku
|
1901 |
if( zType[0]=='w' ){ |
|
588bb7c…
|
aku
|
1902 |
@ Wiki edit |
|
ba418ee…
|
drh
|
1903 |
objType |= OBJTYPE_WIKI; |
|
588bb7c…
|
aku
|
1904 |
}else if( zType[0]=='t' ){ |
|
588bb7c…
|
aku
|
1905 |
@ Ticket change |
|
ba418ee…
|
drh
|
1906 |
objType |= OBJTYPE_TICKET; |
|
588bb7c…
|
aku
|
1907 |
}else if( zType[0]=='c' ){ |
|
b5f4f91…
|
drh
|
1908 |
@ Manifest of check-in |
|
ba418ee…
|
drh
|
1909 |
objType |= OBJTYPE_CHECKIN; |
|
d96c4a4…
|
drh
|
1910 |
}else if( zType[0]=='e' ){ |
|
05cd9fa…
|
rberteig
|
1911 |
if( eventTagId != 0) { |
|
05cd9fa…
|
rberteig
|
1912 |
@ Instance of technote |
|
05cd9fa…
|
rberteig
|
1913 |
objType |= OBJTYPE_EVENT; |
|
05cd9fa…
|
rberteig
|
1914 |
hyperlink_to_event_tagid(db_column_int(&q, 5)); |
|
05cd9fa…
|
rberteig
|
1915 |
}else{ |
|
bd559ff…
|
jan.nijtmans
|
1916 |
@ Attachment to technote |
|
05cd9fa…
|
rberteig
|
1917 |
} |
|
99fcc43…
|
drh
|
1918 |
}else if( zType[0]=='f' ){ |
|
99fcc43…
|
drh
|
1919 |
objType |= OBJTYPE_FORUM; |
|
99fcc43…
|
drh
|
1920 |
@ Forum post |
|
588bb7c…
|
aku
|
1921 |
}else{ |
|
8b2d32c…
|
drh
|
1922 |
@ Tag referencing |
|
d96c4a4…
|
drh
|
1923 |
} |
|
05cd9fa…
|
rberteig
|
1924 |
if( zType[0]!='e' || eventTagId == 0){ |
|
8ad5e46…
|
wyoung
|
1925 |
hyperlink_to_version(zUuid); |
|
923d644…
|
drh
|
1926 |
} |
|
3b92154…
|
drh
|
1927 |
@ - %!W(zCom) by |
|
b5f4f91…
|
drh
|
1928 |
hyperlink_to_user(zUser,zDate," on"); |
|
b5f4f91…
|
drh
|
1929 |
hyperlink_to_date(zDate, "."); |
|
923d644…
|
drh
|
1930 |
if( pDownloadName && blob_size(pDownloadName)==0 ){ |
|
c62e94f…
|
jan.nijtmans
|
1931 |
blob_appendf(pDownloadName, "%S.txt", zUuid); |
|
588bb7c…
|
aku
|
1932 |
} |
|
a81a47f…
|
drh
|
1933 |
tag_private_status(rid); |
|
d0305b3…
|
aku
|
1934 |
cnt++; |
|
d0305b3…
|
aku
|
1935 |
} |
|
d0305b3…
|
aku
|
1936 |
db_finalize(&q); |
|
d0305b3…
|
aku
|
1937 |
} |
|
01050d6…
|
jan.nijtmans
|
1938 |
db_prepare(&q, |
|
e7192bb…
|
andygoth
|
1939 |
"SELECT target, filename, datetime(mtime, toLocal()), user, src" |
|
7c2577b…
|
drh
|
1940 |
" FROM attachment" |
|
7c2577b…
|
drh
|
1941 |
" WHERE src=(SELECT uuid FROM blob WHERE rid=%d)" |
|
96722b6…
|
drh
|
1942 |
" ORDER BY mtime DESC /*sort*/", |
|
7c2577b…
|
drh
|
1943 |
rid |
|
7c2577b…
|
drh
|
1944 |
); |
|
7c2577b…
|
drh
|
1945 |
while( db_step(&q)==SQLITE_ROW ){ |
|
7c2577b…
|
drh
|
1946 |
const char *zTarget = db_column_text(&q, 0); |
|
7c2577b…
|
drh
|
1947 |
const char *zFilename = db_column_text(&q, 1); |
|
7c2577b…
|
drh
|
1948 |
const char *zDate = db_column_text(&q, 2); |
|
7c2577b…
|
drh
|
1949 |
const char *zUser = db_column_text(&q, 3); |
|
6454153…
|
drh
|
1950 |
/* const char *zSrc = db_column_text(&q, 4); */ |
|
7c2577b…
|
drh
|
1951 |
if( cnt>0 ){ |
|
7c2577b…
|
drh
|
1952 |
@ Also attachment "%h(zFilename)" to |
|
7c2577b…
|
drh
|
1953 |
}else{ |
|
7c2577b…
|
drh
|
1954 |
@ Attachment "%h(zFilename)" to |
|
7c2577b…
|
drh
|
1955 |
} |
|
ba418ee…
|
drh
|
1956 |
objType |= OBJTYPE_ATTACHMENT; |
|
ca90659…
|
stephan
|
1957 |
switch( attachment_target_type(zTarget, 1) ){ |
|
5079ffb…
|
stephan
|
1958 |
case CFTYPE_FORUM: |
|
5079ffb…
|
stephan
|
1959 |
if( g.perm.Hyperlink && g.anon.RdForum ){ |
|
5079ffb…
|
stephan
|
1960 |
@ forum post [%z(href("%R/forumpost/%!S",zTarget))%S(zTarget)</a>] |
|
5079ffb…
|
stephan
|
1961 |
}else{ |
|
5079ffb…
|
stephan
|
1962 |
@ forum post [%S(zTarget)] |
|
5079ffb…
|
stephan
|
1963 |
} |
|
5079ffb…
|
stephan
|
1964 |
break; |
|
5079ffb…
|
stephan
|
1965 |
case CFTYPE_TICKET: |
|
05cd9fa…
|
rberteig
|
1966 |
if( g.perm.Hyperlink && g.anon.RdTkt ){ |
|
05cd9fa…
|
rberteig
|
1967 |
@ ticket [%z(href("%R/tktview?name=%!S",zTarget))%S(zTarget)</a>] |
|
05cd9fa…
|
rberteig
|
1968 |
}else{ |
|
05cd9fa…
|
rberteig
|
1969 |
@ ticket [%S(zTarget)] |
|
05cd9fa…
|
rberteig
|
1970 |
} |
|
5079ffb…
|
stephan
|
1971 |
break; |
|
5079ffb…
|
stephan
|
1972 |
case CFTYPE_EVENT: |
|
05cd9fa…
|
rberteig
|
1973 |
if( g.perm.Hyperlink && g.anon.RdWiki ){ |
|
05cd9fa…
|
rberteig
|
1974 |
@ tech note [%z(href("%R/technote/%h",zTarget))%S(zTarget)</a>] |
|
05cd9fa…
|
rberteig
|
1975 |
}else{ |
|
05cd9fa…
|
rberteig
|
1976 |
@ tech note [%S(zTarget)] |
|
05cd9fa…
|
rberteig
|
1977 |
} |
|
5079ffb…
|
stephan
|
1978 |
break; |
|
5079ffb…
|
stephan
|
1979 |
case CFTYPE_WIKI: |
|
05cd9fa…
|
rberteig
|
1980 |
if( g.perm.Hyperlink && g.anon.RdWiki ){ |
|
05cd9fa…
|
rberteig
|
1981 |
@ wiki page [%z(href("%R/wiki?name=%t",zTarget))%h(zTarget)</a>] |
|
05cd9fa…
|
rberteig
|
1982 |
}else{ |
|
05cd9fa…
|
rberteig
|
1983 |
@ wiki page [%h(zTarget)] |
|
05cd9fa…
|
rberteig
|
1984 |
} |
|
ca90659…
|
stephan
|
1985 |
break; |
|
ca90659…
|
stephan
|
1986 |
default: |
|
ca90659…
|
stephan
|
1987 |
/* historical behavior is to assume wiki, but we can end up |
|
ca90659…
|
stephan
|
1988 |
** showing bogus links that way to stale attachments. */ |
|
ca90659…
|
stephan
|
1989 |
@ unknown artifact %h(zTarget) |
|
7c2577b…
|
drh
|
1990 |
} |
|
7c2577b…
|
drh
|
1991 |
@ added by |
|
7c2577b…
|
drh
|
1992 |
hyperlink_to_user(zUser,zDate," on"); |
|
7c2577b…
|
drh
|
1993 |
hyperlink_to_date(zDate,"."); |
|
7c2577b…
|
drh
|
1994 |
cnt++; |
|
7c2577b…
|
drh
|
1995 |
if( pDownloadName && blob_size(pDownloadName)==0 ){ |
|
6454153…
|
drh
|
1996 |
blob_append(pDownloadName, zFilename, -1); |
|
7c2577b…
|
drh
|
1997 |
} |
|
a81a47f…
|
drh
|
1998 |
tag_private_status(rid); |
|
7c2577b…
|
drh
|
1999 |
} |
|
7c2577b…
|
drh
|
2000 |
db_finalize(&q); |
|
8b2d32c…
|
drh
|
2001 |
if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d", |
|
8b2d32c…
|
drh
|
2002 |
rid, TAG_CLUSTER) ){ |
|
4170e0b…
|
drh
|
2003 |
@ Cluster %z(href("%R/info/%S",zUuid))%S(zUuid)</a>. |
|
8b2d32c…
|
drh
|
2004 |
cnt++; |
|
8b2d32c…
|
drh
|
2005 |
} |
|
d0305b3…
|
aku
|
2006 |
if( cnt==0 ){ |
|
8b2d32c…
|
drh
|
2007 |
@ Unrecognized artifact |
|
923d644…
|
drh
|
2008 |
if( pDownloadName && blob_size(pDownloadName)==0 ){ |
|
c62e94f…
|
jan.nijtmans
|
2009 |
blob_appendf(pDownloadName, "%S.txt", zUuid); |
|
923d644…
|
drh
|
2010 |
} |
|
a81a47f…
|
drh
|
2011 |
tag_private_status(rid); |
|
d0305b3…
|
aku
|
2012 |
} |
|
ba418ee…
|
drh
|
2013 |
return objType; |
|
29bab27…
|
drh
|
2014 |
} |
|
29bab27…
|
drh
|
2015 |
|
|
29bab27…
|
drh
|
2016 |
/* |
|
29bab27…
|
drh
|
2017 |
** SETTING: preferred-diff-type width=16 default=0 |
|
29bab27…
|
drh
|
2018 |
** |
|
aac9093…
|
drh
|
2019 |
** The preferred-diff-type setting determines the preferred diff format |
|
aac9093…
|
drh
|
2020 |
** for web pages if the format is not otherwise specified, for example |
|
aac9093…
|
drh
|
2021 |
** by a query parameter or cookie. Allowed values: |
|
aac9093…
|
drh
|
2022 |
** |
|
aac9093…
|
drh
|
2023 |
** 1 Unified diff |
|
aac9093…
|
drh
|
2024 |
** 2 Side-by-side diff |
|
aac9093…
|
drh
|
2025 |
** |
|
aac9093…
|
drh
|
2026 |
** If this setting is omitted or has a value of 0 or less, then it |
|
aac9093…
|
drh
|
2027 |
** is ignored. |
|
29bab27…
|
drh
|
2028 |
*/ |
|
29bab27…
|
drh
|
2029 |
/* |
|
29bab27…
|
drh
|
2030 |
** Return the preferred diff type. |
|
29bab27…
|
drh
|
2031 |
** |
|
29bab27…
|
drh
|
2032 |
** 0 = No diff at all. |
|
29bab27…
|
drh
|
2033 |
** 1 = unified diff |
|
29bab27…
|
drh
|
2034 |
** 2 = side-by-side diff |
|
29bab27…
|
drh
|
2035 |
** |
|
29bab27…
|
drh
|
2036 |
** To determine the preferred diff type, the following values are |
|
29bab27…
|
drh
|
2037 |
** consulted in the order shown. The first available source wins. |
|
29bab27…
|
drh
|
2038 |
** |
|
29bab27…
|
drh
|
2039 |
** * The "diff" query parameter |
|
29bab27…
|
drh
|
2040 |
** * The "diff" field of the user display cookie |
|
29bab27…
|
drh
|
2041 |
** * The "preferred-diff-type" setting |
|
29bab27…
|
drh
|
2042 |
** * 1 for mobile and 2 for desktop, based on the UserAgent |
|
29bab27…
|
drh
|
2043 |
*/ |
|
29bab27…
|
drh
|
2044 |
int preferred_diff_type(void){ |
|
29bab27…
|
drh
|
2045 |
int dflt; |
|
3710202…
|
drh
|
2046 |
int res; |
|
3710202…
|
drh
|
2047 |
int isBot; |
|
e378f93…
|
stephan
|
2048 |
static char zDflt[2] |
|
e378f93…
|
stephan
|
2049 |
/*static b/c cookie_link_parameter() does not copy it!*/; |
|
6ce705b…
|
drh
|
2050 |
if( robot_would_be_restricted("diff") ){ |
|
3710202…
|
drh
|
2051 |
dflt = 0; |
|
3710202…
|
drh
|
2052 |
isBot = 1; |
|
3710202…
|
drh
|
2053 |
}else{ |
|
3710202…
|
drh
|
2054 |
dflt = db_get_int("preferred-diff-type",-99); |
|
3710202…
|
drh
|
2055 |
if( dflt<=0 ) dflt = user_agent_is_likely_mobile() ? 1 : 2; |
|
3710202…
|
drh
|
2056 |
isBot = 0; |
|
3710202…
|
drh
|
2057 |
} |
|
29bab27…
|
drh
|
2058 |
zDflt[0] = dflt + '0'; |
|
29bab27…
|
drh
|
2059 |
zDflt[1] = 0; |
|
29bab27…
|
drh
|
2060 |
cookie_link_parameter("diff","diff", zDflt); |
|
3710202…
|
drh
|
2061 |
res = atoi(PD_NoBot("diff",zDflt)); |
|
3710202…
|
drh
|
2062 |
if( isBot && res>0 && robot_restrict("diff") ){ |
|
3710202…
|
drh
|
2063 |
cgi_reply(); |
|
3710202…
|
drh
|
2064 |
fossil_exit(0); |
|
3710202…
|
drh
|
2065 |
} |
|
3710202…
|
drh
|
2066 |
return res; |
|
8ad5e46…
|
wyoung
|
2067 |
} |
|
8ad5e46…
|
wyoung
|
2068 |
|
|
9df32e2…
|
drh
|
2069 |
|
|
9df32e2…
|
drh
|
2070 |
/* |
|
1a9c6db…
|
drh
|
2071 |
** WEBPAGE: fdiff |
|
8ad5e46…
|
wyoung
|
2072 |
** URL: fdiff?v1=HASH&v2=HASH |
|
1949764…
|
drh
|
2073 |
** |
|
1949764…
|
drh
|
2074 |
** Two arguments, v1 and v2, identify the artifacts to be diffed. |
|
1949764…
|
drh
|
2075 |
** Show diff side by side unless sbs is 0. Generate plain text if |
|
1949764…
|
drh
|
2076 |
** "patch" is present, otherwise generate "pretty" HTML. |
|
1949764…
|
drh
|
2077 |
** |
|
1949764…
|
drh
|
2078 |
** Alternative URL: fdiff?from=filename1&to=filename2&ci=checkin |
|
0ac4cea…
|
drh
|
2079 |
** |
|
1949764…
|
drh
|
2080 |
** If the "from" and "to" query parameters are both present, then they are |
|
1949764…
|
drh
|
2081 |
** the names of two files within the check-in "ci" that are diffed. If the |
|
1949764…
|
drh
|
2082 |
** "ci" parameter is omitted, then the most recent check-in ("tip") is |
|
1949764…
|
drh
|
2083 |
** used. |
|
0ac4cea…
|
drh
|
2084 |
** |
|
0ac4cea…
|
drh
|
2085 |
** Additional parameters: |
|
588bb7c…
|
aku
|
2086 |
** |
|
ab8ed31…
|
drh
|
2087 |
** dc=N Show N lines of context around each diff |
|
ab8ed31…
|
drh
|
2088 |
** patch Use the patch diff format |
|
ab8ed31…
|
drh
|
2089 |
** regex=REGEX Only show differences that match REGEX |
|
ab8ed31…
|
drh
|
2090 |
** sbs=BOOLEAN Turn side-by-side diffs on and off (default: on) |
|
ab8ed31…
|
drh
|
2091 |
** verbose=BOOLEAN Show more detail when describing artifacts |
|
ab8ed31…
|
drh
|
2092 |
** w=BOOLEAN Ignore whitespace |
|
588bb7c…
|
aku
|
2093 |
*/ |
|
588bb7c…
|
aku
|
2094 |
void diff_page(void){ |
|
1d713f3…
|
drh
|
2095 |
int v1, v2; |
|
ab8ed31…
|
drh
|
2096 |
int isPatch = P("patch")!=0; |
|
0a1f4ed…
|
drh
|
2097 |
int diffType; /* 0: none, 1: unified, 2: side-by-side */ |
|
9a63d1f…
|
drh
|
2098 |
char *zV1; |
|
9a63d1f…
|
drh
|
2099 |
char *zV2; |
|
31dd2c0…
|
drh
|
2100 |
const char *zRe; |
|
31dd2c0…
|
drh
|
2101 |
ReCompiled *pRe = 0; |
|
0ac4cea…
|
drh
|
2102 |
u32 objdescFlags = 0; |
|
0a1f4ed…
|
drh
|
2103 |
int verbose = PB("verbose"); |
|
1347a1d…
|
drh
|
2104 |
DiffConfig DCfg; |
|
588bb7c…
|
aku
|
2105 |
|
|
588bb7c…
|
aku
|
2106 |
login_check_credentials(); |
|
653dd40…
|
drh
|
2107 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
16b3309…
|
drh
|
2108 |
if( robot_restrict("diff") ) return; |
|
65d97f2…
|
wyoung
|
2109 |
diff_config_init(&DCfg, 0); |
|
29bab27…
|
drh
|
2110 |
diffType = preferred_diff_type(); |
|
1949764…
|
drh
|
2111 |
if( P("from") && P("to") ){ |
|
1b5d0b0…
|
drh
|
2112 |
v1 = artifact_from_ci_and_filename("from"); |
|
1b5d0b0…
|
drh
|
2113 |
v2 = artifact_from_ci_and_filename("to"); |
|
e3c58af…
|
drh
|
2114 |
if( v1==0 || v2==0 ) fossil_redirect_home(); |
|
1949764…
|
drh
|
2115 |
}else{ |
|
f52a544…
|
drh
|
2116 |
Stmt q; |
|
1949764…
|
drh
|
2117 |
v1 = name_to_rid_www("v1"); |
|
1949764…
|
drh
|
2118 |
v2 = name_to_rid_www("v2"); |
|
e3c58af…
|
drh
|
2119 |
if( v1==0 || v2==0 ) fossil_redirect_home(); |
|
f52a544…
|
drh
|
2120 |
|
|
f52a544…
|
drh
|
2121 |
/* If the two file versions being compared both have the same |
|
f52a544…
|
drh
|
2122 |
** filename, then offer an "Annotate" link that constructs an |
|
f52a544…
|
drh
|
2123 |
** annotation between those version. */ |
|
f52a544…
|
drh
|
2124 |
db_prepare(&q, |
|
f52a544…
|
drh
|
2125 |
"SELECT (SELECT substr(uuid,1,20) FROM blob WHERE rid=a.mid)," |
|
f52a544…
|
drh
|
2126 |
" (SELECT substr(uuid,1,20) FROM blob WHERE rid=b.mid)," |
|
f52a544…
|
drh
|
2127 |
" (SELECT name FROM filename WHERE filename.fnid=a.fnid)" |
|
a9ef45e…
|
drh
|
2128 |
" FROM mlink a, event ea, mlink b, event eb" |
|
f52a544…
|
drh
|
2129 |
" WHERE a.fid=%d" |
|
f52a544…
|
drh
|
2130 |
" AND b.fid=%d" |
|
f52a544…
|
drh
|
2131 |
" AND a.fnid=b.fnid" |
|
f52a544…
|
drh
|
2132 |
" AND a.fid!=a.pid" |
|
a9ef45e…
|
drh
|
2133 |
" AND b.fid!=b.pid" |
|
a9ef45e…
|
drh
|
2134 |
" AND ea.objid=a.mid" |
|
a9ef45e…
|
drh
|
2135 |
" AND eb.objid=b.mid" |
|
a9ef45e…
|
drh
|
2136 |
" ORDER BY ea.mtime ASC, eb.mtime ASC", |
|
f52a544…
|
drh
|
2137 |
v1, v2 |
|
f52a544…
|
drh
|
2138 |
); |
|
f52a544…
|
drh
|
2139 |
if( db_step(&q)==SQLITE_ROW ){ |
|
08cacbf…
|
drh
|
2140 |
const char *zCkin = db_column_text(&q, 0); |
|
08cacbf…
|
drh
|
2141 |
const char *zOrig = db_column_text(&q, 1); |
|
f52a544…
|
drh
|
2142 |
const char *zFN = db_column_text(&q, 2); |
|
f52a544…
|
drh
|
2143 |
style_submenu_element("Annotate", |
|
f52a544…
|
drh
|
2144 |
"%R/annotate?origin=%s&checkin=%s&filename=%T", |
|
f52a544…
|
drh
|
2145 |
zOrig, zCkin, zFN); |
|
f52a544…
|
drh
|
2146 |
} |
|
f52a544…
|
drh
|
2147 |
db_finalize(&q); |
|
1949764…
|
drh
|
2148 |
} |
|
31dd2c0…
|
drh
|
2149 |
zRe = P("regex"); |
|
57f1e87…
|
drh
|
2150 |
cgi_check_for_malice(); |
|
82888a0…
|
drh
|
2151 |
if( zRe ) fossil_re_compile(&pRe, zRe, 0); |
|
ab8ed31…
|
drh
|
2152 |
if( verbose ) objdescFlags |= OBJDESC_DETAIL; |
|
d70ea7e…
|
drh
|
2153 |
if( isPatch ){ |
|
d70ea7e…
|
drh
|
2154 |
Blob c1, c2, *pOut; |
|
1347a1d…
|
drh
|
2155 |
DiffConfig DCfg; |
|
d70ea7e…
|
drh
|
2156 |
pOut = cgi_output_blob(); |
|
d70ea7e…
|
drh
|
2157 |
cgi_set_content_type("text/plain"); |
|
65d97f2…
|
wyoung
|
2158 |
DCfg.diffFlags = DIFF_VERBOSE; |
|
d70ea7e…
|
drh
|
2159 |
content_get(v1, &c1); |
|
d70ea7e…
|
drh
|
2160 |
content_get(v2, &c2); |
|
1347a1d…
|
drh
|
2161 |
DCfg.pRe = pRe; |
|
1347a1d…
|
drh
|
2162 |
text_diff(&c1, &c2, pOut, &DCfg); |
|
d70ea7e…
|
drh
|
2163 |
blob_reset(&c1); |
|
d70ea7e…
|
drh
|
2164 |
blob_reset(&c2); |
|
d70ea7e…
|
drh
|
2165 |
return; |
|
d70ea7e…
|
drh
|
2166 |
} |
|
3e18dbe…
|
jan.nijtmans
|
2167 |
|
|
d70ea7e…
|
drh
|
2168 |
zV1 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v1); |
|
d70ea7e…
|
drh
|
2169 |
zV2 = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", v2); |
|
1347a1d…
|
drh
|
2170 |
construct_diff_flags(diffType, &DCfg); |
|
1347a1d…
|
drh
|
2171 |
DCfg.diffFlags |= DIFF_HTML; |
|
d70ea7e…
|
drh
|
2172 |
|
|
112c713…
|
drh
|
2173 |
style_set_current_feature("fdiff"); |
|
d70ea7e…
|
drh
|
2174 |
style_header("Diff"); |
|
037e06b…
|
drh
|
2175 |
style_submenu_checkbox("w", "Ignore Whitespace", 0, 0); |
|
0a1f4ed…
|
drh
|
2176 |
if( diffType==2 ){ |
|
0a1f4ed…
|
drh
|
2177 |
style_submenu_element("Unified Diff", "%R/fdiff?v1=%T&v2=%T&diff=1", |
|
0a1f4ed…
|
drh
|
2178 |
P("v1"), P("v2")); |
|
0a1f4ed…
|
drh
|
2179 |
}else{ |
|
0a1f4ed…
|
drh
|
2180 |
style_submenu_element("Side-by-side Diff", "%R/fdiff?v1=%T&v2=%T&diff=2", |
|
0a1f4ed…
|
drh
|
2181 |
P("v1"), P("v2")); |
|
0a1f4ed…
|
drh
|
2182 |
} |
|
037e06b…
|
drh
|
2183 |
style_submenu_checkbox("verbose", "Verbose", 0, 0); |
|
0a1f4ed…
|
drh
|
2184 |
style_submenu_element("Patch", "%R/fdiff?v1=%T&v2=%T&patch", |
|
0a1f4ed…
|
drh
|
2185 |
P("v1"), P("v2")); |
|
d70ea7e…
|
drh
|
2186 |
|
|
d70ea7e…
|
drh
|
2187 |
if( P("smhdr")!=0 ){ |
|
d70ea7e…
|
drh
|
2188 |
@ <h2>Differences From Artifact |
|
1fee037…
|
drh
|
2189 |
@ %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a> To |
|
1fee037…
|
drh
|
2190 |
@ %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>.</h2> |
|
d70ea7e…
|
drh
|
2191 |
}else{ |
|
d70ea7e…
|
drh
|
2192 |
@ <h2>Differences From |
|
1fee037…
|
drh
|
2193 |
@ Artifact %z(href("%R/artifact/%!S",zV1))[%S(zV1)]</a>:</h2> |
|
2b07e4e…
|
drh
|
2194 |
object_description(v1, objdescFlags,0, 0); |
|
1fee037…
|
drh
|
2195 |
@ <h2>To Artifact %z(href("%R/artifact/%!S",zV2))[%S(zV2)]</a>:</h2> |
|
2b07e4e…
|
drh
|
2196 |
object_description(v2, objdescFlags,0, 0); |
|
d70ea7e…
|
drh
|
2197 |
} |
|
d70ea7e…
|
drh
|
2198 |
if( pRe ){ |
|
d70ea7e…
|
drh
|
2199 |
@ <b>Only differences that match regular expression "%h(zRe)" |
|
d70ea7e…
|
drh
|
2200 |
@ are shown.</b> |
|
1347a1d…
|
drh
|
2201 |
DCfg.pRe = pRe; |
|
d70ea7e…
|
drh
|
2202 |
} |
|
f5482a0…
|
wyoung
|
2203 |
@ <hr> |
|
1347a1d…
|
drh
|
2204 |
append_diff(zV1, zV2, &DCfg); |
|
0a1f4ed…
|
drh
|
2205 |
append_diff_javascript(diffType); |
|
112c713…
|
drh
|
2206 |
style_finish_page(); |
|
d14adf1…
|
kejoki
|
2207 |
} |
|
d14adf1…
|
kejoki
|
2208 |
|
|
d14adf1…
|
kejoki
|
2209 |
/* |
|
d14adf1…
|
kejoki
|
2210 |
** WEBPAGE: raw |
|
34cb476…
|
drh
|
2211 |
** URL: /raw/ARTIFACTID |
|
fc29b08…
|
drh
|
2212 |
** URL: /raw?ci=BRANCH&filename=NAME |
|
34cb476…
|
drh
|
2213 |
** |
|
34cb476…
|
drh
|
2214 |
** Additional query parameters: |
|
34cb476…
|
drh
|
2215 |
** |
|
34cb476…
|
drh
|
2216 |
** m=MIMETYPE The mimetype is MIMETYPE |
|
34cb476…
|
drh
|
2217 |
** at=FILENAME Content-disposition; attachment; filename=FILENAME; |
|
01050d6…
|
jan.nijtmans
|
2218 |
** |
|
d14adf1…
|
kejoki
|
2219 |
** Return the uninterpreted content of an artifact. Used primarily |
|
d14adf1…
|
kejoki
|
2220 |
** to view artifacts that are images. |
|
d14adf1…
|
kejoki
|
2221 |
*/ |
|
d14adf1…
|
kejoki
|
2222 |
void rawartifact_page(void){ |
|
3af5165…
|
mistachkin
|
2223 |
int rid = 0; |
|
43a2d0f…
|
joel
|
2224 |
char *zUuid; |
|
96722b6…
|
drh
|
2225 |
|
|
57f1e87…
|
drh
|
2226 |
(void)P("at")/*for cgi_check_for_malice()*/; |
|
57f1e87…
|
drh
|
2227 |
(void)P("m"); |
|
1b5d0b0…
|
drh
|
2228 |
if( P("ci") ){ |
|
1b5d0b0…
|
drh
|
2229 |
rid = artifact_from_ci_and_filename(0); |
|
fc29b08…
|
drh
|
2230 |
} |
|
fc29b08…
|
drh
|
2231 |
if( rid==0 ){ |
|
fc29b08…
|
drh
|
2232 |
rid = name_to_rid_www("name"); |
|
fc29b08…
|
drh
|
2233 |
} |
|
96722b6…
|
drh
|
2234 |
login_check_credentials(); |
|
653dd40…
|
drh
|
2235 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
57f1e87…
|
drh
|
2236 |
cgi_check_for_malice(); |
|
96722b6…
|
drh
|
2237 |
if( rid==0 ) fossil_redirect_home(); |
|
43a2d0f…
|
joel
|
2238 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
70bf9a6…
|
drh
|
2239 |
etag_check(ETAG_HASH, zUuid); |
|
840b762…
|
drh
|
2240 |
if( fossil_strcmp(P("name"), zUuid)==0 && login_is_nobody() ){ |
|
43a2d0f…
|
joel
|
2241 |
g.isConst = 1; |
|
43a2d0f…
|
joel
|
2242 |
} |
|
43a2d0f…
|
joel
|
2243 |
free(zUuid); |
|
7abfca6…
|
drh
|
2244 |
deliver_artifact(rid, P("m")); |
|
7abfca6…
|
drh
|
2245 |
} |
|
7abfca6…
|
drh
|
2246 |
|
|
7abfca6…
|
drh
|
2247 |
|
|
7abfca6…
|
drh
|
2248 |
/* |
|
7abfca6…
|
drh
|
2249 |
** WEBPAGE: secureraw |
|
7abfca6…
|
drh
|
2250 |
** URL: /secureraw/HASH?m=TYPE |
|
7abfca6…
|
drh
|
2251 |
** |
|
7abfca6…
|
drh
|
2252 |
** Return the uninterpreted content of an artifact. This is similar |
|
7abfca6…
|
drh
|
2253 |
** to /raw except in this case the only way to specify the artifact |
|
7abfca6…
|
drh
|
2254 |
** is by the full-length SHA1 or SHA3 hash. Abbreviations are not |
|
7abfca6…
|
drh
|
2255 |
** accepted. |
|
7abfca6…
|
drh
|
2256 |
*/ |
|
7abfca6…
|
drh
|
2257 |
void secure_rawartifact_page(void){ |
|
7abfca6…
|
drh
|
2258 |
int rid = 0; |
|
8ad5e46…
|
wyoung
|
2259 |
const char *zName = PD("name", ""); |
|
7abfca6…
|
drh
|
2260 |
|
|
57f1e87…
|
drh
|
2261 |
(void)P("at")/*for cgi_check_for_malice()*/; |
|
57f1e87…
|
drh
|
2262 |
(void)P("m"); |
|
57f1e87…
|
drh
|
2263 |
cgi_check_for_malice(); |
|
7abfca6…
|
drh
|
2264 |
login_check_credentials(); |
|
7abfca6…
|
drh
|
2265 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
8ad5e46…
|
wyoung
|
2266 |
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName); |
|
7abfca6…
|
drh
|
2267 |
if( rid==0 ){ |
|
7abfca6…
|
drh
|
2268 |
cgi_set_status(404, "Not Found"); |
|
8ad5e46…
|
wyoung
|
2269 |
@ Unknown artifact: "%h(zName)" |
|
7abfca6…
|
drh
|
2270 |
return; |
|
7abfca6…
|
drh
|
2271 |
} |
|
7abfca6…
|
drh
|
2272 |
g.isConst = 1; |
|
7abfca6…
|
drh
|
2273 |
deliver_artifact(rid, P("m")); |
|
7abfca6…
|
drh
|
2274 |
} |
|
7abfca6…
|
drh
|
2275 |
|
|
5f7fcba…
|
drh
|
2276 |
|
|
5f7fcba…
|
drh
|
2277 |
/* |
|
51c1efd…
|
stephan
|
2278 |
** WEBPAGE: jchunk hidden |
|
51c1efd…
|
stephan
|
2279 |
** URL: /jchunk/HASH?from=N&to=M |
|
5f7fcba…
|
drh
|
2280 |
** |
|
5f7fcba…
|
drh
|
2281 |
** Return lines of text from a file as a JSON array - one entry in the |
|
5f7fcba…
|
drh
|
2282 |
** array for each line of text. |
|
5f7fcba…
|
drh
|
2283 |
** |
|
3807891…
|
drh
|
2284 |
** The HASH is normally a sha1 or sha3 hash that identifies an artifact |
|
3807891…
|
drh
|
2285 |
** in the BLOB table of the database. However, if HASH starts with an "x" |
|
3807891…
|
drh
|
2286 |
** and is followed by valid hexadecimal, and if we are running in a |
|
3807891…
|
drh
|
2287 |
** "fossil ui" situation (locally and with privilege), then decode the hex |
|
3807891…
|
drh
|
2288 |
** into a filename and read the file content from that name. |
|
3807891…
|
drh
|
2289 |
** |
|
51c1efd…
|
stephan
|
2290 |
** **Warning:** This is an internal-use-only interface that is subject to |
|
51c1efd…
|
stephan
|
2291 |
** change at any moment. External application should not use this interface |
|
51c1efd…
|
stephan
|
2292 |
** since the application will break when this interface changes, and this |
|
51c1efd…
|
stephan
|
2293 |
** interface will undoubtedly change. |
|
51c1efd…
|
stephan
|
2294 |
** |
|
51c1efd…
|
stephan
|
2295 |
** This page is intended to be used in an XHR from javascript on a |
|
51c1efd…
|
stephan
|
2296 |
** diff page, to return unseen context to fill in additional context |
|
51c1efd…
|
stephan
|
2297 |
** when the user clicks on the appropriate button. The response is |
|
51c1efd…
|
stephan
|
2298 |
** always in JSON form and errors are reported as documented for |
|
51c1efd…
|
stephan
|
2299 |
** ajax_route_error(). |
|
5f7fcba…
|
drh
|
2300 |
*/ |
|
51c1efd…
|
stephan
|
2301 |
void jchunk_page(void){ |
|
5f7fcba…
|
drh
|
2302 |
int rid = 0; |
|
5f7fcba…
|
drh
|
2303 |
const char *zName = PD("name", ""); |
|
3807891…
|
drh
|
2304 |
int nName = (int)(strlen(zName)&0x7fffffff); |
|
5f7fcba…
|
drh
|
2305 |
int iFrom = atoi(PD("from","0")); |
|
5f7fcba…
|
drh
|
2306 |
int iTo = atoi(PD("to","0")); |
|
5f7fcba…
|
drh
|
2307 |
int ln; |
|
6f5dfd9…
|
drh
|
2308 |
int go = 1; |
|
5f7fcba…
|
drh
|
2309 |
const char *zSep; |
|
5f7fcba…
|
drh
|
2310 |
Blob content; |
|
5f7fcba…
|
drh
|
2311 |
Blob line; |
|
5f7fcba…
|
drh
|
2312 |
Blob *pOut; |
|
5f7fcba…
|
drh
|
2313 |
|
|
51c1efd…
|
stephan
|
2314 |
if(0){ |
|
51c1efd…
|
stephan
|
2315 |
ajax_route_error(400, "Just testing client-side error handling."); |
|
51c1efd…
|
stephan
|
2316 |
return; |
|
51c1efd…
|
stephan
|
2317 |
} |
|
51c1efd…
|
stephan
|
2318 |
|
|
5f7fcba…
|
drh
|
2319 |
login_check_credentials(); |
|
57f1e87…
|
drh
|
2320 |
cgi_check_for_malice(); |
|
51c1efd…
|
stephan
|
2321 |
if( !g.perm.Read ){ |
|
51c1efd…
|
stephan
|
2322 |
ajax_route_error(403, "Access requires Read permissions."); |
|
5f7fcba…
|
drh
|
2323 |
return; |
|
5f7fcba…
|
drh
|
2324 |
} |
|
5f7fcba…
|
drh
|
2325 |
if( iFrom<1 || iTo<iFrom ){ |
|
51c1efd…
|
stephan
|
2326 |
ajax_route_error(500, "Invalid line range from=%d, to=%d.", |
|
51c1efd…
|
stephan
|
2327 |
iFrom, iTo); |
|
5f7fcba…
|
drh
|
2328 |
return; |
|
5f7fcba…
|
drh
|
2329 |
} |
|
3807891…
|
drh
|
2330 |
if( zName[0]=='x' |
|
3807891…
|
drh
|
2331 |
&& ((nName-1)&1)==0 |
|
3807891…
|
drh
|
2332 |
&& validate16(&zName[1],nName-1) |
|
3807891…
|
drh
|
2333 |
&& g.perm.Admin |
|
3807891…
|
drh
|
2334 |
&& cgi_is_loopback(g.zIpAddr) |
|
2dda151…
|
florian
|
2335 |
&& db_open_local(0) |
|
3807891…
|
drh
|
2336 |
){ |
|
3807891…
|
drh
|
2337 |
/* Treat the HASH as a hex-encoded filename */ |
|
3807891…
|
drh
|
2338 |
int n = (nName-1)/2; |
|
3807891…
|
drh
|
2339 |
char *zFN = fossil_malloc(n+1); |
|
3807891…
|
drh
|
2340 |
decode16((const u8*)&zName[1], (u8*)zFN, nName-1); |
|
3807891…
|
drh
|
2341 |
zFN[n] = 0; |
|
3807891…
|
drh
|
2342 |
if( file_size(zFN, ExtFILE)<0 ){ |
|
3807891…
|
drh
|
2343 |
blob_zero(&content); |
|
3807891…
|
drh
|
2344 |
}else{ |
|
3807891…
|
drh
|
2345 |
blob_read_from_file(&content, zFN, ExtFILE); |
|
3807891…
|
drh
|
2346 |
} |
|
3807891…
|
drh
|
2347 |
fossil_free(zFN); |
|
3807891…
|
drh
|
2348 |
}else{ |
|
3807891…
|
drh
|
2349 |
/* Treat the HASH as an artifact hash matching BLOB.UUID */ |
|
3807891…
|
drh
|
2350 |
#if 1 |
|
3807891…
|
drh
|
2351 |
/* Re-enable this block once this code is integrated somewhere into |
|
3807891…
|
drh
|
2352 |
the UI. */ |
|
3807891…
|
drh
|
2353 |
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName); |
|
3807891…
|
drh
|
2354 |
if( rid==0 ){ |
|
3807891…
|
drh
|
2355 |
ajax_route_error(404, "Unknown artifact: %h", zName); |
|
3807891…
|
drh
|
2356 |
return; |
|
3807891…
|
drh
|
2357 |
} |
|
3807891…
|
drh
|
2358 |
#else |
|
3807891…
|
drh
|
2359 |
/* This impl is only to simplify "manual" testing via the JS |
|
3807891…
|
drh
|
2360 |
console. */ |
|
3807891…
|
drh
|
2361 |
rid = symbolic_name_to_rid(zName, "*"); |
|
3807891…
|
drh
|
2362 |
if( rid==0 ){ |
|
3807891…
|
drh
|
2363 |
ajax_route_error(404, "Unknown artifact: %h", zName); |
|
3807891…
|
drh
|
2364 |
return; |
|
3807891…
|
drh
|
2365 |
}else if( rid<0 ){ |
|
3807891…
|
drh
|
2366 |
ajax_route_error(418, "Ambiguous artifact name: %h", zName); |
|
3807891…
|
drh
|
2367 |
return; |
|
3807891…
|
drh
|
2368 |
} |
|
3807891…
|
drh
|
2369 |
#endif |
|
3807891…
|
drh
|
2370 |
content_get(rid, &content); |
|
3807891…
|
drh
|
2371 |
} |
|
5f7fcba…
|
drh
|
2372 |
g.isConst = 1; |
|
c0714a0…
|
stephan
|
2373 |
cgi_set_content_type("application/json"); |
|
5f7fcba…
|
drh
|
2374 |
ln = 0; |
|
6f5dfd9…
|
drh
|
2375 |
while( go && ln<iFrom ){ |
|
6f5dfd9…
|
drh
|
2376 |
go = blob_line(&content, &line); |
|
5f7fcba…
|
drh
|
2377 |
ln++; |
|
5f7fcba…
|
drh
|
2378 |
} |
|
5f7fcba…
|
drh
|
2379 |
pOut = cgi_output_blob(); |
|
6f5dfd9…
|
drh
|
2380 |
blob_append(pOut, "[\n", 2); |
|
6f5dfd9…
|
drh
|
2381 |
zSep = 0; |
|
6f5dfd9…
|
drh
|
2382 |
while( go && ln<=iTo ){ |
|
6f5dfd9…
|
drh
|
2383 |
if( zSep ) blob_append(pOut, zSep, 2); |
|
5f7fcba…
|
drh
|
2384 |
blob_trim(&line); |
|
5f7fcba…
|
drh
|
2385 |
blob_append_json_literal(pOut, blob_buffer(&line), blob_size(&line)); |
|
5f7fcba…
|
drh
|
2386 |
zSep = ",\n"; |
|
6f5dfd9…
|
drh
|
2387 |
go = blob_line(&content, &line); |
|
5f7fcba…
|
drh
|
2388 |
ln++; |
|
5f7fcba…
|
drh
|
2389 |
} |
|
5f7fcba…
|
drh
|
2390 |
blob_appendf(pOut,"]\n"); |
|
5f7fcba…
|
drh
|
2391 |
blob_reset(&content); |
|
5f7fcba…
|
drh
|
2392 |
} |
|
4cb50c4…
|
stephan
|
2393 |
|
|
4cb50c4…
|
stephan
|
2394 |
/* |
|
7abfca6…
|
drh
|
2395 |
** Generate a verbatim artifact as the result of an HTTP request. |
|
4cb50c4…
|
stephan
|
2396 |
** If zMime is not NULL, use it as the mimetype. If zMime is |
|
4cb50c4…
|
stephan
|
2397 |
** NULL, guess at the mimetype based on the filename |
|
7abfca6…
|
drh
|
2398 |
** associated with the artifact. |
|
7abfca6…
|
drh
|
2399 |
*/ |
|
7abfca6…
|
drh
|
2400 |
void deliver_artifact(int rid, const char *zMime){ |
|
7abfca6…
|
drh
|
2401 |
Blob content; |
|
34cb476…
|
drh
|
2402 |
const char *zAttachName = P("at"); |
|
af16836…
|
drh
|
2403 |
if( zMime==0 ){ |
|
34cb476…
|
drh
|
2404 |
char *zFN = (char*)zAttachName; |
|
34cb476…
|
drh
|
2405 |
if( zFN==0 ){ |
|
34cb476…
|
drh
|
2406 |
zFN = db_text(0, "SELECT filename.name FROM mlink, filename" |
|
34cb476…
|
drh
|
2407 |
" WHERE mlink.fid=%d" |
|
34cb476…
|
drh
|
2408 |
" AND filename.fnid=mlink.fnid", rid); |
|
34cb476…
|
drh
|
2409 |
} |
|
34cb476…
|
drh
|
2410 |
if( zFN==0 ){ |
|
5f3916a…
|
viriketo
|
2411 |
/* Look also at the attachment table */ |
|
34cb476…
|
drh
|
2412 |
zFN = db_text(0, "SELECT attachment.filename FROM attachment, blob" |
|
34cb476…
|
drh
|
2413 |
" WHERE blob.rid=%d" |
|
34cb476…
|
drh
|
2414 |
" AND attachment.src=blob.uuid", rid); |
|
34cb476…
|
drh
|
2415 |
} |
|
34cb476…
|
drh
|
2416 |
if( zFN ){ |
|
34cb476…
|
drh
|
2417 |
zMime = mimetype_from_name(zFN); |
|
5f3916a…
|
viriketo
|
2418 |
} |
|
34cb476…
|
drh
|
2419 |
if( zMime==0 ){ |
|
34cb476…
|
drh
|
2420 |
zMime = "application/x-fossil-artifact"; |
|
34cb476…
|
drh
|
2421 |
} |
|
af16836…
|
drh
|
2422 |
} |
|
d14adf1…
|
kejoki
|
2423 |
content_get(rid, &content); |
|
14c81d9…
|
drh
|
2424 |
fossil_free(style_csp(1)); |
|
d14adf1…
|
kejoki
|
2425 |
cgi_set_content_type(zMime); |
|
34cb476…
|
drh
|
2426 |
if( zAttachName ){ |
|
34cb476…
|
drh
|
2427 |
cgi_content_disposition_filename(zAttachName); |
|
34cb476…
|
drh
|
2428 |
} |
|
d14adf1…
|
kejoki
|
2429 |
cgi_set_content(&content); |
|
d14adf1…
|
kejoki
|
2430 |
} |
|
d14adf1…
|
kejoki
|
2431 |
|
|
d14adf1…
|
kejoki
|
2432 |
/* |
|
d14adf1…
|
kejoki
|
2433 |
** Render a hex dump of a file. |
|
d14adf1…
|
kejoki
|
2434 |
*/ |
|
d14adf1…
|
kejoki
|
2435 |
static void hexdump(Blob *pBlob){ |
|
d14adf1…
|
kejoki
|
2436 |
const unsigned char *x; |
|
d14adf1…
|
kejoki
|
2437 |
int n, i, j, k; |
|
d14adf1…
|
kejoki
|
2438 |
char zLine[100]; |
|
d14adf1…
|
kejoki
|
2439 |
static const char zHex[] = "0123456789abcdef"; |
|
d14adf1…
|
kejoki
|
2440 |
|
|
d14adf1…
|
kejoki
|
2441 |
x = (const unsigned char*)blob_buffer(pBlob); |
|
d14adf1…
|
kejoki
|
2442 |
n = blob_size(pBlob); |
|
d14adf1…
|
kejoki
|
2443 |
for(i=0; i<n; i+=16){ |
|
d14adf1…
|
kejoki
|
2444 |
j = 0; |
|
d14adf1…
|
kejoki
|
2445 |
zLine[0] = zHex[(i>>24)&0xf]; |
|
d14adf1…
|
kejoki
|
2446 |
zLine[1] = zHex[(i>>16)&0xf]; |
|
d14adf1…
|
kejoki
|
2447 |
zLine[2] = zHex[(i>>8)&0xf]; |
|
d14adf1…
|
kejoki
|
2448 |
zLine[3] = zHex[i&0xf]; |
|
d14adf1…
|
kejoki
|
2449 |
zLine[4] = ':'; |
|
bbbb35a…
|
drh
|
2450 |
sqlite3_snprintf(sizeof(zLine), zLine, "%04x: ", i); |
|
d14adf1…
|
kejoki
|
2451 |
for(j=0; j<16; j++){ |
|
d14adf1…
|
kejoki
|
2452 |
k = 5+j*3; |
|
d14adf1…
|
kejoki
|
2453 |
zLine[k] = ' '; |
|
d14adf1…
|
kejoki
|
2454 |
if( i+j<n ){ |
|
d14adf1…
|
kejoki
|
2455 |
unsigned char c = x[i+j]; |
|
d14adf1…
|
kejoki
|
2456 |
zLine[k+1] = zHex[c>>4]; |
|
d14adf1…
|
kejoki
|
2457 |
zLine[k+2] = zHex[c&0xf]; |
|
d14adf1…
|
kejoki
|
2458 |
}else{ |
|
d14adf1…
|
kejoki
|
2459 |
zLine[k+1] = ' '; |
|
d14adf1…
|
kejoki
|
2460 |
zLine[k+2] = ' '; |
|
d14adf1…
|
kejoki
|
2461 |
} |
|
d14adf1…
|
kejoki
|
2462 |
} |
|
d14adf1…
|
kejoki
|
2463 |
zLine[53] = ' '; |
|
d14adf1…
|
kejoki
|
2464 |
zLine[54] = ' '; |
|
60736ab…
|
drh
|
2465 |
cgi_append_content(zLine, 55); |
|
60736ab…
|
drh
|
2466 |
for(j=k=0; j<16; j++){ |
|
d14adf1…
|
kejoki
|
2467 |
if( i+j<n ){ |
|
d14adf1…
|
kejoki
|
2468 |
unsigned char c = x[i+j]; |
|
60736ab…
|
drh
|
2469 |
if( c>'>' && c<=0x7e ){ |
|
60736ab…
|
drh
|
2470 |
zLine[k++] = c; |
|
60736ab…
|
drh
|
2471 |
}else if( c=='>' ){ |
|
60736ab…
|
drh
|
2472 |
zLine[k++] = '&'; |
|
60736ab…
|
drh
|
2473 |
zLine[k++] = 'g'; |
|
60736ab…
|
drh
|
2474 |
zLine[k++] = 't'; |
|
60736ab…
|
drh
|
2475 |
zLine[k++] = ';'; |
|
60736ab…
|
drh
|
2476 |
}else if( c=='<' ){ |
|
60736ab…
|
drh
|
2477 |
zLine[k++] = '&'; |
|
60736ab…
|
drh
|
2478 |
zLine[k++] = 'l'; |
|
60736ab…
|
drh
|
2479 |
zLine[k++] = 't'; |
|
60736ab…
|
drh
|
2480 |
zLine[k++] = ';'; |
|
60736ab…
|
drh
|
2481 |
}else if( c=='&' ){ |
|
60736ab…
|
drh
|
2482 |
zLine[k++] = '&'; |
|
60736ab…
|
drh
|
2483 |
zLine[k++] = 'a'; |
|
60736ab…
|
drh
|
2484 |
zLine[k++] = 'm'; |
|
60736ab…
|
drh
|
2485 |
zLine[k++] = 'p'; |
|
60736ab…
|
drh
|
2486 |
zLine[k++] = ';'; |
|
60736ab…
|
drh
|
2487 |
}else if( c>=' ' ){ |
|
60736ab…
|
drh
|
2488 |
zLine[k++] = c; |
|
60736ab…
|
drh
|
2489 |
}else{ |
|
60736ab…
|
drh
|
2490 |
zLine[k++] = '.'; |
|
60736ab…
|
drh
|
2491 |
} |
|
60736ab…
|
drh
|
2492 |
}else{ |
|
60736ab…
|
drh
|
2493 |
break; |
|
60736ab…
|
drh
|
2494 |
} |
|
60736ab…
|
drh
|
2495 |
} |
|
60736ab…
|
drh
|
2496 |
zLine[k++] = '\n'; |
|
60736ab…
|
drh
|
2497 |
cgi_append_content(zLine, k); |
|
d14adf1…
|
kejoki
|
2498 |
} |
|
d14adf1…
|
kejoki
|
2499 |
} |
|
d14adf1…
|
kejoki
|
2500 |
|
|
d14adf1…
|
kejoki
|
2501 |
/* |
|
d14adf1…
|
kejoki
|
2502 |
** WEBPAGE: hexdump |
|
d14adf1…
|
kejoki
|
2503 |
** URL: /hexdump?name=ARTIFACTID |
|
01050d6…
|
jan.nijtmans
|
2504 |
** |
|
d14adf1…
|
kejoki
|
2505 |
** Show the complete content of a file identified by ARTIFACTID |
|
d14adf1…
|
kejoki
|
2506 |
** as preformatted text. |
|
0ac4cea…
|
drh
|
2507 |
** |
|
0ac4cea…
|
drh
|
2508 |
** Other parameters: |
|
0ac4cea…
|
drh
|
2509 |
** |
|
3c2d418…
|
drh
|
2510 |
** verbose Show more detail when describing the object |
|
d14adf1…
|
kejoki
|
2511 |
*/ |
|
d14adf1…
|
kejoki
|
2512 |
void hexdump_page(void){ |
|
d14adf1…
|
kejoki
|
2513 |
int rid; |
|
d14adf1…
|
kejoki
|
2514 |
Blob content; |
|
923d644…
|
drh
|
2515 |
Blob downloadName; |
|
ee544f4…
|
drh
|
2516 |
char *zUuid; |
|
0ac4cea…
|
drh
|
2517 |
u32 objdescFlags = 0; |
|
0ac4cea…
|
drh
|
2518 |
|
|
0ac4cea…
|
drh
|
2519 |
rid = name_to_rid_www("name"); |
|
0ac4cea…
|
drh
|
2520 |
login_check_credentials(); |
|
653dd40…
|
drh
|
2521 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
653dd40…
|
drh
|
2522 |
if( rid==0 ) fossil_redirect_home(); |
|
57f1e87…
|
drh
|
2523 |
cgi_check_for_malice(); |
|
259e3a0…
|
drh
|
2524 |
if( g.perm.Admin ){ |
|
259e3a0…
|
drh
|
2525 |
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
259e3a0…
|
drh
|
2526 |
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ |
|
a40e8a0…
|
drh
|
2527 |
style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#delshun", zUuid); |
|
259e3a0…
|
drh
|
2528 |
}else{ |
|
a40e8a0…
|
drh
|
2529 |
style_submenu_element("Shun", "%R/shun?shun=%s#addshun", zUuid); |
|
259e3a0…
|
drh
|
2530 |
} |
|
259e3a0…
|
drh
|
2531 |
} |
|
259e3a0…
|
drh
|
2532 |
style_header("Hex Artifact Content"); |
|
259e3a0…
|
drh
|
2533 |
zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid); |
|
70bf9a6…
|
drh
|
2534 |
etag_check(ETAG_HASH, zUuid); |
|
8ee5e55…
|
drh
|
2535 |
@ <h2>Artifact |
|
68b2737…
|
drh
|
2536 |
style_copy_button(1, "hash-ar", 0, 2, 0, "%s", zUuid); |
|
259e3a0…
|
drh
|
2537 |
if( g.perm.Setup ){ |
|
759fbda…
|
drh
|
2538 |
@ (%d(rid)):</h2> |
|
259e3a0…
|
drh
|
2539 |
}else{ |
|
759fbda…
|
drh
|
2540 |
@ :</h2> |
|
259e3a0…
|
drh
|
2541 |
} |
|
259e3a0…
|
drh
|
2542 |
blob_zero(&downloadName); |
|
259e3a0…
|
drh
|
2543 |
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL; |
|
2b07e4e…
|
drh
|
2544 |
object_description(rid, objdescFlags, 0, &downloadName); |
|
34cb476…
|
drh
|
2545 |
style_submenu_element("Download", "%R/raw/%s?at=%T", |
|
0feb412…
|
drh
|
2546 |
zUuid, file_tail(blob_str(&downloadName))); |
|
f5482a0…
|
wyoung
|
2547 |
@ <hr> |
|
259e3a0…
|
drh
|
2548 |
content_get(rid, &content); |
|
16b3309…
|
drh
|
2549 |
if( blob_size(&content)>100000 ){ |
|
60736ab…
|
drh
|
2550 |
/* Prevent robots from running hexdump on megabyte-sized source files |
|
60736ab…
|
drh
|
2551 |
** and there by eating up lots of CPU time and bandwidth. There is |
|
60736ab…
|
drh
|
2552 |
** no good reason for a robot to need a hexdump. */ |
|
16b3309…
|
drh
|
2553 |
@ <p>A hex dump of this file is not available because it is too large. |
|
60736ab…
|
drh
|
2554 |
@ Please download the raw binary file and generate a hex dump yourself.</p> |
|
60736ab…
|
drh
|
2555 |
}else{ |
|
60736ab…
|
drh
|
2556 |
@ <blockquote><pre> |
|
60736ab…
|
drh
|
2557 |
hexdump(&content); |
|
60736ab…
|
drh
|
2558 |
@ </pre></blockquote> |
|
60736ab…
|
drh
|
2559 |
} |
|
112c713…
|
drh
|
2560 |
style_finish_page(); |
|
259e3a0…
|
drh
|
2561 |
} |
|
259e3a0…
|
drh
|
2562 |
|
|
259e3a0…
|
drh
|
2563 |
/* |
|
259e3a0…
|
drh
|
2564 |
** Look for "ci" and "filename" query parameters. If found, try to |
|
259e3a0…
|
drh
|
2565 |
** use them to extract the record ID of an artifact for the file. |
|
d95f712…
|
drh
|
2566 |
** |
|
1b5d0b0…
|
drh
|
2567 |
** Also look for "fn" and "name" as an aliases for "filename". If any |
|
1b5d0b0…
|
drh
|
2568 |
** "filename" or "fn" or "name" are present but "ci" is missing, then |
|
1b5d0b0…
|
drh
|
2569 |
** use "tip" as the default value for "ci". |
|
1b5d0b0…
|
drh
|
2570 |
** |
|
1b5d0b0…
|
drh
|
2571 |
** If zNameParam is not NULL, then use that parameter as the filename |
|
1b5d0b0…
|
drh
|
2572 |
** rather than "fn" or "filename" or "name". the zNameParam is used |
|
1b5d0b0…
|
drh
|
2573 |
** for the from= and to= query parameters of /fdiff. |
|
1b5d0b0…
|
drh
|
2574 |
*/ |
|
1b5d0b0…
|
drh
|
2575 |
int artifact_from_ci_and_filename(const char *zNameParam){ |
|
259e3a0…
|
drh
|
2576 |
const char *zFilename; |
|
259e3a0…
|
drh
|
2577 |
const char *zCI; |
|
259e3a0…
|
drh
|
2578 |
int cirid; |
|
259e3a0…
|
drh
|
2579 |
Manifest *pManifest; |
|
259e3a0…
|
drh
|
2580 |
ManifestFile *pFile; |
|
1b5d0b0…
|
drh
|
2581 |
int rid = 0; |
|
1949764…
|
drh
|
2582 |
|
|
1949764…
|
drh
|
2583 |
if( zNameParam ){ |
|
1949764…
|
drh
|
2584 |
zFilename = P(zNameParam); |
|
1949764…
|
drh
|
2585 |
}else{ |
|
1949764…
|
drh
|
2586 |
zFilename = P("filename"); |
|
1949764…
|
drh
|
2587 |
if( zFilename==0 ){ |
|
1949764…
|
drh
|
2588 |
zFilename = P("fn"); |
|
1949764…
|
drh
|
2589 |
} |
|
1b5d0b0…
|
drh
|
2590 |
if( zFilename==0 ){ |
|
1b5d0b0…
|
drh
|
2591 |
zFilename = P("name"); |
|
1b5d0b0…
|
drh
|
2592 |
} |
|
1949764…
|
drh
|
2593 |
} |
|
1949764…
|
drh
|
2594 |
if( zFilename==0 ) return 0; |
|
1949764…
|
drh
|
2595 |
|
|
1b5d0b0…
|
drh
|
2596 |
zCI = PD("ci", "tip"); |
|
1b5d0b0…
|
drh
|
2597 |
cirid = name_to_typed_rid(zCI, "ci"); |
|
d95f712…
|
drh
|
2598 |
if( cirid<=0 ) return 0; |
|
259e3a0…
|
drh
|
2599 |
pManifest = manifest_get(cirid, CFTYPE_MANIFEST, 0); |
|
259e3a0…
|
drh
|
2600 |
if( pManifest==0 ) return 0; |
|
259e3a0…
|
drh
|
2601 |
manifest_file_rewind(pManifest); |
|
259e3a0…
|
drh
|
2602 |
while( (pFile = manifest_file_next(pManifest,0))!=0 ){ |
|
259e3a0…
|
drh
|
2603 |
if( fossil_strcmp(zFilename, pFile->zName)==0 ){ |
|
1b5d0b0…
|
drh
|
2604 |
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", pFile->zUuid); |
|
1b5d0b0…
|
drh
|
2605 |
break; |
|
259e3a0…
|
drh
|
2606 |
} |
|
259e3a0…
|
drh
|
2607 |
} |
|
3cca4c2…
|
drh
|
2608 |
manifest_destroy(pManifest); |
|
1b5d0b0…
|
drh
|
2609 |
return rid; |
|
259e3a0…
|
drh
|
2610 |
} |
|
259e3a0…
|
drh
|
2611 |
|
|
259e3a0…
|
drh
|
2612 |
/* |
|
b699040…
|
drh
|
2613 |
** The "z" argument is a string that contains the text of a source |
|
b699040…
|
drh
|
2614 |
** code file and nZ is its length in bytes. This routine appends that |
|
b699040…
|
drh
|
2615 |
** text to the HTTP reply with line numbering. |
|
b699040…
|
drh
|
2616 |
** |
|
b699040…
|
drh
|
2617 |
** zName is the content's file name, if any (it may be NULL). If that |
|
b699040…
|
drh
|
2618 |
** name contains a '.' then the part after the final '.' is used as |
|
b699040…
|
drh
|
2619 |
** the X part of a "language-X" CSS class on the generated CODE block. |
|
259e3a0…
|
drh
|
2620 |
** |
|
259e3a0…
|
drh
|
2621 |
** zLn is the ?ln= parameter for the HTTP query. If there is an argument, |
|
259e3a0…
|
drh
|
2622 |
** then highlight that line number and scroll to it once the page loads. |
|
259e3a0…
|
drh
|
2623 |
** If there are two line numbers, highlight the range of lines. |
|
259e3a0…
|
drh
|
2624 |
** Multiple ranges can be highlighed by adding additional line numbers |
|
259e3a0…
|
drh
|
2625 |
** separated by a non-digit character (also not one of [-,.]). |
|
34f7fd7…
|
stephan
|
2626 |
** |
|
34f7fd7…
|
stephan
|
2627 |
** If includeJS is true then the JS code associated with line |
|
34f7fd7…
|
stephan
|
2628 |
** numbering is also emitted, else it is not. If this routine is |
|
34f7fd7…
|
stephan
|
2629 |
** called multiple times in a single app run, the JS is emitted only |
|
34f7fd7…
|
stephan
|
2630 |
** once. Note that when using this routine to emit Ajax responses, the |
|
34f7fd7…
|
stephan
|
2631 |
** JS should be not be included, as it will not get imported properly |
|
34f7fd7…
|
stephan
|
2632 |
** into the response's rendering. |
|
259e3a0…
|
drh
|
2633 |
*/ |
|
259e3a0…
|
drh
|
2634 |
void output_text_with_line_numbers( |
|
259e3a0…
|
drh
|
2635 |
const char *z, |
|
b699040…
|
drh
|
2636 |
int nZ, |
|
b699040…
|
drh
|
2637 |
const char *zName, |
|
34f7fd7…
|
stephan
|
2638 |
const char *zLn, |
|
34f7fd7…
|
stephan
|
2639 |
int includeJS |
|
259e3a0…
|
drh
|
2640 |
){ |
|
259e3a0…
|
drh
|
2641 |
int iStart, iEnd; /* Start and end of region to highlight */ |
|
259e3a0…
|
drh
|
2642 |
int n = 0; /* Current line number */ |
|
259e3a0…
|
drh
|
2643 |
int i = 0; /* Loop index */ |
|
259e3a0…
|
drh
|
2644 |
int iTop = 0; /* Scroll so that this line is on top of screen. */ |
|
b699040…
|
drh
|
2645 |
int nLine = 0; /* content line count */ |
|
b699040…
|
drh
|
2646 |
int nSpans = 0; /* number of distinct zLn spans */ |
|
b699040…
|
drh
|
2647 |
const char *zExt = file_extension(zName); |
|
34f7fd7…
|
stephan
|
2648 |
static int emittedJS = 0; /* emitted shared JS yet? */ |
|
259e3a0…
|
drh
|
2649 |
Stmt q; |
|
259e3a0…
|
drh
|
2650 |
|
|
259e3a0…
|
drh
|
2651 |
iStart = iEnd = atoi(zLn); |
|
259e3a0…
|
drh
|
2652 |
db_multi_exec( |
|
259e3a0…
|
drh
|
2653 |
"CREATE TEMP TABLE lnos(iStart INTEGER PRIMARY KEY, iEnd INTEGER)"); |
|
259e3a0…
|
drh
|
2654 |
if( iStart>0 ){ |
|
259e3a0…
|
drh
|
2655 |
do{ |
|
259e3a0…
|
drh
|
2656 |
while( fossil_isdigit(zLn[i]) ) i++; |
|
259e3a0…
|
drh
|
2657 |
if( zLn[i]==',' || zLn[i]=='-' || zLn[i]=='.' ){ |
|
259e3a0…
|
drh
|
2658 |
i++; |
|
259e3a0…
|
drh
|
2659 |
while( zLn[i]=='.' ){ i++; } |
|
259e3a0…
|
drh
|
2660 |
iEnd = atoi(&zLn[i]); |
|
259e3a0…
|
drh
|
2661 |
while( fossil_isdigit(zLn[i]) ) i++; |
|
259e3a0…
|
drh
|
2662 |
} |
|
259e3a0…
|
drh
|
2663 |
while( fossil_isdigit(zLn[i]) ) i++; |
|
259e3a0…
|
drh
|
2664 |
if( iEnd<iStart ) iEnd = iStart; |
|
259e3a0…
|
drh
|
2665 |
db_multi_exec( |
|
259e3a0…
|
drh
|
2666 |
"INSERT OR REPLACE INTO lnos VALUES(%d,%d)", iStart, iEnd |
|
259e3a0…
|
drh
|
2667 |
); |
|
b699040…
|
drh
|
2668 |
++nSpans; |
|
259e3a0…
|
drh
|
2669 |
iStart = iEnd = atoi(&zLn[i++]); |
|
259e3a0…
|
drh
|
2670 |
}while( zLn[i] && iStart && iEnd ); |
|
259e3a0…
|
drh
|
2671 |
} |
|
b699040…
|
drh
|
2672 |
/*cgi_printf("<!-- ln span count=%d -->", nSpans);*/ |
|
b699040…
|
drh
|
2673 |
cgi_append_content("<table class='numbered-lines'><tbody>" |
|
53ff9d0…
|
stephan
|
2674 |
"<tr><td class='line-numbers'><pre>", -1); |
|
b699040…
|
drh
|
2675 |
iStart = iEnd = 0; |
|
b699040…
|
drh
|
2676 |
count_lines(z, nZ, &nLine); |
|
b699040…
|
drh
|
2677 |
for( n=1 ; n<=nLine; ++n ){ |
|
b699040…
|
drh
|
2678 |
const char * zAttr = ""; |
|
b699040…
|
drh
|
2679 |
const char * zId = ""; |
|
b699040…
|
drh
|
2680 |
if(nSpans>0 && iEnd==0){/*Grab the next range of zLn marking*/ |
|
b699040…
|
drh
|
2681 |
db_prepare(&q, "SELECT iStart, iEnd FROM lnos " |
|
b699040…
|
drh
|
2682 |
"WHERE iStart >= %d ORDER BY iStart", n); |
|
b699040…
|
drh
|
2683 |
if( db_step(&q)==SQLITE_ROW ){ |
|
b699040…
|
drh
|
2684 |
iStart = db_column_int(&q, 0); |
|
b699040…
|
drh
|
2685 |
iEnd = db_column_int(&q, 1); |
|
b699040…
|
drh
|
2686 |
if(!iTop){ |
|
b699040…
|
drh
|
2687 |
iTop = iStart - 15 + (iEnd-iStart)/4; |
|
b699040…
|
drh
|
2688 |
if( iTop>iStart - 2 ) iTop = iStart-2; |
|
b699040…
|
drh
|
2689 |
} |
|
b699040…
|
drh
|
2690 |
}else{ |
|
b699040…
|
drh
|
2691 |
/* Note that overlapping multi-spans, e.g. 10-15+12-20, |
|
b699040…
|
drh
|
2692 |
can cause us to miss a row. */ |
|
b699040…
|
drh
|
2693 |
iStart = iEnd = 0; |
|
b699040…
|
drh
|
2694 |
} |
|
b699040…
|
drh
|
2695 |
db_finalize(&q); |
|
b699040…
|
drh
|
2696 |
--nSpans; |
|
b699040…
|
drh
|
2697 |
/*cgi_printf("<!-- iStart=%d, iEnd=%d -->", iStart, iEnd);*/ |
|
b699040…
|
drh
|
2698 |
} |
|
b699040…
|
drh
|
2699 |
if(n==iTop) { |
|
b699040…
|
drh
|
2700 |
zId = " id='scrollToMe'"; |
|
b699040…
|
drh
|
2701 |
} |
|
b699040…
|
drh
|
2702 |
if(n==iStart){/*Figure out which CSS class(es) this line needs...*/ |
|
b699040…
|
drh
|
2703 |
if(n==iEnd){ |
|
b699040…
|
drh
|
2704 |
zAttr = " class='selected-line start end'"; |
|
b699040…
|
drh
|
2705 |
iEnd = 0; |
|
b699040…
|
drh
|
2706 |
}else{ |
|
b699040…
|
drh
|
2707 |
zAttr = " class='selected-line start'"; |
|
b699040…
|
drh
|
2708 |
} |
|
b699040…
|
drh
|
2709 |
iStart = 0; |
|
b699040…
|
drh
|
2710 |
}else if(n==iEnd){ |
|
b699040…
|
drh
|
2711 |
zAttr = " class='selected-line end'"; |
|
b699040…
|
drh
|
2712 |
iEnd = 0; |
|
b699040…
|
drh
|
2713 |
}else if( n>iStart && n<iEnd ){ |
|
b699040…
|
drh
|
2714 |
zAttr = " class='selected-line'"; |
|
b699040…
|
drh
|
2715 |
} |
|
53ff9d0…
|
stephan
|
2716 |
cgi_printf("<span%s%s>%6d</span>\n", zId, zAttr, n) |
|
53ff9d0…
|
stephan
|
2717 |
/* ^^^ explicit \n is necessary for text-mode browsers. */; |
|
b699040…
|
drh
|
2718 |
} |
|
53ff9d0…
|
stephan
|
2719 |
cgi_append_content("</pre></td><td class='file-content'><pre>",-1); |
|
b699040…
|
drh
|
2720 |
if(zExt && *zExt){ |
|
b699040…
|
drh
|
2721 |
cgi_printf("<code class='language-%h'>",zExt); |
|
b699040…
|
drh
|
2722 |
}else{ |
|
b699040…
|
drh
|
2723 |
cgi_append_content("<code>", -1); |
|
b699040…
|
drh
|
2724 |
} |
|
b699040…
|
drh
|
2725 |
cgi_printf("%z", htmlize(z, nZ)); |
|
b699040…
|
drh
|
2726 |
CX("</code></pre></td></tr></tbody></table>\n"); |
|
34f7fd7…
|
stephan
|
2727 |
if(includeJS && !emittedJS){ |
|
34f7fd7…
|
stephan
|
2728 |
emittedJS = 1; |
|
34f7fd7…
|
stephan
|
2729 |
if( db_int(0, "SELECT EXISTS(SELECT 1 FROM lnos)") ){ |
|
34f7fd7…
|
stephan
|
2730 |
builtin_request_js("scroll.js"); |
|
34f7fd7…
|
stephan
|
2731 |
} |
|
815b4fc…
|
wyoung
|
2732 |
builtin_fossil_js_bundle_or("numbered-lines", NULL); |
|
b699040…
|
drh
|
2733 |
} |
|
b699040…
|
drh
|
2734 |
} |
|
b699040…
|
drh
|
2735 |
|
|
b699040…
|
drh
|
2736 |
/* |
|
b699040…
|
drh
|
2737 |
** COMMAND: test-line-numbers |
|
b699040…
|
drh
|
2738 |
** |
|
b699040…
|
drh
|
2739 |
** Usage: %fossil test-line-numbers FILE ?LN-SPEC? |
|
b699040…
|
drh
|
2740 |
** |
|
b699040…
|
drh
|
2741 |
*/ |
|
b699040…
|
drh
|
2742 |
void cmd_test_line_numbers(void){ |
|
b699040…
|
drh
|
2743 |
Blob content = empty_blob; |
|
b699040…
|
drh
|
2744 |
const char * zLn = ""; |
|
b699040…
|
drh
|
2745 |
const char * zFilename = 0; |
|
b699040…
|
drh
|
2746 |
|
|
b699040…
|
drh
|
2747 |
if(g.argc < 3){ |
|
b699040…
|
drh
|
2748 |
usage("FILE"); |
|
b699040…
|
drh
|
2749 |
}else if(g.argc>3){ |
|
b699040…
|
drh
|
2750 |
zLn = g.argv[3]; |
|
b699040…
|
drh
|
2751 |
} |
|
b699040…
|
drh
|
2752 |
db_find_and_open_repository(0,0); |
|
b699040…
|
drh
|
2753 |
zFilename = g.argv[2]; |
|
b699040…
|
drh
|
2754 |
fossil_print("%s %s\n", zFilename, zLn); |
|
b699040…
|
drh
|
2755 |
|
|
b699040…
|
drh
|
2756 |
blob_read_from_file(&content, zFilename, ExtFILE); |
|
b699040…
|
drh
|
2757 |
output_text_with_line_numbers(blob_str(&content), blob_size(&content), |
|
34f7fd7…
|
stephan
|
2758 |
zFilename, zLn, 0); |
|
b699040…
|
drh
|
2759 |
blob_reset(&content); |
|
b699040…
|
drh
|
2760 |
fossil_print("%b\n", cgi_output_blob()); |
|
b699040…
|
drh
|
2761 |
} |
|
d95f712…
|
drh
|
2762 |
|
|
d95f712…
|
drh
|
2763 |
/* |
|
259e3a0…
|
drh
|
2764 |
** WEBPAGE: artifact |
|
d95f712…
|
drh
|
2765 |
** WEBPAGE: file |
|
d95f712…
|
drh
|
2766 |
** WEBPAGE: whatis |
|
d098711…
|
drh
|
2767 |
** WEBPAGE: docfile |
|
d95f712…
|
drh
|
2768 |
** |
|
d95f712…
|
drh
|
2769 |
** Typical usage: |
|
259e3a0…
|
drh
|
2770 |
** |
|
9f3bad8…
|
drh
|
2771 |
** /artifact/HASH |
|
9f3bad8…
|
drh
|
2772 |
** /whatis/HASH |
|
d95f712…
|
drh
|
2773 |
** /file/NAME |
|
d098711…
|
drh
|
2774 |
** /docfile/NAME |
|
5acc3e4…
|
drh
|
2775 |
** |
|
5acc3e4…
|
drh
|
2776 |
** Additional query parameters: |
|
5acc3e4…
|
drh
|
2777 |
** |
|
5acc3e4…
|
drh
|
2778 |
** ln - show line numbers |
|
5acc3e4…
|
drh
|
2779 |
** ln=N - highlight line number N |
|
5acc3e4…
|
drh
|
2780 |
** ln=M-N - highlight lines M through N inclusive |
|
4896c0b…
|
andybradford
|
2781 |
** ln=M-N+Y-Z - highlight lines M through N and Y through Z (inclusive) |
|
3c2d418…
|
drh
|
2782 |
** verbose - show more detail in the description |
|
d098711…
|
drh
|
2783 |
** brief - show just the document, not the metadata. The |
|
d098711…
|
drh
|
2784 |
** /docfile page is an alias for /file?brief |
|
d10e2cb…
|
drh
|
2785 |
** download - redirect to the download (artifact page only) |
|
1b5d0b0…
|
drh
|
2786 |
** name=NAME - filename or hash as a query parameter |
|
2601132…
|
drh
|
2787 |
** filename=NAME - alternative spelling for "name=" |
|
2601132…
|
drh
|
2788 |
** fn=NAME - alternative spelling for "name=" |
|
1b5d0b0…
|
drh
|
2789 |
** ci=VERSION - The specific check-in to use with "name=" to |
|
1b5d0b0…
|
drh
|
2790 |
** identify the file. |
|
4a53f34…
|
andygoth
|
2791 |
** txt - Force display of unformatted source text |
|
4956789…
|
andybradford
|
2792 |
** hash - Output only the hash of the artifact |
|
3c2d418…
|
drh
|
2793 |
** |
|
3c2d418…
|
drh
|
2794 |
** The /artifact page show the complete content of a file |
|
1b5d0b0…
|
drh
|
2795 |
** identified by HASH. The /whatis page shows only a description |
|
1b5d0b0…
|
drh
|
2796 |
** of how the artifact is used. The /file page shows the most recent |
|
1b5d0b0…
|
drh
|
2797 |
** version of the file or directory called NAME, or a list of the |
|
1b5d0b0…
|
drh
|
2798 |
** top-level directory if NAME is omitted. |
|
1b5d0b0…
|
drh
|
2799 |
** |
|
cd05cb2…
|
drh
|
2800 |
** For /artifact and /whatis, the name= query parameter can refer to |
|
cd05cb2…
|
drh
|
2801 |
** either the name of a file, or an artifact hash. If the ci= query |
|
cd05cb2…
|
drh
|
2802 |
** parameter is also present, then name= must refer to a file name. |
|
cd05cb2…
|
drh
|
2803 |
** If ci= is omitted, then the hash interpretation is preferred but |
|
cd05cb2…
|
drh
|
2804 |
** if name= cannot be understood as a hash, a default "tip" value is |
|
cd05cb2…
|
drh
|
2805 |
** used for ci=. |
|
1b5d0b0…
|
drh
|
2806 |
** |
|
cd05cb2…
|
drh
|
2807 |
** For /file, name= can only be interpreted as a filename. As before, |
|
cd05cb2…
|
drh
|
2808 |
** a default value of "tip" is used for ci= if ci= is omitted. |
|
a48474b…
|
drh
|
2809 |
*/ |
|
a48474b…
|
drh
|
2810 |
void artifact_page(void){ |
|
96722b6…
|
drh
|
2811 |
int rid = 0; |
|
a48474b…
|
drh
|
2812 |
Blob content; |
|
d14adf1…
|
kejoki
|
2813 |
const char *zMime; |
|
923d644…
|
drh
|
2814 |
Blob downloadName; |
|
4956789…
|
andybradford
|
2815 |
Blob uuid; |
|
2b07e4e…
|
drh
|
2816 |
int renderAsWiki = 0; |
|
2b07e4e…
|
drh
|
2817 |
int renderAsHtml = 0; |
|
4a53f34…
|
andygoth
|
2818 |
int renderAsSvg = 0; |
|
2b07e4e…
|
drh
|
2819 |
int objType; |
|
2b07e4e…
|
drh
|
2820 |
int asText; |
|
2b07e4e…
|
drh
|
2821 |
const char *zUuid = 0; |
|
2b07e4e…
|
drh
|
2822 |
u32 objdescFlags = OBJDESC_BASE; |
|
2b07e4e…
|
drh
|
2823 |
int descOnly = fossil_strcmp(g.zPath,"whatis")==0; |
|
4956789…
|
andybradford
|
2824 |
int hashOnly = P("hash")!=0; |
|
dfc9a73…
|
drh
|
2825 |
int docOnly = P("brief")!=0; |
|
2b07e4e…
|
drh
|
2826 |
int isFile = fossil_strcmp(g.zPath,"file")==0; |
|
2b07e4e…
|
drh
|
2827 |
const char *zLn = P("ln"); |
|
2b07e4e…
|
drh
|
2828 |
const char *zName = P("name"); |
|
2b07e4e…
|
drh
|
2829 |
const char *zCI = P("ci"); |
|
2b07e4e…
|
drh
|
2830 |
HQuery url; |
|
2b07e4e…
|
drh
|
2831 |
char *zCIUuid = 0; |
|
2b07e4e…
|
drh
|
2832 |
int isSymbolicCI = 0; /* ci= exists and is a symbolic name, not a hash */ |
|
1b5d0b0…
|
drh
|
2833 |
int isBranchCI = 0; /* ci= refers to a branch name */ |
|
2b07e4e…
|
drh
|
2834 |
char *zHeader = 0; |
|
2b07e4e…
|
drh
|
2835 |
|
|
2b07e4e…
|
drh
|
2836 |
login_check_credentials(); |
|
2b07e4e…
|
drh
|
2837 |
if( !g.perm.Read ){ login_needed(g.anon.Read); return; } |
|
57f1e87…
|
drh
|
2838 |
cgi_check_for_malice(); |
|
112c713…
|
drh
|
2839 |
style_set_current_feature("artifact"); |
|
d098711…
|
drh
|
2840 |
if( fossil_strcmp(g.zPath, "docfile")==0 ){ |
|
d098711…
|
drh
|
2841 |
isFile = 1; |
|
d098711…
|
drh
|
2842 |
docOnly = 1; |
|
d098711…
|
drh
|
2843 |
} |
|
1b5d0b0…
|
drh
|
2844 |
|
|
1b5d0b0…
|
drh
|
2845 |
/* Capture and normalize the name= and ci= query parameters */ |
|
1b5d0b0…
|
drh
|
2846 |
if( zName==0 ){ |
|
1b5d0b0…
|
drh
|
2847 |
zName = P("filename"); |
|
1b5d0b0…
|
drh
|
2848 |
if( zName==0 ){ |
|
1b5d0b0…
|
drh
|
2849 |
zName = P("fn"); |
|
1b5d0b0…
|
drh
|
2850 |
} |
|
1b5d0b0…
|
drh
|
2851 |
} |
|
1b5d0b0…
|
drh
|
2852 |
if( zCI && strlen(zCI)==0 ){ zCI = 0; } |
|
1b5d0b0…
|
drh
|
2853 |
if( zCI |
|
1b5d0b0…
|
drh
|
2854 |
&& name_to_uuid2(zCI, "ci", &zCIUuid) |
|
1b5d0b0…
|
drh
|
2855 |
&& sqlite3_strnicmp(zCIUuid, zCI, strlen(zCI))!=0 |
|
1b5d0b0…
|
drh
|
2856 |
){ |
|
1b5d0b0…
|
drh
|
2857 |
isSymbolicCI = 1; |
|
92fe4a5…
|
drh
|
2858 |
isBranchCI = branch_includes_uuid(zCI, zCIUuid); |
|
1b5d0b0…
|
drh
|
2859 |
} |
|
1b5d0b0…
|
drh
|
2860 |
|
|
1b5d0b0…
|
drh
|
2861 |
/* The name= query parameter (or at least one of its alternative |
|
1b5d0b0…
|
drh
|
2862 |
** spellings) is required. Except for /file, show a top-level |
|
1b5d0b0…
|
drh
|
2863 |
** directory listing if name= is omitted. |
|
1b5d0b0…
|
drh
|
2864 |
*/ |
|
1b5d0b0…
|
drh
|
2865 |
if( zName==0 ){ |
|
1b5d0b0…
|
drh
|
2866 |
if( isFile ){ |
|
1b5d0b0…
|
drh
|
2867 |
if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
|
1b5d0b0…
|
drh
|
2868 |
page_tree(); |
|
1b5d0b0…
|
drh
|
2869 |
return; |
|
1b5d0b0…
|
drh
|
2870 |
} |
|
1b5d0b0…
|
drh
|
2871 |
style_header("Missing name= query parameter"); |
|
1b5d0b0…
|
drh
|
2872 |
@ The name= query parameter is missing |
|
112c713…
|
drh
|
2873 |
style_finish_page(); |
|
1b5d0b0…
|
drh
|
2874 |
return; |
|
1b5d0b0…
|
drh
|
2875 |
} |
|
1b5d0b0…
|
drh
|
2876 |
|
|
1b5d0b0…
|
drh
|
2877 |
url_initialize(&url, g.zPath); |
|
1b5d0b0…
|
drh
|
2878 |
url_add_parameter(&url, "name", zName); |
|
a6477bc…
|
george
|
2879 |
url_add_parameter(&url, "ci", zCI); /* no-op if zCI is NULL */ |
|
1b5d0b0…
|
drh
|
2880 |
|
|
1b5d0b0…
|
drh
|
2881 |
if( zCI==0 && !isFile ){ |
|
1b5d0b0…
|
drh
|
2882 |
/* If there is no ci= query parameter, then prefer to interpret |
|
1356151…
|
mgagnon
|
2883 |
** name= as a hash for /artifact and /whatis. But not for /file. |
|
4907122…
|
stephan
|
2884 |
** For /file, a name= without a ci= will prefer to use the default |
|
1b5d0b0…
|
drh
|
2885 |
** "tip" value for ci=. */ |
|
1b5d0b0…
|
drh
|
2886 |
rid = name_to_rid(zName); |
|
1b5d0b0…
|
drh
|
2887 |
} |
|
1b5d0b0…
|
drh
|
2888 |
if( rid==0 ){ |
|
1b5d0b0…
|
drh
|
2889 |
rid = artifact_from_ci_and_filename(0); |
|
1b5d0b0…
|
drh
|
2890 |
} |
|
cd05cb2…
|
drh
|
2891 |
|
|
cd05cb2…
|
drh
|
2892 |
if( rid==0 ){ /* Artifact not found */ |
|
cd05cb2…
|
drh
|
2893 |
if( isFile ){ |
|
5cf5ad8…
|
drh
|
2894 |
Stmt q; |
|
cd05cb2…
|
drh
|
2895 |
/* For /file, also check to see if name= refers to a directory, |
|
cd05cb2…
|
drh
|
2896 |
** and if so, do a listing for that directory */ |
|
cd05cb2…
|
drh
|
2897 |
int nName = (int)strlen(zName); |
|
cd05cb2…
|
drh
|
2898 |
if( nName && zName[nName-1]=='/' ) nName--; |
|
cd05cb2…
|
drh
|
2899 |
if( db_exists( |
|
cd05cb2…
|
drh
|
2900 |
"SELECT 1 FROM filename" |
|
cd05cb2…
|
drh
|
2901 |
" WHERE name GLOB '%.*q/*' AND substr(name,1,%d)=='%.*q/';", |
|
cd05cb2…
|
drh
|
2902 |
nName, zName, nName+1, nName, zName |
|
cd05cb2…
|
drh
|
2903 |
) ){ |
|
cd05cb2…
|
drh
|
2904 |
if( P("ci")==0 ) cgi_set_query_parameter("ci","tip"); |
|
cd05cb2…
|
drh
|
2905 |
page_tree(); |
|
cd05cb2…
|
drh
|
2906 |
return; |
|
cd05cb2…
|
drh
|
2907 |
} |
|
5cf5ad8…
|
drh
|
2908 |
/* No directory found, look for an historic version of the file |
|
5cf5ad8…
|
drh
|
2909 |
** that was subsequently deleted. */ |
|
275da70…
|
danield
|
2910 |
db_prepare(&q, |
|
5cf5ad8…
|
drh
|
2911 |
"SELECT fid, uuid FROM mlink, filename, event, blob" |
|
5cf5ad8…
|
drh
|
2912 |
" WHERE filename.name=%Q" |
|
5cf5ad8…
|
drh
|
2913 |
" AND mlink.fnid=filename.fnid AND mlink.fid>0" |
|
5cf5ad8…
|
drh
|
2914 |
" AND event.objid=mlink.mid" |
|
5cf5ad8…
|
drh
|
2915 |
" AND blob.rid=mlink.mid" |
|
5cf5ad8…
|
drh
|
2916 |
" ORDER BY event.mtime DESC", |
|
5cf5ad8…
|
drh
|
2917 |
zName |
|
5cf5ad8…
|
drh
|
2918 |
); |
|
5cf5ad8…
|
drh
|
2919 |
if( db_step(&q)==SQLITE_ROW ){ |
|
5cf5ad8…
|
drh
|
2920 |
rid = db_column_int(&q, 0); |
|
a6477bc…
|
george
|
2921 |
zCI = fossil_strdup(db_column_text(&q, 1)); |
|
a6477bc…
|
george
|
2922 |
zCIUuid = fossil_strdup(zCI); |
|
5cf5ad8…
|
drh
|
2923 |
url_add_parameter(&url, "ci", zCI); |
|
5cf5ad8…
|
drh
|
2924 |
} |
|
5cf5ad8…
|
drh
|
2925 |
db_finalize(&q); |
|
534c10f…
|
stephan
|
2926 |
if( rid==0 ){ |
|
5cf5ad8…
|
drh
|
2927 |
style_header("No such file"); |
|
5cf5ad8…
|
drh
|
2928 |
@ File '%h(zName)' does not exist in this repository. |
|
5cf5ad8…
|
drh
|
2929 |
} |
|
cd05cb2…
|
drh
|
2930 |
}else{ |
|
cd05cb2…
|
drh
|
2931 |
style_header("No such artifact"); |
|
cd05cb2…
|
drh
|
2932 |
@ Artifact '%h(zName)' does not exist in this repository. |
|
cd05cb2…
|
drh
|
2933 |
} |
|
5cf5ad8…
|
drh
|
2934 |
if( rid==0 ){ |
|
112c713…
|
drh
|
2935 |
style_finish_page(); |
|
5cf5ad8…
|
drh
|
2936 |
return; |
|
5cf5ad8…
|
drh
|
2937 |
} |
|
1b5d0b0…
|
drh
|
2938 |
} |
|
1b5d0b0…
|
drh
|
2939 |
|
|
3cca4c2…
|
drh
|
2940 |
if( descOnly || P("verbose")!=0 ){ |
|
3cca4c2…
|
drh
|
2941 |
url_add_parameter(&url, "verbose", "1"); |
|
3cca4c2…
|
drh
|
2942 |
objdescFlags |= OBJDESC_DETAIL; |
|
3cca4c2…
|
drh
|
2943 |
} |
|
d95f712…
|
drh
|
2944 |
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
70bf9a6…
|
drh
|
2945 |
etag_check(ETAG_HASH, zUuid); |
|
70bf9a6…
|
drh
|
2946 |
|
|
4956789…
|
andybradford
|
2947 |
if( descOnly && hashOnly ){ |
|
4956789…
|
andybradford
|
2948 |
blob_set(&uuid, zUuid); |
|
4956789…
|
andybradford
|
2949 |
cgi_set_content_type("text/plain"); |
|
4956789…
|
andybradford
|
2950 |
cgi_set_content(&uuid); |
|
4956789…
|
andybradford
|
2951 |
return; |
|
4956789…
|
andybradford
|
2952 |
} |
|
4956789…
|
andybradford
|
2953 |
|
|
e07b109…
|
drh
|
2954 |
asText = P("txt")!=0; |
|
759fbda…
|
drh
|
2955 |
if( isFile ){ |
|
dfc9a73…
|
drh
|
2956 |
if( docOnly ){ |
|
dfc9a73…
|
drh
|
2957 |
/* No header */ |
|
dfc9a73…
|
drh
|
2958 |
}else if( zCI==0 || fossil_strcmp(zCI,"tip")==0 ){ |
|
cd05cb2…
|
drh
|
2959 |
zCI = "tip"; |
|
b54d939…
|
drh
|
2960 |
@ <h2>File %z(href("%R/finfo?name=%T&m&ci=tip",zName))%h(zName)</a> |
|
4977765…
|
drh
|
2961 |
@ from the %z(href("%R/info/tip"))latest check-in</a></h2> |
|
1b5d0b0…
|
drh
|
2962 |
}else{ |
|
2b07e4e…
|
drh
|
2963 |
const char *zPath; |
|
2b07e4e…
|
drh
|
2964 |
Blob path; |
|
2b07e4e…
|
drh
|
2965 |
blob_zero(&path); |
|
cd05cb2…
|
drh
|
2966 |
hyperlinked_path(zName, &path, zCI, "dir", "", LINKPATH_FINFO); |
|
2b07e4e…
|
drh
|
2967 |
zPath = blob_str(&path); |
|
00eb7a0…
|
drh
|
2968 |
@ <h2>File %s(zPath) artifact \ |
|
68b2737…
|
drh
|
2969 |
style_copy_button(1,"hash-fid",0,0,0,"%z%S</a> ", |
|
00eb7a0…
|
drh
|
2970 |
href("%R/info/%s",zUuid),zUuid); |
|
1b5d0b0…
|
drh
|
2971 |
if( isBranchCI ){ |
|
1b5d0b0…
|
drh
|
2972 |
@ on branch %z(href("%R/timeline?r=%T",zCI))%h(zCI)</a></h2> |
|
1b5d0b0…
|
drh
|
2973 |
}else if( isSymbolicCI ){ |
|
00eb7a0…
|
drh
|
2974 |
@ part of check-in %z(href("%R/info/%!S",zCIUuid))%s(zCI)</a></h2> |
|
1b5d0b0…
|
drh
|
2975 |
}else{ |
|
00eb7a0…
|
drh
|
2976 |
@ part of check-in %z(href("%R/info/%!S",zCIUuid))%S(zCIUuid)</a></h2> |
|
1b5d0b0…
|
drh
|
2977 |
} |
|
2b07e4e…
|
drh
|
2978 |
blob_reset(&path); |
|
1b5d0b0…
|
drh
|
2979 |
} |
|
6643d4a…
|
drh
|
2980 |
zMime = mimetype_from_name(zName); |
|
d098711…
|
drh
|
2981 |
if( !docOnly ){ |
|
d098711…
|
drh
|
2982 |
style_submenu_element("Artifact", "%R/artifact/%S", zUuid); |
|
d098711…
|
drh
|
2983 |
style_submenu_element("Annotate", "%R/annotate?filename=%T&checkin=%T", |
|
d098711…
|
drh
|
2984 |
zName, zCI); |
|
d098711…
|
drh
|
2985 |
style_submenu_element("Blame", "%R/blame?filename=%T&checkin=%T", |
|
d098711…
|
drh
|
2986 |
zName, zCI); |
|
d098711…
|
drh
|
2987 |
style_submenu_element("Doc", "%R/doc/%T/%T", zCI, zName); |
|
d098711…
|
drh
|
2988 |
} |
|
cd05cb2…
|
drh
|
2989 |
blob_init(&downloadName, zName, -1); |
|
cd05cb2…
|
drh
|
2990 |
objType = OBJTYPE_CONTENT; |
|
759fbda…
|
drh
|
2991 |
}else{ |
|
759fbda…
|
drh
|
2992 |
@ <h2>Artifact |
|
68b2737…
|
drh
|
2993 |
style_copy_button(1, "hash-ar", 0, 2, 0, "%s", zUuid); |
|
759fbda…
|
drh
|
2994 |
if( g.perm.Setup ){ |
|
759fbda…
|
drh
|
2995 |
@ (%d(rid)):</h2> |
|
759fbda…
|
drh
|
2996 |
}else{ |
|
759fbda…
|
drh
|
2997 |
@ :</h2> |
|
759fbda…
|
drh
|
2998 |
} |
|
cd05cb2…
|
drh
|
2999 |
blob_zero(&downloadName); |
|
cd05cb2…
|
drh
|
3000 |
if( asText ) objdescFlags &= ~OBJDESC_BASE; |
|
cd05cb2…
|
drh
|
3001 |
objType = object_description(rid, objdescFlags, |
|
cd05cb2…
|
drh
|
3002 |
(isFile?zName:0), &downloadName); |
|
6643d4a…
|
drh
|
3003 |
zMime = mimetype_from_name(blob_str(&downloadName)); |
|
759fbda…
|
drh
|
3004 |
} |
|
d10e2cb…
|
drh
|
3005 |
if( !descOnly && P("download")!=0 ){ |
|
34cb476…
|
drh
|
3006 |
cgi_redirectf("%R/raw/%s?at=%T", |
|
34cb476…
|
drh
|
3007 |
db_text("x", "SELECT uuid FROM blob WHERE rid=%d", rid), |
|
0feb412…
|
drh
|
3008 |
file_tail(blob_str(&downloadName))); |
|
d10e2cb…
|
drh
|
3009 |
/*NOTREACHED*/ |
|
d10e2cb…
|
drh
|
3010 |
} |
|
d098711…
|
drh
|
3011 |
if( g.perm.Admin && !docOnly ){ |
|
49b0ff1…
|
drh
|
3012 |
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
49b0ff1…
|
drh
|
3013 |
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ |
|
a40e8a0…
|
drh
|
3014 |
style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#accshun", zUuid); |
|
2b07e4e…
|
drh
|
3015 |
}else{ |
|
a40e8a0…
|
drh
|
3016 |
style_submenu_element("Shun", "%R/shun?shun=%s#addshun",zUuid); |
|
2b07e4e…
|
drh
|
3017 |
} |
|
2b07e4e…
|
drh
|
3018 |
} |
|
2b07e4e…
|
drh
|
3019 |
|
|
2b07e4e…
|
drh
|
3020 |
if( isFile ){ |
|
2b07e4e…
|
drh
|
3021 |
if( isSymbolicCI ){ |
|
2b07e4e…
|
drh
|
3022 |
zHeader = mprintf("%s at %s", file_tail(zName), zCI); |
|
a7343c6…
|
drh
|
3023 |
style_set_current_page("doc/%t/%T", zCI, zName); |
|
cf72fc1…
|
drh
|
3024 |
}else if( zCIUuid && zCIUuid[0] ){ |
|
2b07e4e…
|
drh
|
3025 |
zHeader = mprintf("%s at [%S]", file_tail(zName), zCIUuid); |
|
a7343c6…
|
drh
|
3026 |
style_set_current_page("doc/%S/%T", zCIUuid, zName); |
|
d95f712…
|
drh
|
3027 |
}else{ |
|
4c3e172…
|
danield
|
3028 |
zHeader = fossil_strdup(file_tail(zName)); |
|
a7343c6…
|
drh
|
3029 |
style_set_current_page("doc/tip/%T", zName); |
|
d95f712…
|
drh
|
3030 |
} |
|
2b07e4e…
|
drh
|
3031 |
}else if( descOnly ){ |
|
2b07e4e…
|
drh
|
3032 |
zHeader = mprintf("Artifact Description [%S]", zUuid); |
|
2b07e4e…
|
drh
|
3033 |
}else{ |
|
2b07e4e…
|
drh
|
3034 |
zHeader = mprintf("Artifact [%S]", zUuid); |
|
d95f712…
|
drh
|
3035 |
} |
|
2b07e4e…
|
drh
|
3036 |
style_header("%s", zHeader); |
|
2b07e4e…
|
drh
|
3037 |
fossil_free(zCIUuid); |
|
2b07e4e…
|
drh
|
3038 |
fossil_free(zHeader); |
|
cd05cb2…
|
drh
|
3039 |
if( !isFile && g.perm.Admin ){ |
|
8b2d32c…
|
drh
|
3040 |
Stmt q; |
|
8b2d32c…
|
drh
|
3041 |
db_prepare(&q, |
|
8b2d32c…
|
drh
|
3042 |
"SELECT coalesce(user.login,rcvfrom.uid)," |
|
dbc9e48…
|
danield
|
3043 |
" datetime(rcvfrom.mtime,toLocal())," |
|
2e2932f…
|
drh
|
3044 |
" coalesce(rcvfrom.ipaddr,'unknown')," |
|
2e2932f…
|
drh
|
3045 |
" rcvfrom.rcvid" |
|
8b2d32c…
|
drh
|
3046 |
" FROM blob, rcvfrom LEFT JOIN user ON user.uid=rcvfrom.uid" |
|
8b2d32c…
|
drh
|
3047 |
" WHERE blob.rid=%d" |
|
8b2d32c…
|
drh
|
3048 |
" AND rcvfrom.rcvid=blob.rcvid;", rid); |
|
8b2d32c…
|
drh
|
3049 |
while( db_step(&q)==SQLITE_ROW ){ |
|
8b2d32c…
|
drh
|
3050 |
const char *zUser = db_column_text(&q,0); |
|
8b2d32c…
|
drh
|
3051 |
const char *zDate = db_column_text(&q,1); |
|
8b2d32c…
|
drh
|
3052 |
const char *zIp = db_column_text(&q,2); |
|
2e2932f…
|
drh
|
3053 |
int rcvid = db_column_int(&q,3); |
|
2e2932f…
|
drh
|
3054 |
@ <p>Received on %s(zDate) from %h(zUser) at %h(zIp). |
|
d21fdd5…
|
danield
|
3055 |
@ (<a href="%R/rcvfrom?rcvid=%d(rcvid)">rcvid %d(rcvid)</a>)</p> |
|
8b2d32c…
|
drh
|
3056 |
} |
|
8b2d32c…
|
drh
|
3057 |
db_finalize(&q); |
|
8b2d32c…
|
drh
|
3058 |
} |
|
d098711…
|
drh
|
3059 |
if( !docOnly ){ |
|
b1e811c…
|
drh
|
3060 |
style_submenu_element("Download", "%R/raw/%s?at=%T", |
|
b1e811c…
|
drh
|
3061 |
zUuid, file_tail(blob_str(&downloadName))); |
|
d098711…
|
drh
|
3062 |
if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){ |
|
d098711…
|
drh
|
3063 |
style_submenu_element("Check-ins Using", "%R/timeline?uf=%s", zUuid); |
|
d098711…
|
drh
|
3064 |
} |
|
187424e…
|
andygoth
|
3065 |
} |
|
c7fe01f…
|
drh
|
3066 |
if( zMime ){ |
|
31c52c7…
|
drh
|
3067 |
if( fossil_strcmp(zMime, "text/html")==0 ){ |
|
ba418ee…
|
drh
|
3068 |
if( asText ){ |
|
3cca4c2…
|
drh
|
3069 |
style_submenu_element("Html", "%s", url_render(&url, "txt", 0, 0, 0)); |
|
c7fe01f…
|
drh
|
3070 |
}else{ |
|
c7fe01f…
|
drh
|
3071 |
renderAsHtml = 1; |
|
d098711…
|
drh
|
3072 |
if( !docOnly ){ |
|
d098711…
|
drh
|
3073 |
style_submenu_element("Text", "%s", url_render(&url, "txt","1",0,0)); |
|
d098711…
|
drh
|
3074 |
} |
|
c7fe01f…
|
drh
|
3075 |
} |
|
60019ce…
|
drh
|
3076 |
}else if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 |
|
e32214a…
|
drh
|
3077 |
|| fossil_strcmp(zMime, "text/x-markdown")==0 |
|
e32214a…
|
drh
|
3078 |
|| fossil_strcmp(zMime, "text/x-pikchr")==0 ){ |
|
ba418ee…
|
drh
|
3079 |
if( asText ){ |
|
e32214a…
|
drh
|
3080 |
style_submenu_element(zMime[7]=='p' ? "Pikchr" : "Wiki", |
|
e32214a…
|
drh
|
3081 |
"%s", url_render(&url, "txt", 0, 0, 0)); |
|
c7fe01f…
|
drh
|
3082 |
}else{ |
|
c7fe01f…
|
drh
|
3083 |
renderAsWiki = 1; |
|
d098711…
|
drh
|
3084 |
if( !docOnly ){ |
|
d098711…
|
drh
|
3085 |
style_submenu_element("Text", "%s", url_render(&url, "txt","1",0,0)); |
|
d098711…
|
drh
|
3086 |
} |
|
4a53f34…
|
andygoth
|
3087 |
} |
|
4a53f34…
|
andygoth
|
3088 |
}else if( fossil_strcmp(zMime, "image/svg+xml")==0 ){ |
|
4a53f34…
|
andygoth
|
3089 |
if( asText ){ |
|
4a53f34…
|
andygoth
|
3090 |
style_submenu_element("Svg", "%s", url_render(&url, "txt", 0, 0, 0)); |
|
4a53f34…
|
andygoth
|
3091 |
}else{ |
|
4a53f34…
|
andygoth
|
3092 |
renderAsSvg = 1; |
|
d098711…
|
drh
|
3093 |
if( !docOnly ){ |
|
d098711…
|
drh
|
3094 |
style_submenu_element("Text", "%s", url_render(&url, "txt","1",0,0)); |
|
d098711…
|
drh
|
3095 |
} |
|
ba418ee…
|
drh
|
3096 |
} |
|
1243bf3…
|
stephan
|
3097 |
} |
|
d098711…
|
drh
|
3098 |
if( !docOnly && fileedit_is_editable(zName) ){ |
|
1243bf3…
|
stephan
|
3099 |
style_submenu_element("Edit", |
|
1243bf3…
|
stephan
|
3100 |
"%R/fileedit?filename=%T&checkin=%!S", |
|
1243bf3…
|
stephan
|
3101 |
zName, zCI); |
|
ba418ee…
|
drh
|
3102 |
} |
|
ba418ee…
|
drh
|
3103 |
} |
|
ba418ee…
|
drh
|
3104 |
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){ |
|
187424e…
|
andygoth
|
3105 |
style_submenu_element("Parsed", "%R/info/%s", zUuid); |
|
3c2d418…
|
drh
|
3106 |
} |
|
3c2d418…
|
drh
|
3107 |
if( descOnly ){ |
|
187424e…
|
andygoth
|
3108 |
style_submenu_element("Content", "%R/artifact/%s", zUuid); |
|
3c2d418…
|
drh
|
3109 |
}else{ |
|
dfc9a73…
|
drh
|
3110 |
if( !docOnly || !isFile ){ |
|
dfc9a73…
|
drh
|
3111 |
@ <hr> |
|
dfc9a73…
|
drh
|
3112 |
} |
|
3c2d418…
|
drh
|
3113 |
content_get(rid, &content); |
|
3c2d418…
|
drh
|
3114 |
if( renderAsWiki ){ |
|
89b6dda…
|
drh
|
3115 |
safe_html_context(DOCSRC_FILE); |
|
89b6dda…
|
drh
|
3116 |
wiki_render_by_mimetype(&content, zMime); |
|
9b2b6f5…
|
stephan
|
3117 |
document_emit_js(); |
|
3c2d418…
|
drh
|
3118 |
}else if( renderAsHtml ){ |
|
9d18585…
|
drh
|
3119 |
@ <iframe src="%R/raw/%s(zUuid)" |
|
3cca4c2…
|
drh
|
3120 |
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0" |
|
4675fc7…
|
drh
|
3121 |
@ sandbox="allow-same-origin" id="ifm1"> |
|
3c2d418…
|
drh
|
3122 |
@ </iframe> |
|
6854244…
|
drh
|
3123 |
@ <script nonce="%h(style_nonce())">/* info.c:%d(__LINE__) */ |
|
4675fc7…
|
drh
|
3124 |
@ document.getElementById("ifm1").addEventListener("load", |
|
4675fc7…
|
drh
|
3125 |
@ function(){ |
|
4675fc7…
|
drh
|
3126 |
@ this.height=this.contentDocument.documentElement.scrollHeight + 75; |
|
4675fc7…
|
drh
|
3127 |
@ } |
|
4675fc7…
|
drh
|
3128 |
@ ); |
|
4675fc7…
|
drh
|
3129 |
@ </script> |
|
4a53f34…
|
andygoth
|
3130 |
}else if( renderAsSvg ){ |
|
4a53f34…
|
andygoth
|
3131 |
@ <object type="image/svg+xml" data="%R/raw/%s(zUuid)"></object> |
|
3c2d418…
|
drh
|
3132 |
}else{ |
|
1e00898…
|
drh
|
3133 |
const char *zContentMime; |
|
a40e8a0…
|
drh
|
3134 |
style_submenu_element("Hex", "%R/hexdump?name=%s", zUuid); |
|
40c40f7…
|
drh
|
3135 |
if( zLn==0 || atoi(zLn)==0 ){ |
|
40c40f7…
|
drh
|
3136 |
style_submenu_checkbox("ln", "Line Numbers", 0, 0); |
|
40c40f7…
|
drh
|
3137 |
} |
|
3c2d418…
|
drh
|
3138 |
blob_to_utf8_no_bom(&content, 0); |
|
1e00898…
|
drh
|
3139 |
zContentMime = mimetype_from_content(&content); |
|
1e00898…
|
drh
|
3140 |
if( zMime==0 ) zMime = zContentMime; |
|
b699040…
|
drh
|
3141 |
@ <blockquote class="file-content"> |
|
1e00898…
|
drh
|
3142 |
if( zContentMime==0 ){ |
|
74b538f…
|
drh
|
3143 |
const char *z, *zFileName, *zExt; |
|
3c2d418…
|
drh
|
3144 |
z = blob_str(&content); |
|
74b538f…
|
drh
|
3145 |
zFileName = db_text(0, |
|
74b538f…
|
drh
|
3146 |
"SELECT name FROM mlink, filename" |
|
74b538f…
|
drh
|
3147 |
" WHERE filename.fnid=mlink.fnid" |
|
74b538f…
|
drh
|
3148 |
" AND mlink.fid=%d", |
|
74b538f…
|
drh
|
3149 |
rid); |
|
5a9ac6c…
|
drh
|
3150 |
zExt = zFileName ? file_extension(zFileName) : 0; |
|
3c2d418…
|
drh
|
3151 |
if( zLn ){ |
|
b699040…
|
drh
|
3152 |
output_text_with_line_numbers(z, blob_size(&content), |
|
34f7fd7…
|
stephan
|
3153 |
zFileName, zLn, 1); |
|
e7a7b5c…
|
george
|
3154 |
}else if( zExt && zExt[0] ){ |
|
74b538f…
|
drh
|
3155 |
@ <pre> |
|
b699040…
|
drh
|
3156 |
@ <code class="language-%s(zExt)">%h(z)</code> |
|
74b538f…
|
drh
|
3157 |
@ </pre> |
|
3c2d418…
|
drh
|
3158 |
}else{ |
|
3c2d418…
|
drh
|
3159 |
@ <pre> |
|
3c2d418…
|
drh
|
3160 |
@ %h(z) |
|
3c2d418…
|
drh
|
3161 |
@ </pre> |
|
3c2d418…
|
drh
|
3162 |
} |
|
3c2d418…
|
drh
|
3163 |
}else if( strncmp(zMime, "image/", 6)==0 ){ |
|
7b0dbe8…
|
drh
|
3164 |
@ <p>(file is %d(blob_size(&content)) bytes of image data)</i></p> |
|
7b0dbe8…
|
drh
|
3165 |
@ <p><img src="%R/raw/%s(zUuid)?m=%s(zMime)"></p> |
|
187424e…
|
andygoth
|
3166 |
style_submenu_element("Image", "%R/raw/%s?m=%s", zUuid, zMime); |
|
6643d4a…
|
drh
|
3167 |
}else if( strncmp(zMime, "audio/", 6)==0 ){ |
|
dff1332…
|
drh
|
3168 |
@ <p>(file is %d(blob_size(&content)) bytes of sound data)</i></p> |
|
6643d4a…
|
drh
|
3169 |
@ <audio controls src="%R/raw/%s(zUuid)?m=%s(zMime)"> |
|
6643d4a…
|
drh
|
3170 |
@ (Not supported by this browser) |
|
6643d4a…
|
drh
|
3171 |
@ </audio> |
|
3c2d418…
|
drh
|
3172 |
}else{ |
|
3c2d418…
|
drh
|
3173 |
@ <i>(file is %d(blob_size(&content)) bytes of binary data)</i> |
|
3c2d418…
|
drh
|
3174 |
} |
|
3c2d418…
|
drh
|
3175 |
@ </blockquote> |
|
3c2d418…
|
drh
|
3176 |
} |
|
3c2d418…
|
drh
|
3177 |
} |
|
112c713…
|
drh
|
3178 |
style_finish_page(); |
|
01050d6…
|
jan.nijtmans
|
3179 |
} |
|
b3ee50c…
|
drh
|
3180 |
|
|
b3ee50c…
|
drh
|
3181 |
/* |
|
b3ee50c…
|
drh
|
3182 |
** WEBPAGE: tinfo |
|
e8c4f69…
|
drh
|
3183 |
** URL: /tinfo?name=ARTIFACTID |
|
b3ee50c…
|
drh
|
3184 |
** |
|
b3ee50c…
|
drh
|
3185 |
** Show the details of a ticket change control artifact. |
|
b3ee50c…
|
drh
|
3186 |
*/ |
|
b3ee50c…
|
drh
|
3187 |
void tinfo_page(void){ |
|
b3ee50c…
|
drh
|
3188 |
int rid; |
|
b3ee50c…
|
drh
|
3189 |
char *zDate; |
|
b3ee50c…
|
drh
|
3190 |
const char *zUuid; |
|
323299c…
|
drh
|
3191 |
char zTktName[HNAME_MAX+1]; |
|
d13054c…
|
drh
|
3192 |
Manifest *pTktChng; |
|
ba418ee…
|
drh
|
3193 |
int modPending; |
|
ba418ee…
|
drh
|
3194 |
const char *zModAction; |
|
dbaf520…
|
stephan
|
3195 |
char *zTktTitle; |
|
b3ee50c…
|
drh
|
3196 |
login_check_credentials(); |
|
653dd40…
|
drh
|
3197 |
if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; } |
|
96722b6…
|
drh
|
3198 |
rid = name_to_rid_www("name"); |
|
b3ee50c…
|
drh
|
3199 |
if( rid==0 ){ fossil_redirect_home(); } |
|
57f1e87…
|
drh
|
3200 |
cgi_check_for_malice(); |
|
b3ee50c…
|
drh
|
3201 |
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
b344d3c…
|
drh
|
3202 |
if( g.perm.Admin ){ |
|
49b0ff1…
|
drh
|
3203 |
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){ |
|
a40e8a0…
|
drh
|
3204 |
style_submenu_element("Unshun", "%R/shun?accept=%s&sub=1#accshun", zUuid); |
|
b3ee50c…
|
drh
|
3205 |
}else{ |
|
a40e8a0…
|
drh
|
3206 |
style_submenu_element("Shun", "%R/shun?shun=%s#addshun", zUuid); |
|
ba418ee…
|
drh
|
3207 |
} |
|
ba418ee…
|
drh
|
3208 |
} |
|
ec81aee…
|
jan.nijtmans
|
3209 |
pTktChng = manifest_get(rid, CFTYPE_TICKET, 0); |
|
ba418ee…
|
drh
|
3210 |
if( pTktChng==0 ) fossil_redirect_home(); |
|
0028a3c…
|
george
|
3211 |
zDate = db_text(0, "SELECT datetime(%.12f,toLocal())", pTktChng->rDate); |
|
323299c…
|
drh
|
3212 |
sqlite3_snprintf(sizeof(zTktName), zTktName, "%s", pTktChng->zTicketUuid); |
|
ba418ee…
|
drh
|
3213 |
if( g.perm.ModTkt && (zModAction = P("modaction"))!=0 ){ |
|
ba418ee…
|
drh
|
3214 |
if( strcmp(zModAction,"delete")==0 ){ |
|
ba418ee…
|
drh
|
3215 |
moderation_disapprove(rid); |
|
636c334…
|
mistachkin
|
3216 |
/* |
|
636c334…
|
mistachkin
|
3217 |
** Next, check if the ticket still exists; if not, we cannot |
|
636c334…
|
mistachkin
|
3218 |
** redirect to it. |
|
636c334…
|
mistachkin
|
3219 |
*/ |
|
636c334…
|
mistachkin
|
3220 |
if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", |
|
636c334…
|
mistachkin
|
3221 |
zTktName) ){ |
|
636c334…
|
mistachkin
|
3222 |
cgi_redirectf("%R/tktview/%s", zTktName); |
|
636c334…
|
mistachkin
|
3223 |
/*NOTREACHED*/ |
|
636c334…
|
mistachkin
|
3224 |
}else{ |
|
636c334…
|
mistachkin
|
3225 |
cgi_redirectf("%R/modreq"); |
|
636c334…
|
mistachkin
|
3226 |
/*NOTREACHED*/ |
|
636c334…
|
mistachkin
|
3227 |
} |
|
ba418ee…
|
drh
|
3228 |
} |
|
ba418ee…
|
drh
|
3229 |
if( strcmp(zModAction,"approve")==0 ){ |
|
5e28feb…
|
drh
|
3230 |
moderation_approve('t', rid); |
|
b3ee50c…
|
drh
|
3231 |
} |
|
b3ee50c…
|
drh
|
3232 |
} |
|
1aa8067…
|
drh
|
3233 |
zTktTitle = db_table_has_column("repository", "ticket", "title" ) |
|
275da70…
|
danield
|
3234 |
? db_text("(No title)", |
|
f8bc3ce…
|
drh
|
3235 |
"SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName) |
|
dbaf520…
|
stephan
|
3236 |
: 0; |
|
112c713…
|
drh
|
3237 |
style_set_current_feature("tinfo"); |
|
b3ee50c…
|
drh
|
3238 |
style_header("Ticket Change Details"); |
|
187424e…
|
andygoth
|
3239 |
style_submenu_element("Raw", "%R/artifact/%s", zUuid); |
|
872a3b2…
|
george
|
3240 |
style_submenu_element("History", "%R/tkthistory/%s#%S", zTktName,zUuid); |
|
187424e…
|
andygoth
|
3241 |
style_submenu_element("Page", "%R/tktview/%t", zTktName); |
|
187424e…
|
andygoth
|
3242 |
style_submenu_element("Timeline", "%R/tkttimeline/%t", zTktName); |
|
4f8c897…
|
drh
|
3243 |
if( P("plaintext") ){ |
|
187424e…
|
andygoth
|
3244 |
style_submenu_element("Formatted", "%R/info/%s", zUuid); |
|
4f8c897…
|
drh
|
3245 |
}else{ |
|
187424e…
|
andygoth
|
3246 |
style_submenu_element("Plaintext", "%R/info/%s?plaintext", zUuid); |
|
4f8c897…
|
drh
|
3247 |
} |
|
ba418ee…
|
drh
|
3248 |
|
|
ba418ee…
|
drh
|
3249 |
@ <div class="section">Overview</div> |
|
ba418ee…
|
drh
|
3250 |
@ <p><table class="label-value"> |
|
ba418ee…
|
drh
|
3251 |
@ <tr><th>Artifact ID:</th> |
|
1fee037…
|
drh
|
3252 |
@ <td>%z(href("%R/artifact/%!S",zUuid))%s(zUuid)</a> |
|
ba418ee…
|
drh
|
3253 |
if( g.perm.Setup ){ |
|
ba418ee…
|
drh
|
3254 |
@ (%d(rid)) |
|
ba418ee…
|
drh
|
3255 |
} |
|
99fcc43…
|
drh
|
3256 |
modPending = moderation_pending_www(rid); |
|
ba418ee…
|
drh
|
3257 |
@ <tr><th>Ticket:</th> |
|
dbaf520…
|
stephan
|
3258 |
@ <td>%z(href("%R/tktview/%s",zTktName))%s(zTktName)</a> |
|
3529f2c…
|
jan.nijtmans
|
3259 |
if( zTktTitle ){ |
|
f5482a0…
|
wyoung
|
3260 |
@<br>%h(zTktTitle) |
|
dbaf520…
|
stephan
|
3261 |
} |
|
dbaf520…
|
stephan
|
3262 |
@</td></tr> |
|
4290984…
|
drh
|
3263 |
@ <tr><th>User & Date:</th><td> |
|
4290984…
|
drh
|
3264 |
hyperlink_to_user(pTktChng->zUser, zDate, " on "); |
|
ba418ee…
|
drh
|
3265 |
hyperlink_to_date(zDate, "</td></tr>"); |
|
9e0da27…
|
drh
|
3266 |
@ </table> |
|
b3ee50c…
|
drh
|
3267 |
free(zDate); |
|
dbaf520…
|
stephan
|
3268 |
free(zTktTitle); |
|
3ba9a4d…
|
jan.nijtmans
|
3269 |
|
|
ba418ee…
|
drh
|
3270 |
if( g.perm.ModTkt && modPending ){ |
|
ba418ee…
|
drh
|
3271 |
@ <div class="section">Moderation</div> |
|
ba418ee…
|
drh
|
3272 |
@ <blockquote> |
|
ba418ee…
|
drh
|
3273 |
@ <form method="POST" action="%R/tinfo/%s(zUuid)"> |
|
ba418ee…
|
drh
|
3274 |
@ <label><input type="radio" name="modaction" value="delete"> |
|
f5482a0…
|
wyoung
|
3275 |
@ Delete this change</label><br> |
|
ba418ee…
|
drh
|
3276 |
@ <label><input type="radio" name="modaction" value="approve"> |
|
f5482a0…
|
wyoung
|
3277 |
@ Approve this change</label><br> |
|
ba418ee…
|
drh
|
3278 |
@ <input type="submit" value="Submit"> |
|
ba418ee…
|
drh
|
3279 |
@ </form> |
|
ba418ee…
|
drh
|
3280 |
@ </blockquote> |
|
ba418ee…
|
drh
|
3281 |
} |
|
ba418ee…
|
drh
|
3282 |
|
|
ba418ee…
|
drh
|
3283 |
@ <div class="section">Changes</div> |
|
ba418ee…
|
drh
|
3284 |
@ <p> |
|
872a3b2…
|
george
|
3285 |
ticket_output_change_artifact(pTktChng, 0, 1, 0); |
|
d13054c…
|
drh
|
3286 |
manifest_destroy(pTktChng); |
|
275da70…
|
danield
|
3287 |
style_finish_page(); |
|
275da70…
|
danield
|
3288 |
} |
|
275da70…
|
danield
|
3289 |
|
|
4170e0b…
|
drh
|
3290 |
/* |
|
4170e0b…
|
drh
|
3291 |
** rid is a cluster. Paint a page that contains detailed information |
|
4170e0b…
|
drh
|
3292 |
** about that cluster. |
|
4170e0b…
|
drh
|
3293 |
*/ |
|
4170e0b…
|
drh
|
3294 |
static void cluster_info(int rid, const char *zName){ |
|
4170e0b…
|
drh
|
3295 |
Manifest *pCluster; |
|
4170e0b…
|
drh
|
3296 |
int i; |
|
4170e0b…
|
drh
|
3297 |
Blob where = BLOB_INITIALIZER; |
|
4170e0b…
|
drh
|
3298 |
Blob unks = BLOB_INITIALIZER; |
|
4170e0b…
|
drh
|
3299 |
Stmt q; |
|
4170e0b…
|
drh
|
3300 |
char *zSha1Bg; |
|
4170e0b…
|
drh
|
3301 |
char *zSha3Bg; |
|
4170e0b…
|
drh
|
3302 |
int badRid = 0; |
|
9953b16…
|
drh
|
3303 |
int rcvid; |
|
4170e0b…
|
drh
|
3304 |
int hashClr = PB("hclr"); |
|
9953b16…
|
drh
|
3305 |
const char *zDate; |
|
4170e0b…
|
drh
|
3306 |
|
|
4170e0b…
|
drh
|
3307 |
pCluster = manifest_get(rid, CFTYPE_CLUSTER, 0); |
|
4170e0b…
|
drh
|
3308 |
if( pCluster==0 ){ |
|
4170e0b…
|
drh
|
3309 |
artifact_page(); |
|
4170e0b…
|
drh
|
3310 |
return; |
|
4170e0b…
|
drh
|
3311 |
} |
|
4170e0b…
|
drh
|
3312 |
style_header("Cluster %S", zName); |
|
9953b16…
|
drh
|
3313 |
rcvid = db_int(0, "SELECT rcvid FROM blob WHERE rid=%d", rid); |
|
9953b16…
|
drh
|
3314 |
if( rcvid==0 ){ |
|
9953b16…
|
drh
|
3315 |
zDate = 0; |
|
9953b16…
|
drh
|
3316 |
}else{ |
|
9953b16…
|
drh
|
3317 |
zDate = db_text(0, "SELECT datetime(mtime) FROM rcvfrom WHERE rcvid=%d", |
|
9953b16…
|
drh
|
3318 |
rcvid); |
|
9953b16…
|
drh
|
3319 |
} |
|
4170e0b…
|
drh
|
3320 |
@ <p>Artifact %z(href("%R/artifact/%h",zName))%S(zName)</a> is a cluster |
|
9953b16…
|
drh
|
3321 |
@ with %d(pCluster->nCChild) entries |
|
9953b16…
|
drh
|
3322 |
if( g.perm.Admin ){ |
|
9953b16…
|
drh
|
3323 |
@ received <a href="%R/rcvfrom?rcvid=%d(rcvid)">%h(zDate)</a>: |
|
9953b16…
|
drh
|
3324 |
}else{ |
|
9953b16…
|
drh
|
3325 |
@ received %h(zDate): |
|
9953b16…
|
drh
|
3326 |
} |
|
4170e0b…
|
drh
|
3327 |
blob_appendf(&where,"IN(0"); |
|
4170e0b…
|
drh
|
3328 |
for(i=0; i<pCluster->nCChild; i++){ |
|
4170e0b…
|
drh
|
3329 |
int rid = fast_uuid_to_rid(pCluster->azCChild[i]); |
|
4170e0b…
|
drh
|
3330 |
if( rid ){ |
|
4170e0b…
|
drh
|
3331 |
blob_appendf(&where,",%d", rid); |
|
4170e0b…
|
drh
|
3332 |
}else{ |
|
4170e0b…
|
drh
|
3333 |
if( blob_size(&unks)>0 ) blob_append_char(&unks, ','); |
|
4170e0b…
|
drh
|
3334 |
badRid++; |
|
4170e0b…
|
drh
|
3335 |
blob_append_sql(&unks,"(%d,%Q)",-badRid,pCluster->azCChild[i]); |
|
4170e0b…
|
drh
|
3336 |
} |
|
4170e0b…
|
drh
|
3337 |
} |
|
4170e0b…
|
drh
|
3338 |
blob_append_char(&where,')'); |
|
4170e0b…
|
drh
|
3339 |
describe_artifacts(blob_str(&where)); |
|
4170e0b…
|
drh
|
3340 |
blob_reset(&where); |
|
4170e0b…
|
drh
|
3341 |
if( badRid>0 ){ |
|
4170e0b…
|
drh
|
3342 |
db_multi_exec( |
|
4170e0b…
|
drh
|
3343 |
"WITH unks(rx,hx) AS (VALUES %s)\n" |
|
72a218c…
|
drh
|
3344 |
"INSERT INTO description(rid,uuid,type,summary) " |
|
4170e0b…
|
drh
|
3345 |
" SELECT rx, hx, 'phantom', '' FROM unks;", |
|
4170e0b…
|
drh
|
3346 |
blob_sql_text(&unks) |
|
4170e0b…
|
drh
|
3347 |
); |
|
4170e0b…
|
drh
|
3348 |
} |
|
4170e0b…
|
drh
|
3349 |
blob_reset(&unks); |
|
4170e0b…
|
drh
|
3350 |
db_prepare(&q, |
|
4170e0b…
|
drh
|
3351 |
"SELECT rid, uuid, summary, isPrivate, type='phantom', rcvid, ref" |
|
4170e0b…
|
drh
|
3352 |
" FROM description ORDER BY uuid" |
|
4170e0b…
|
drh
|
3353 |
); |
|
4170e0b…
|
drh
|
3354 |
if( skin_detail_boolean("white-foreground") ){ |
|
4170e0b…
|
drh
|
3355 |
zSha1Bg = "#714417"; |
|
4170e0b…
|
drh
|
3356 |
zSha3Bg = "#177117"; |
|
4170e0b…
|
drh
|
3357 |
}else{ |
|
4170e0b…
|
drh
|
3358 |
zSha1Bg = "#ebffb0"; |
|
4170e0b…
|
drh
|
3359 |
zSha3Bg = "#b0ffb0"; |
|
4170e0b…
|
drh
|
3360 |
} |
|
4170e0b…
|
drh
|
3361 |
@ <table cellpadding="2" cellspacing="0" border="1"> |
|
4170e0b…
|
drh
|
3362 |
if( g.perm.Admin ){ |
|
4170e0b…
|
drh
|
3363 |
@ <tr><th>RID<th>Hash<th>Rcvid<th>Description<th>Ref<th>Remarks |
|
4170e0b…
|
drh
|
3364 |
}else{ |
|
4170e0b…
|
drh
|
3365 |
@ <tr><th>RID<th>Hash<th>Description<th>Ref<th>Remarks |
|
4170e0b…
|
drh
|
3366 |
} |
|
4170e0b…
|
drh
|
3367 |
while( db_step(&q)==SQLITE_ROW ){ |
|
4170e0b…
|
drh
|
3368 |
int rid = db_column_int(&q,0); |
|
4170e0b…
|
drh
|
3369 |
const char *zUuid = db_column_text(&q, 1); |
|
4170e0b…
|
drh
|
3370 |
const char *zDesc = db_column_text(&q, 2); |
|
4170e0b…
|
drh
|
3371 |
int isPriv = db_column_int(&q,3); |
|
4170e0b…
|
drh
|
3372 |
int isPhantom = db_column_int(&q,4); |
|
4170e0b…
|
drh
|
3373 |
const char *zRef = db_column_text(&q,6); |
|
4170e0b…
|
drh
|
3374 |
if( isPriv && !isPhantom && !g.perm.Private && !g.perm.Admin ){ |
|
4170e0b…
|
drh
|
3375 |
/* Don't show private artifacts to users without Private (x) permission */ |
|
4170e0b…
|
drh
|
3376 |
continue; |
|
4170e0b…
|
drh
|
3377 |
} |
|
4170e0b…
|
drh
|
3378 |
if( rid<=0 ){ |
|
4170e0b…
|
drh
|
3379 |
@ <tr><td> </td> |
|
4170e0b…
|
drh
|
3380 |
}else if( hashClr ){ |
|
4170e0b…
|
drh
|
3381 |
const char *zClr = db_column_bytes(&q,1)>40 ? zSha3Bg : zSha1Bg; |
|
4170e0b…
|
drh
|
3382 |
@ <tr style='background-color:%s(zClr);'><td align="right">%d(rid)</td> |
|
4170e0b…
|
drh
|
3383 |
}else{ |
|
4170e0b…
|
drh
|
3384 |
@ <tr><td align="right">%d(rid)</td> |
|
4170e0b…
|
drh
|
3385 |
} |
|
4170e0b…
|
drh
|
3386 |
if( rid<=0 ){ |
|
4170e0b…
|
drh
|
3387 |
@ <td> %S(zUuid) </td> |
|
4170e0b…
|
drh
|
3388 |
}else{ |
|
4170e0b…
|
drh
|
3389 |
@ <td> %z(href("%R/info/%!S",zUuid))%S(zUuid)</a> </td> |
|
4170e0b…
|
drh
|
3390 |
} |
|
4170e0b…
|
drh
|
3391 |
if( g.perm.Admin ){ |
|
4170e0b…
|
drh
|
3392 |
int rcvid = db_column_int(&q,5); |
|
4170e0b…
|
drh
|
3393 |
if( rcvid<=0 ){ |
|
4170e0b…
|
drh
|
3394 |
@ <td> |
|
4170e0b…
|
drh
|
3395 |
}else{ |
|
4170e0b…
|
drh
|
3396 |
@ <td><a href='%R/rcvfrom?rcvid=%d(rcvid)'>%d(rcvid)</a> |
|
4170e0b…
|
drh
|
3397 |
} |
|
4170e0b…
|
drh
|
3398 |
} |
|
4170e0b…
|
drh
|
3399 |
@ <td align="left">%h(zDesc)</td> |
|
4170e0b…
|
drh
|
3400 |
if( zRef && zRef[0] ){ |
|
4170e0b…
|
drh
|
3401 |
@ <td>%z(href("%R/info/%!S",zRef))%S(zRef)</a> |
|
4170e0b…
|
drh
|
3402 |
}else{ |
|
4170e0b…
|
drh
|
3403 |
@ <td> |
|
4170e0b…
|
drh
|
3404 |
} |
|
4170e0b…
|
drh
|
3405 |
if( isPriv || isPhantom ){ |
|
4170e0b…
|
drh
|
3406 |
if( isPriv==0 ){ |
|
4170e0b…
|
drh
|
3407 |
@ <td>phantom</td> |
|
4170e0b…
|
drh
|
3408 |
}else if( isPhantom==0 ){ |
|
4170e0b…
|
drh
|
3409 |
@ <td>private</td> |
|
4170e0b…
|
drh
|
3410 |
}else{ |
|
4170e0b…
|
drh
|
3411 |
@ <td>private,phantom</td> |
|
4170e0b…
|
drh
|
3412 |
} |
|
4170e0b…
|
drh
|
3413 |
}else{ |
|
4170e0b…
|
drh
|
3414 |
@ <td> |
|
4170e0b…
|
drh
|
3415 |
} |
|
4170e0b…
|
drh
|
3416 |
@ </tr> |
|
4170e0b…
|
drh
|
3417 |
} |
|
4170e0b…
|
drh
|
3418 |
@ </table> |
|
4170e0b…
|
drh
|
3419 |
db_finalize(&q); |
|
4170e0b…
|
drh
|
3420 |
style_finish_page(); |
|
4170e0b…
|
drh
|
3421 |
} |
|
4170e0b…
|
drh
|
3422 |
|
|
a48474b…
|
drh
|
3423 |
|
|
a48474b…
|
drh
|
3424 |
/* |
|
a48474b…
|
drh
|
3425 |
** WEBPAGE: info |
|
8ad5e46…
|
wyoung
|
3426 |
** URL: info/NAME |
|
a48474b…
|
drh
|
3427 |
** |
|
8ad5e46…
|
wyoung
|
3428 |
** The NAME argument is any valid artifact name: an artifact hash, |
|
8ad5e46…
|
wyoung
|
3429 |
** a timestamp, a tag name, etc. |
|
a48474b…
|
drh
|
3430 |
** |
|
8ad5e46…
|
wyoung
|
3431 |
** Because NAME can match so many different things (commit artifacts, |
|
8ad5e46…
|
wyoung
|
3432 |
** wiki pages, ticket comments, forum posts...) the format of the output |
|
8ad5e46…
|
wyoung
|
3433 |
** page depends on the type of artifact that NAME matches. |
|
a48474b…
|
drh
|
3434 |
*/ |
|
a48474b…
|
drh
|
3435 |
void info_page(void){ |
|
a48474b…
|
drh
|
3436 |
const char *zName; |
|
8745d0d…
|
eric
|
3437 |
Blob uuid; |
|
bf56b2d…
|
drh
|
3438 |
int rid; |
|
2c8ea5f…
|
drh
|
3439 |
int rc; |
|
49467d2…
|
drh
|
3440 |
int nLen; |
|
01050d6…
|
jan.nijtmans
|
3441 |
|
|
a48474b…
|
drh
|
3442 |
zName = P("name"); |
|
a48474b…
|
drh
|
3443 |
if( zName==0 ) fossil_redirect_home(); |
|
57f1e87…
|
drh
|
3444 |
cgi_check_for_malice(); |
|
49467d2…
|
drh
|
3445 |
nLen = strlen(zName); |
|
bf56b2d…
|
drh
|
3446 |
blob_set(&uuid, zName); |
|
49467d2…
|
drh
|
3447 |
if( name_collisions(zName) ){ |
|
49467d2…
|
drh
|
3448 |
cgi_set_parameter("src","info"); |
|
49467d2…
|
drh
|
3449 |
ambiguous_page(); |
|
49467d2…
|
drh
|
3450 |
return; |
|
49467d2…
|
drh
|
3451 |
} |
|
2a013f0…
|
drh
|
3452 |
rc = name_to_uuid(&uuid, -1, "*"); |
|
2c8ea5f…
|
drh
|
3453 |
if( rc==1 ){ |
|
49467d2…
|
drh
|
3454 |
if( validate16(zName, nLen) ){ |
|
49467d2…
|
drh
|
3455 |
if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){ |
|
3d13152…
|
drh
|
3456 |
cgi_set_parameter_nocopy("tl","1",0); |
|
49467d2…
|
drh
|
3457 |
tktview_page(); |
|
49467d2…
|
drh
|
3458 |
return; |
|
49467d2…
|
drh
|
3459 |
} |
|
49467d2…
|
drh
|
3460 |
if( db_exists("SELECT 1 FROM tag" |
|
49467d2…
|
drh
|
3461 |
" WHERE tagname GLOB 'event-%q*'", zName) ){ |
|
49467d2…
|
drh
|
3462 |
event_page(); |
|
49467d2…
|
drh
|
3463 |
return; |
|
49467d2…
|
drh
|
3464 |
} |
|
49467d2…
|
drh
|
3465 |
} |
|
2c8ea5f…
|
drh
|
3466 |
style_header("No Such Object"); |
|
2c8ea5f…
|
drh
|
3467 |
@ <p>No such object: %h(zName)</p> |
|
49467d2…
|
drh
|
3468 |
if( nLen<4 ){ |
|
36ffa74…
|
drh
|
3469 |
@ <p>Object name should be no less than 4 characters. Ten or more |
|
36ffa74…
|
drh
|
3470 |
@ characters are recommended.</p> |
|
49467d2…
|
drh
|
3471 |
} |
|
112c713…
|
drh
|
3472 |
style_finish_page(); |
|
2c8ea5f…
|
drh
|
3473 |
return; |
|
2c8ea5f…
|
drh
|
3474 |
}else if( rc==2 ){ |
|
2c8ea5f…
|
drh
|
3475 |
cgi_set_parameter("src","info"); |
|
2c8ea5f…
|
drh
|
3476 |
ambiguous_page(); |
|
2c8ea5f…
|
drh
|
3477 |
return; |
|
bf56b2d…
|
drh
|
3478 |
} |
|
a3161f5…
|
drh
|
3479 |
zName = blob_str(&uuid); |
|
49b0ff1…
|
drh
|
3480 |
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName); |
|
a48474b…
|
drh
|
3481 |
if( rid==0 ){ |
|
a48474b…
|
drh
|
3482 |
style_header("Broken Link"); |
|
a48474b…
|
drh
|
3483 |
@ <p>No such object: %h(zName)</p> |
|
112c713…
|
drh
|
3484 |
style_finish_page(); |
|
a48474b…
|
drh
|
3485 |
return; |
|
a48474b…
|
drh
|
3486 |
} |
|
a48474b…
|
drh
|
3487 |
if( db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){ |
|
713b8be…
|
drh
|
3488 |
ci_page(); |
|
a48474b…
|
drh
|
3489 |
}else |
|
a48474b…
|
drh
|
3490 |
if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)" |
|
a48474b…
|
drh
|
3491 |
" WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){ |
|
a48474b…
|
drh
|
3492 |
winfo_page(); |
|
a48474b…
|
drh
|
3493 |
}else |
|
b3ee50c…
|
drh
|
3494 |
if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)" |
|
b3ee50c…
|
drh
|
3495 |
" WHERE rid=%d AND tagname LIKE 'tkt-%%'", rid) ){ |
|
b3ee50c…
|
drh
|
3496 |
tinfo_page(); |
|
b3ee50c…
|
drh
|
3497 |
}else |
|
81ab302…
|
drh
|
3498 |
if( db_table_exists("repository","forumpost") |
|
81ab302…
|
drh
|
3499 |
&& db_exists("SELECT 1 FROM forumpost WHERE fpid=%d", rid) |
|
81ab302…
|
drh
|
3500 |
){ |
|
81ab302…
|
drh
|
3501 |
forumthread_page(); |
|
81ab302…
|
drh
|
3502 |
}else |
|
3b3116e…
|
drh
|
3503 |
if( db_exists("SELECT 1 FROM plink WHERE cid=%d", rid) ){ |
|
9be1b00…
|
drh
|
3504 |
ci_page(); |
|
9c89b0e…
|
drh
|
3505 |
}else |
|
9c89b0e…
|
drh
|
3506 |
if( db_exists("SELECT 1 FROM plink WHERE pid=%d", rid) ){ |
|
9be1b00…
|
drh
|
3507 |
ci_page(); |
|
4892882…
|
drh
|
3508 |
}else |
|
ba418ee…
|
drh
|
3509 |
if( db_exists("SELECT 1 FROM attachment WHERE attachid=%d", rid) ){ |
|
ba418ee…
|
drh
|
3510 |
ainfo_page(); |
|
99fcc43…
|
drh
|
3511 |
}else |
|
4170e0b…
|
drh
|
3512 |
if( db_exists("SELECT 1 FROM tagxref WHERE rid=%d AND tagid=%d", |
|
4170e0b…
|
drh
|
3513 |
rid, TAG_CLUSTER) ){ |
|
4170e0b…
|
drh
|
3514 |
cluster_info(rid, zName); |
|
4170e0b…
|
drh
|
3515 |
}else |
|
a48474b…
|
drh
|
3516 |
{ |
|
a48474b…
|
drh
|
3517 |
artifact_page(); |
|
f0474b8…
|
drh
|
3518 |
} |
|
f0474b8…
|
drh
|
3519 |
} |
|
f0474b8…
|
drh
|
3520 |
|
|
f0474b8…
|
drh
|
3521 |
/* |
|
4892882…
|
drh
|
3522 |
** Do a comment comparison. |
|
4892882…
|
drh
|
3523 |
** |
|
4892882…
|
drh
|
3524 |
** + Leading and trailing whitespace are ignored. |
|
4892882…
|
drh
|
3525 |
** + \r\n characters compare equal to \n |
|
4892882…
|
drh
|
3526 |
** |
|
4892882…
|
drh
|
3527 |
** Return true if equal and false if not equal. |
|
4892882…
|
drh
|
3528 |
*/ |
|
4892882…
|
drh
|
3529 |
static int comment_compare(const char *zA, const char *zB){ |
|
4892882…
|
drh
|
3530 |
if( zA==0 ) zA = ""; |
|
4892882…
|
drh
|
3531 |
if( zB==0 ) zB = ""; |
|
4892882…
|
drh
|
3532 |
while( fossil_isspace(zA[0]) ) zA++; |
|
4892882…
|
drh
|
3533 |
while( fossil_isspace(zB[0]) ) zB++; |
|
4892882…
|
drh
|
3534 |
while( zA[0] && zB[0] ){ |
|
4892882…
|
drh
|
3535 |
if( zA[0]==zB[0] ){ zA++; zB++; continue; } |
|
4892882…
|
drh
|
3536 |
if( zA[0]=='\r' && zA[1]=='\n' && zB[0]=='\n' ){ |
|
4892882…
|
drh
|
3537 |
zA += 2; |
|
4892882…
|
drh
|
3538 |
zB++; |
|
4892882…
|
drh
|
3539 |
continue; |
|
4892882…
|
drh
|
3540 |
} |
|
4892882…
|
drh
|
3541 |
if( zB[0]=='\r' && zB[1]=='\n' && zA[0]=='\n' ){ |
|
4892882…
|
drh
|
3542 |
zB += 2; |
|
4892882…
|
drh
|
3543 |
zA++; |
|
4892882…
|
drh
|
3544 |
continue; |
|
4892882…
|
drh
|
3545 |
} |
|
4892882…
|
drh
|
3546 |
return 0; |
|
4892882…
|
drh
|
3547 |
} |
|
4892882…
|
drh
|
3548 |
while( fossil_isspace(zB[0]) ) zB++; |
|
4892882…
|
drh
|
3549 |
while( fossil_isspace(zA[0]) ) zA++; |
|
4892882…
|
drh
|
3550 |
return zA[0]==0 && zB[0]==0; |
|
4892882…
|
drh
|
3551 |
} |
|
4892882…
|
drh
|
3552 |
|
|
4892882…
|
drh
|
3553 |
/* |
|
e454028…
|
drh
|
3554 |
***************************************************************************** |
|
e454028…
|
drh
|
3555 |
** The following methods operate on the "newtags" temporary table. This |
|
e454028…
|
drh
|
3556 |
** table collects changes for a control artifact that will implement an |
|
e454028…
|
drh
|
3557 |
** edit to a check-in. |
|
e454028…
|
drh
|
3558 |
** |
|
e454028…
|
drh
|
3559 |
** Initialize the newtags table |
|
c73c95c…
|
andybradford
|
3560 |
*/ |
|
c73c95c…
|
andybradford
|
3561 |
static void init_newtags(void){ |
|
c73c95c…
|
andybradford
|
3562 |
db_multi_exec("CREATE TEMP TABLE newtags(tag UNIQUE, prefix, value)"); |
|
c73c95c…
|
andybradford
|
3563 |
} |
|
c73c95c…
|
andybradford
|
3564 |
|
|
e454028…
|
drh
|
3565 |
/* Add a new changes to the newtags table */ |
|
c73c95c…
|
andybradford
|
3566 |
static void change_special( |
|
c73c95c…
|
andybradford
|
3567 |
const char *zName, /* Name of the special tag */ |
|
c73c95c…
|
andybradford
|
3568 |
const char *zOp, /* Operation prefix (e.g. +,-,*) */ |
|
c73c95c…
|
andybradford
|
3569 |
const char *zValue /* Value of the tag */ |
|
c73c95c…
|
andybradford
|
3570 |
){ |
|
c73c95c…
|
andybradford
|
3571 |
db_multi_exec("REPLACE INTO newtags VALUES(%Q,'%q',%Q)", zName, zOp, zValue); |
|
c73c95c…
|
andybradford
|
3572 |
} |
|
c73c95c…
|
andybradford
|
3573 |
|
|
e454028…
|
drh
|
3574 |
/* Change a symbolic tag */ |
|
c73c95c…
|
andybradford
|
3575 |
static void change_sym_tag(const char *zTag, const char *zOp){ |
|
c73c95c…
|
andybradford
|
3576 |
db_multi_exec("REPLACE INTO newtags VALUES('sym-%q',%Q,NULL)", zTag, zOp); |
|
c73c95c…
|
andybradford
|
3577 |
} |
|
c73c95c…
|
andybradford
|
3578 |
|
|
e454028…
|
drh
|
3579 |
/* Cancel a tag */ |
|
c73c95c…
|
andybradford
|
3580 |
static void cancel_special(const char *zTag){ |
|
c73c95c…
|
andybradford
|
3581 |
change_special(zTag,"-",0); |
|
c73c95c…
|
andybradford
|
3582 |
} |
|
c73c95c…
|
andybradford
|
3583 |
|
|
e454028…
|
drh
|
3584 |
/* Add a background color tag. This will be propagating tag |
|
e454028…
|
drh
|
3585 |
** if fPropagateColor is true. */ |
|
c73c95c…
|
andybradford
|
3586 |
static void add_color(const char *zNewColor, int fPropagateColor){ |
|
c73c95c…
|
andybradford
|
3587 |
change_special("bgcolor",fPropagateColor ? "*" : "+", zNewColor); |
|
c73c95c…
|
andybradford
|
3588 |
} |
|
c73c95c…
|
andybradford
|
3589 |
|
|
e454028…
|
drh
|
3590 |
/* Cancel a background color tag */ |
|
c73c95c…
|
andybradford
|
3591 |
static void cancel_color(void){ |
|
c73c95c…
|
andybradford
|
3592 |
change_special("bgcolor","-",0); |
|
c73c95c…
|
andybradford
|
3593 |
} |
|
c73c95c…
|
andybradford
|
3594 |
|
|
e454028…
|
drh
|
3595 |
/* Add a comment-change tag */ |
|
c73c95c…
|
andybradford
|
3596 |
static void add_comment(const char *zNewComment){ |
|
c73c95c…
|
andybradford
|
3597 |
change_special("comment","+",zNewComment); |
|
c73c95c…
|
andybradford
|
3598 |
} |
|
c73c95c…
|
andybradford
|
3599 |
|
|
e454028…
|
drh
|
3600 |
/* Add a date-change tag */ |
|
c73c95c…
|
andybradford
|
3601 |
static void add_date(const char *zNewDate){ |
|
c73c95c…
|
andybradford
|
3602 |
change_special("date","+",zNewDate); |
|
c73c95c…
|
andybradford
|
3603 |
} |
|
c73c95c…
|
andybradford
|
3604 |
|
|
e454028…
|
drh
|
3605 |
/* Add a change-user tag */ |
|
c73c95c…
|
andybradford
|
3606 |
static void add_user(const char *zNewUser){ |
|
c73c95c…
|
andybradford
|
3607 |
change_special("user","+",zNewUser); |
|
c73c95c…
|
andybradford
|
3608 |
} |
|
c73c95c…
|
andybradford
|
3609 |
|
|
e454028…
|
drh
|
3610 |
/* Add a generic symbolic tag (one that has no value) */ |
|
c73c95c…
|
andybradford
|
3611 |
static void add_tag(const char *zNewTag){ |
|
c73c95c…
|
andybradford
|
3612 |
change_sym_tag(zNewTag,"+"); |
|
c73c95c…
|
andybradford
|
3613 |
} |
|
c73c95c…
|
andybradford
|
3614 |
|
|
e454028…
|
drh
|
3615 |
/* Cancel an existing symbolic tag associated with check-in rid */ |
|
c73c95c…
|
andybradford
|
3616 |
static void cancel_tag(int rid, const char *zCancelTag){ |
|
c73c95c…
|
andybradford
|
3617 |
if( db_exists("SELECT 1 FROM tagxref, tag" |
|
c73c95c…
|
andybradford
|
3618 |
" WHERE tagxref.rid=%d AND tagtype>0" |
|
c73c95c…
|
andybradford
|
3619 |
" AND tagxref.tagid=tag.tagid AND tagname='sym-%q'", |
|
c73c95c…
|
andybradford
|
3620 |
rid, zCancelTag) |
|
e454028…
|
drh
|
3621 |
){ |
|
e454028…
|
drh
|
3622 |
change_sym_tag(zCancelTag,"-"); |
|
e454028…
|
drh
|
3623 |
} |
|
c73c95c…
|
andybradford
|
3624 |
} |
|
c73c95c…
|
andybradford
|
3625 |
|
|
e454028…
|
drh
|
3626 |
/* Add a hidden tag that propagates to all ancestors */ |
|
c73c95c…
|
andybradford
|
3627 |
static void hide_branch(void){ |
|
c73c95c…
|
andybradford
|
3628 |
change_special("hidden","*",0); |
|
c73c95c…
|
andybradford
|
3629 |
} |
|
c73c95c…
|
andybradford
|
3630 |
|
|
e454028…
|
drh
|
3631 |
/* Close the branch */ |
|
c73c95c…
|
andybradford
|
3632 |
static void close_leaf(int rid){ |
|
c73c95c…
|
andybradford
|
3633 |
change_special("closed",is_a_leaf(rid)?"+":"*",0); |
|
c73c95c…
|
andybradford
|
3634 |
} |
|
c73c95c…
|
andybradford
|
3635 |
|
|
e454028…
|
drh
|
3636 |
/* Move the check-in to a different branch */ |
|
c73c95c…
|
andybradford
|
3637 |
static void change_branch(int rid, const char *zNewBranch){ |
|
c73c95c…
|
andybradford
|
3638 |
db_multi_exec( |
|
c73c95c…
|
andybradford
|
3639 |
"REPLACE INTO newtags " |
|
c73c95c…
|
andybradford
|
3640 |
" SELECT tagname, '-', NULL FROM tagxref, tag" |
|
c73c95c…
|
andybradford
|
3641 |
" WHERE tagxref.rid=%d AND tagtype==2" |
|
c73c95c…
|
andybradford
|
3642 |
" AND tagname GLOB 'sym-*'" |
|
c73c95c…
|
andybradford
|
3643 |
" AND tag.tagid=tagxref.tagid", |
|
c73c95c…
|
andybradford
|
3644 |
rid |
|
c73c95c…
|
andybradford
|
3645 |
); |
|
c73c95c…
|
andybradford
|
3646 |
change_special("branch","*",zNewBranch); |
|
c73c95c…
|
andybradford
|
3647 |
change_sym_tag(zNewBranch,"*"); |
|
c73c95c…
|
andybradford
|
3648 |
} |
|
c73c95c…
|
andybradford
|
3649 |
|
|
c73c95c…
|
andybradford
|
3650 |
/* |
|
e454028…
|
drh
|
3651 |
** Construct a control artifact. |
|
e454028…
|
drh
|
3652 |
** |
|
e454028…
|
drh
|
3653 |
** Preconditions: |
|
e454028…
|
drh
|
3654 |
** |
|
e454028…
|
drh
|
3655 |
** (1) "ctrl" contains the beginning of a control artifact with |
|
e454028…
|
drh
|
3656 |
** just the D-card showing the timestamp on the control artifact |
|
e454028…
|
drh
|
3657 |
** itself. |
|
e454028…
|
drh
|
3658 |
** |
|
e454028…
|
drh
|
3659 |
** (2) The newtags temporary table has been constructed. |
|
e454028…
|
drh
|
3660 |
** |
|
e454028…
|
drh
|
3661 |
** (3) Zero or more methods may have been called to populate the |
|
e454028…
|
drh
|
3662 |
** newtags table. Or the newtags table might be empty. |
|
e454028…
|
drh
|
3663 |
** |
|
e454028…
|
drh
|
3664 |
** Construct the complete control artifact. Or, if there are not |
|
e454028…
|
drh
|
3665 |
** changes, just zero out the ctrl blob. |
|
c73c95c…
|
andybradford
|
3666 |
*/ |
|
e454028…
|
drh
|
3667 |
static void construct_newtags_artifact( |
|
e454028…
|
drh
|
3668 |
Blob *ctrl, /* The control artifact text */ |
|
e454028…
|
drh
|
3669 |
int rid, /* rid of the check-in that the artifact applies to */ |
|
e454028…
|
drh
|
3670 |
const char *zUuid, /* UUID of the check-in to which the artifact applies*/ |
|
e454028…
|
drh
|
3671 |
const char *zUserOvrd /* The user name on the control artifact */ |
|
5c99557…
|
drh
|
3672 |
){ |
|
c73c95c…
|
andybradford
|
3673 |
Stmt q; |
|
c73c95c…
|
andybradford
|
3674 |
int nChng = 0; |
|
c73c95c…
|
andybradford
|
3675 |
|
|
c73c95c…
|
andybradford
|
3676 |
db_prepare(&q, "SELECT tag, prefix, value FROM newtags" |
|
c73c95c…
|
andybradford
|
3677 |
" ORDER BY prefix || tag"); |
|
c73c95c…
|
andybradford
|
3678 |
while( db_step(&q)==SQLITE_ROW ){ |
|
c73c95c…
|
andybradford
|
3679 |
const char *zTag = db_column_text(&q, 0); |
|
c73c95c…
|
andybradford
|
3680 |
const char *zPrefix = db_column_text(&q, 1); |
|
c73c95c…
|
andybradford
|
3681 |
const char *zValue = db_column_text(&q, 2); |
|
c73c95c…
|
andybradford
|
3682 |
nChng++; |
|
c73c95c…
|
andybradford
|
3683 |
if( zValue ){ |
|
c73c95c…
|
andybradford
|
3684 |
blob_appendf(ctrl, "T %s%F %s %F\n", zPrefix, zTag, zUuid, zValue); |
|
c73c95c…
|
andybradford
|
3685 |
}else{ |
|
c73c95c…
|
andybradford
|
3686 |
blob_appendf(ctrl, "T %s%F %s\n", zPrefix, zTag, zUuid); |
|
c73c95c…
|
andybradford
|
3687 |
} |
|
c73c95c…
|
andybradford
|
3688 |
} |
|
c73c95c…
|
andybradford
|
3689 |
db_finalize(&q); |
|
c73c95c…
|
andybradford
|
3690 |
if( nChng>0 ){ |
|
c73c95c…
|
andybradford
|
3691 |
Blob cksum; |
|
5c99557…
|
drh
|
3692 |
if( zUserOvrd && zUserOvrd[0] ){ |
|
5c99557…
|
drh
|
3693 |
blob_appendf(ctrl, "U %F\n", zUserOvrd); |
|
5c99557…
|
drh
|
3694 |
}else{ |
|
5c99557…
|
drh
|
3695 |
blob_appendf(ctrl, "U %F\n", login_name()); |
|
5c99557…
|
drh
|
3696 |
} |
|
c73c95c…
|
andybradford
|
3697 |
md5sum_blob(ctrl, &cksum); |
|
c73c95c…
|
andybradford
|
3698 |
blob_appendf(ctrl, "Z %b\n", &cksum); |
|
e454028…
|
drh
|
3699 |
blob_reset(&cksum); |
|
e454028…
|
drh
|
3700 |
}else{ |
|
e454028…
|
drh
|
3701 |
blob_reset(ctrl); |
|
e454028…
|
drh
|
3702 |
} |
|
e454028…
|
drh
|
3703 |
} |
|
e454028…
|
drh
|
3704 |
|
|
e454028…
|
drh
|
3705 |
/* |
|
e454028…
|
drh
|
3706 |
** Return true if the artifact is complete. We assume that any non-empty |
|
e454028…
|
drh
|
3707 |
** artifact is complete. |
|
e454028…
|
drh
|
3708 |
*/ |
|
e454028…
|
drh
|
3709 |
static int artifact_is_complete(Blob *ctrl){ |
|
e454028…
|
drh
|
3710 |
return blob_size(ctrl)>0; |
|
e454028…
|
drh
|
3711 |
} |
|
e454028…
|
drh
|
3712 |
|
|
e454028…
|
drh
|
3713 |
/* |
|
e454028…
|
drh
|
3714 |
** Apply a control artifact to the repository database. Except, if the |
|
e454028…
|
drh
|
3715 |
** artifact is empty, this routine is a no-op. |
|
e454028…
|
drh
|
3716 |
*/ |
|
e454028…
|
drh
|
3717 |
static void publish_newtags_artifact(Blob *ctrl, int rid){ |
|
e454028…
|
drh
|
3718 |
if( artifact_is_complete(ctrl) ){ |
|
e454028…
|
drh
|
3719 |
int nrid; |
|
e454028…
|
drh
|
3720 |
g.markPrivate = content_is_private(rid); |
|
e454028…
|
drh
|
3721 |
nrid = content_put(ctrl); |
|
e454028…
|
drh
|
3722 |
manifest_crosslink(nrid, ctrl, MC_PERMIT_HOOKS); |
|
c73c95c…
|
andybradford
|
3723 |
} |
|
c73c95c…
|
andybradford
|
3724 |
} |
|
e454028…
|
drh
|
3725 |
/* End of the newtags subsystem |
|
e454028…
|
drh
|
3726 |
******************************************************************************/ |
|
c73c95c…
|
andybradford
|
3727 |
|
|
c73c95c…
|
andybradford
|
3728 |
/* |
|
c73c95c…
|
andybradford
|
3729 |
** This method checks that the date can be parsed. |
|
c73c95c…
|
andybradford
|
3730 |
** Returns 1 if datetime() can validate, 0 otherwise. |
|
c73c95c…
|
andybradford
|
3731 |
*/ |
|
c73c95c…
|
andybradford
|
3732 |
int is_datetime(const char* zDate){ |
|
c73c95c…
|
andybradford
|
3733 |
return db_int(0, "SELECT datetime(%Q) NOT NULL", zDate); |
|
c73c95c…
|
andybradford
|
3734 |
} |
|
c73c95c…
|
andybradford
|
3735 |
|
|
c73c95c…
|
andybradford
|
3736 |
/* |
|
9be1b00…
|
drh
|
3737 |
** WEBPAGE: ci_edit |
|
f8bc3ce…
|
drh
|
3738 |
** |
|
f8bc3ce…
|
drh
|
3739 |
** Edit a check-in. (Check-ins are immutable and do not really change. |
|
f8bc3ce…
|
drh
|
3740 |
** This page really creates supplemental tags that affect the display |
|
f8bc3ce…
|
drh
|
3741 |
** of the check-in.) |
|
f8bc3ce…
|
drh
|
3742 |
** |
|
7dd07b2…
|
drh
|
3743 |
** Query parameters: |
|
f8bc3ce…
|
drh
|
3744 |
** |
|
f8bc3ce…
|
drh
|
3745 |
** rid=INTEGER Record ID of the check-in to edit (REQUIRED) |
|
f8bc3ce…
|
drh
|
3746 |
** |
|
7dd07b2…
|
drh
|
3747 |
** POST parameters after pressing "Preview", "Cancel", or "Apply": |
|
f8bc3ce…
|
drh
|
3748 |
** |
|
f8bc3ce…
|
drh
|
3749 |
** c=TEXT New check-in comment |
|
f8bc3ce…
|
drh
|
3750 |
** u=TEXT New user name |
|
f8bc3ce…
|
drh
|
3751 |
** newclr Apply a background color |
|
f8bc3ce…
|
drh
|
3752 |
** clr=TEXT New background color (only if newclr) |
|
f8bc3ce…
|
drh
|
3753 |
** pclr Propagate new background color (only if newclr) |
|
f8bc3ce…
|
drh
|
3754 |
** dt=TEXT New check-in date/time (ISO8610 format) |
|
f8bc3ce…
|
drh
|
3755 |
** newtag Add a new tag to the check-in |
|
f8bc3ce…
|
drh
|
3756 |
** tagname=TEXT Name of the new tag to be added (only if newtag) |
|
f8bc3ce…
|
drh
|
3757 |
** newbr Put the check-in on a new branch |
|
f8bc3ce…
|
drh
|
3758 |
** brname=TEXT Name of the new branch (only if newbr) |
|
f8bc3ce…
|
drh
|
3759 |
** close Close this check-in |
|
f8bc3ce…
|
drh
|
3760 |
** hide Hide this check-in |
|
f8bc3ce…
|
drh
|
3761 |
** cNNN Cancel tag with tagid=NNN |
|
f8bc3ce…
|
drh
|
3762 |
** |
|
f8bc3ce…
|
drh
|
3763 |
** cancel Cancel the edit. Return to the check-in view |
|
f8bc3ce…
|
drh
|
3764 |
** preview Show a preview of the edited check-in comment |
|
f8bc3ce…
|
drh
|
3765 |
** apply Apply changes |
|
9be1b00…
|
drh
|
3766 |
*/ |
|
9be1b00…
|
drh
|
3767 |
void ci_edit_page(void){ |
|
f0474b8…
|
drh
|
3768 |
int rid; |
|
ac03d43…
|
drh
|
3769 |
const char *zComment; /* Current comment on the check-in */ |
|
ac03d43…
|
drh
|
3770 |
const char *zNewComment; /* Revised check-in comment */ |
|
ac03d43…
|
drh
|
3771 |
const char *zUser; /* Current user for the check-in */ |
|
ac03d43…
|
drh
|
3772 |
const char *zNewUser; /* Revised user */ |
|
ac03d43…
|
drh
|
3773 |
const char *zDate; /* Current date of the check-in */ |
|
ac03d43…
|
drh
|
3774 |
const char *zNewDate; /* Revised check-in date */ |
|
f8bc3ce…
|
drh
|
3775 |
const char *zNewColorFlag; /* "checked" if "Change color" is checked */ |
|
f8bc3ce…
|
drh
|
3776 |
const char *zColor; /* Current background color */ |
|
f8bc3ce…
|
drh
|
3777 |
const char *zNewColor; /* Revised background color */ |
|
f8bc3ce…
|
drh
|
3778 |
const char *zNewTagFlag; /* "checked" if "Add tag" is checked */ |
|
f8bc3ce…
|
drh
|
3779 |
const char *zNewTag; /* Name of the new tag */ |
|
f8bc3ce…
|
drh
|
3780 |
const char *zNewBrFlag; /* "checked" if "New branch" is checked */ |
|
f8bc3ce…
|
drh
|
3781 |
const char *zNewBranch; /* Name of the new branch */ |
|
f8bc3ce…
|
drh
|
3782 |
const char *zCloseFlag; /* "checked" if "Close" is checked */ |
|
f8bc3ce…
|
drh
|
3783 |
const char *zHideFlag; /* "checked" if "Hide" is checked */ |
|
2080d52…
|
drh
|
3784 |
int fPropagateColor; /* True if color propagates before edit */ |
|
2080d52…
|
drh
|
3785 |
int fNewPropagateColor; /* True if color propagates after edit */ |
|
22a4e0c…
|
jan.nijtmans
|
3786 |
int fHasHidden = 0; /* True if hidden tag already set */ |
|
64c21ef…
|
jan.nijtmans
|
3787 |
int fHasClosed = 0; /* True if closed tag already set */ |
|
f8bc3ce…
|
drh
|
3788 |
const char *zChngTime = 0; /* Value of chngtime= query param, if any */ |
|
e454028…
|
drh
|
3789 |
int bApply = P("apply")!=0; |
|
e454028…
|
drh
|
3790 |
int bPreview = P("preview")!=0; |
|
f0474b8…
|
drh
|
3791 |
char *zUuid; |
|
f0474b8…
|
drh
|
3792 |
Blob comment; |
|
2cb54f3…
|
jan.nijtmans
|
3793 |
char *zBranchName = 0; |
|
42c2a18…
|
drh
|
3794 |
Stmt q; |
|
e454028…
|
drh
|
3795 |
Blob ctrl; /* The generated control artifact */ |
|
01050d6…
|
jan.nijtmans
|
3796 |
|
|
f0474b8…
|
drh
|
3797 |
login_check_credentials(); |
|
653dd40…
|
drh
|
3798 |
if( !g.perm.Write ){ login_needed(g.anon.Write); return; } |
|
2a013f0…
|
drh
|
3799 |
rid = name_to_typed_rid(P("r"), "ci"); |
|
42c2a18…
|
drh
|
3800 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
f0474b8…
|
drh
|
3801 |
zComment = db_text(0, "SELECT coalesce(ecomment,comment)" |
|
f0474b8…
|
drh
|
3802 |
" FROM event WHERE objid=%d", rid); |
|
f0474b8…
|
drh
|
3803 |
if( zComment==0 ) fossil_redirect_home(); |
|
42c2a18…
|
drh
|
3804 |
if( P("cancel") ){ |
|
f8bc3ce…
|
drh
|
3805 |
cgi_redirectf("%R/ci/%S", zUuid); |
|
42c2a18…
|
drh
|
3806 |
} |
|
ca72f02…
|
drh
|
3807 |
if( g.perm.Setup ) zChngTime = P("chngtime"); |
|
f0474b8…
|
drh
|
3808 |
zNewComment = PD("c",zComment); |
|
f0474b8…
|
drh
|
3809 |
zUser = db_text(0, "SELECT coalesce(euser,user)" |
|
f0474b8…
|
drh
|
3810 |
" FROM event WHERE objid=%d", rid); |
|
f0474b8…
|
drh
|
3811 |
if( zUser==0 ) fossil_redirect_home(); |
|
655e782…
|
drh
|
3812 |
zNewUser = PDT("u",zUser); |
|
ac03d43…
|
drh
|
3813 |
zDate = db_text(0, "SELECT datetime(mtime)" |
|
ac03d43…
|
drh
|
3814 |
" FROM event WHERE objid=%d", rid); |
|
ac03d43…
|
drh
|
3815 |
if( zDate==0 ) fossil_redirect_home(); |
|
655e782…
|
drh
|
3816 |
zNewDate = PDT("dt",zDate); |
|
b7f32a7…
|
drh
|
3817 |
zColor = db_text("", "SELECT bgcolor" |
|
b7f32a7…
|
drh
|
3818 |
" FROM event WHERE objid=%d", rid); |
|
655e782…
|
drh
|
3819 |
zNewColor = PDT("clr",zColor); |
|
2080d52…
|
drh
|
3820 |
fPropagateColor = db_int(0, "SELECT tagtype FROM tagxref" |
|
2080d52…
|
drh
|
3821 |
" WHERE rid=%d AND tagid=%d", |
|
2080d52…
|
drh
|
3822 |
rid, TAG_BGCOLOR)==2; |
|
2080d52…
|
drh
|
3823 |
fNewPropagateColor = P("clr")!=0 ? P("pclr")!=0 : fPropagateColor; |
|
f8bc3ce…
|
drh
|
3824 |
zNewColorFlag = P("newclr") ? " checked" : ""; |
|
73c23a4…
|
drh
|
3825 |
zNewTagFlag = P("newtag") ? " checked" : ""; |
|
655e782…
|
drh
|
3826 |
zNewTag = PDT("tagname",""); |
|
73c23a4…
|
drh
|
3827 |
zNewBrFlag = P("newbr") ? " checked" : ""; |
|
655e782…
|
drh
|
3828 |
zNewBranch = PDT("brname",""); |
|
8dbe5dd…
|
drh
|
3829 |
zBranchName = branch_of_rid(rid); |
|
73c23a4…
|
drh
|
3830 |
zCloseFlag = P("close") ? " checked" : ""; |
|
22a4e0c…
|
jan.nijtmans
|
3831 |
zHideFlag = P("hide") ? " checked" : ""; |
|
e454028…
|
drh
|
3832 |
blob_zero(&ctrl); |
|
e454028…
|
drh
|
3833 |
if( bApply && !cgi_csrf_safe(2) ) bApply = 0; |
|
e454028…
|
drh
|
3834 |
if( bApply || bPreview ){ |
|
e454028…
|
drh
|
3835 |
char *zNow = date_in_standard_format(zChngTime ? zChngTime : "now"); |
|
b230721…
|
drh
|
3836 |
blob_appendf(&ctrl, "D %s\n", zNow); |
|
c73c95c…
|
andybradford
|
3837 |
init_newtags(); |
|
f8bc3ce…
|
drh
|
3838 |
if( zNewColorFlag[0] |
|
f8bc3ce…
|
drh
|
3839 |
&& zNewColor[0] |
|
01050d6…
|
jan.nijtmans
|
3840 |
&& (fPropagateColor!=fNewPropagateColor |
|
4892882…
|
drh
|
3841 |
|| fossil_strcmp(zColor,zNewColor)!=0) |
|
f8bc3ce…
|
drh
|
3842 |
){ |
|
f8bc3ce…
|
drh
|
3843 |
add_color(zNewColor,fNewPropagateColor); |
|
f8bc3ce…
|
drh
|
3844 |
} |
|
c73c95c…
|
andybradford
|
3845 |
if( comment_compare(zComment,zNewComment)==0 ) add_comment(zNewComment); |
|
c73c95c…
|
andybradford
|
3846 |
if( fossil_strcmp(zDate,zNewDate)!=0 ) add_date(zNewDate); |
|
c73c95c…
|
andybradford
|
3847 |
if( fossil_strcmp(zUser,zNewUser)!=0 ) add_user(zNewUser); |
|
73c23a4…
|
drh
|
3848 |
db_prepare(&q, |
|
73c23a4…
|
drh
|
3849 |
"SELECT tag.tagid, tagname FROM tagxref, tag" |
|
73c23a4…
|
drh
|
3850 |
" WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid", |
|
73c23a4…
|
drh
|
3851 |
rid |
|
73c23a4…
|
drh
|
3852 |
); |
|
42c2a18…
|
drh
|
3853 |
while( db_step(&q)==SQLITE_ROW ){ |
|
73c23a4…
|
drh
|
3854 |
int tagid = db_column_int(&q, 0); |
|
73c23a4…
|
drh
|
3855 |
const char *zTag = db_column_text(&q, 1); |
|
73c23a4…
|
drh
|
3856 |
char zLabel[30]; |
|
bbbb35a…
|
drh
|
3857 |
sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid); |
|
c73c95c…
|
andybradford
|
3858 |
if( P(zLabel) ) cancel_special(zTag); |
|
c73c95c…
|
andybradford
|
3859 |
} |
|
c73c95c…
|
andybradford
|
3860 |
db_finalize(&q); |
|
c73c95c…
|
andybradford
|
3861 |
if( zHideFlag[0] ) hide_branch(); |
|
c73c95c…
|
andybradford
|
3862 |
if( zCloseFlag[0] ) close_leaf(rid); |
|
c73c95c…
|
andybradford
|
3863 |
if( zNewTagFlag[0] && zNewTag[0] ) add_tag(zNewTag); |
|
c73c95c…
|
andybradford
|
3864 |
if( zNewBrFlag[0] && zNewBranch[0] ) change_branch(rid,zNewBranch); |
|
e454028…
|
drh
|
3865 |
construct_newtags_artifact(&ctrl, rid, zUuid, 0); |
|
e454028…
|
drh
|
3866 |
if( bApply ){ |
|
e454028…
|
drh
|
3867 |
if( artifact_is_complete(&ctrl) ){ |
|
e454028…
|
drh
|
3868 |
db_begin_transaction(); |
|
e454028…
|
drh
|
3869 |
publish_newtags_artifact(&ctrl, rid); |
|
e454028…
|
drh
|
3870 |
db_end_transaction(0); |
|
e454028…
|
drh
|
3871 |
blob_reset(&ctrl); |
|
e454028…
|
drh
|
3872 |
} |
|
e454028…
|
drh
|
3873 |
cgi_redirectf("%R/ci/%S", zUuid); |
|
e454028…
|
drh
|
3874 |
} |
|
89de100…
|
drh
|
3875 |
} |
|
89de100…
|
drh
|
3876 |
blob_zero(&comment); |
|
89de100…
|
drh
|
3877 |
blob_append(&comment, zNewComment, -1); |
|
e454028…
|
drh
|
3878 |
style_header("Edit Check-in %S", zUuid); |
|
e454028…
|
drh
|
3879 |
@ <div class="section accordion">Original Context Around \ |
|
e454028…
|
drh
|
3880 |
@ Check-in %S(zUuid) on %s(zDate)</div> |
|
e454028…
|
drh
|
3881 |
@ <div class="accordion_panel"> |
|
e454028…
|
drh
|
3882 |
render_checkin_context(rid, 0, 2, 0); |
|
e454028…
|
drh
|
3883 |
@ </div> |
|
e454028…
|
drh
|
3884 |
if( bPreview ){ |
|
e454028…
|
drh
|
3885 |
@ <div class="section accordion">After The Proposed Changes</div> |
|
e454028…
|
drh
|
3886 |
@ <div class="accordion_panel"> |
|
e454028…
|
drh
|
3887 |
db_begin_transaction(); |
|
e454028…
|
drh
|
3888 |
publish_newtags_artifact(&ctrl, rid); |
|
e454028…
|
drh
|
3889 |
render_checkin_context(rid, 0, 2, 0); |
|
e454028…
|
drh
|
3890 |
db_end_transaction(1); |
|
e454028…
|
drh
|
3891 |
@ </div> |
|
e454028…
|
drh
|
3892 |
} |
|
e454028…
|
drh
|
3893 |
@ <div class="section accordion">Proposed Changes For \ |
|
e454028…
|
drh
|
3894 |
@ Check-In %S(zUuid):</div> |
|
e454028…
|
drh
|
3895 |
@ <div class="accordion_panel"> |
|
920ace1…
|
drh
|
3896 |
form_begin(0, "%R/ci_edit"); |
|
f5482a0…
|
wyoung
|
3897 |
@ <div><input type="hidden" name="r" value="%s(zUuid)"> |
|
b7f32a7…
|
drh
|
3898 |
@ <table border="0" cellspacing="10"> |
|
b7f32a7…
|
drh
|
3899 |
|
|
a60b008…
|
joel
|
3900 |
@ <tr><th align="right" valign="top">User:</th> |
|
b7f32a7…
|
drh
|
3901 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
3902 |
@ <input type="text" name="u" size="20" value="%h(zNewUser)"> |
|
b7f32a7…
|
drh
|
3903 |
@ </td></tr> |
|
b7f32a7…
|
drh
|
3904 |
|
|
a60b008…
|
joel
|
3905 |
@ <tr><th align="right" valign="top">Comment:</th> |
|
b7f32a7…
|
drh
|
3906 |
@ <td valign="top"> |
|
b7f32a7…
|
drh
|
3907 |
@ <textarea name="c" rows="10" cols="80">%h(zNewComment)</textarea> |
|
b7f32a7…
|
drh
|
3908 |
@ </td></tr> |
|
b7f32a7…
|
drh
|
3909 |
|
|
a60b008…
|
joel
|
3910 |
@ <tr><th align="right" valign="top">Check-in Time:</th> |
|
a60b008…
|
joel
|
3911 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
3912 |
@ <input type="text" name="dt" size="20" value="%h(zNewDate)"> |
|
a60b008…
|
joel
|
3913 |
@ </td></tr> |
|
a60b008…
|
joel
|
3914 |
|
|
a60b008…
|
joel
|
3915 |
if( zChngTime ){ |
|
a60b008…
|
joel
|
3916 |
@ <tr><th align="right" valign="top">Timestamp of this change:</th> |
|
a60b008…
|
joel
|
3917 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
3918 |
@ <input type="text" name="chngtime" size="20" value="%h(zChngTime)"> |
|
a60b008…
|
joel
|
3919 |
@ </td></tr> |
|
a60b008…
|
joel
|
3920 |
} |
|
a60b008…
|
joel
|
3921 |
|
|
f8bc3ce…
|
drh
|
3922 |
@ <tr><th align="right" valign="top">Background Color:</th> |
|
a60b008…
|
joel
|
3923 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
3924 |
@ <div><label><input type='checkbox' name='newclr'%s(zNewColorFlag)> |
|
f8bc3ce…
|
drh
|
3925 |
@ Change background color: \ |
|
f8bc3ce…
|
drh
|
3926 |
@ <input type='color' name='clr'\ |
|
f8bc3ce…
|
drh
|
3927 |
@ value='%s(zNewColor[0]?zNewColor:"#808080")'></label></div> |
|
f8bc3ce…
|
drh
|
3928 |
@ <div><label> |
|
f8bc3ce…
|
drh
|
3929 |
if( fNewPropagateColor ){ |
|
f5482a0…
|
wyoung
|
3930 |
@ <input type="checkbox" name="pclr" checked="checked"> |
|
f8bc3ce…
|
drh
|
3931 |
}else{ |
|
f5482a0…
|
wyoung
|
3932 |
@ <input type="checkbox" name="pclr"> |
|
f8bc3ce…
|
drh
|
3933 |
} |
|
f8bc3ce…
|
drh
|
3934 |
@ Propagate color to descendants</label></div> |
|
9956fa6…
|
stephan
|
3935 |
@ <div class='font-size-80'>Be aware that fixed background |
|
9956fa6…
|
stephan
|
3936 |
@ colors will not interact well with all available skins. |
|
5954e62…
|
florian
|
3937 |
@ It is recommended that Fossil be allowed to select these |
|
9956fa6…
|
stephan
|
3938 |
@ colors automatically so that it can take the skin's |
|
9956fa6…
|
stephan
|
3939 |
@ preferences into account.</div> |
|
a60b008…
|
joel
|
3940 |
@ </td></tr> |
|
a60b008…
|
joel
|
3941 |
|
|
a60b008…
|
joel
|
3942 |
@ <tr><th align="right" valign="top">Tags:</th> |
|
a60b008…
|
joel
|
3943 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
3944 |
@ <label><input type="checkbox" id="newtag" name="newtag"%s(zNewTagFlag)> |
|
a60b008…
|
joel
|
3945 |
@ Add the following new tag name to this check-in:</label> |
|
f5482a0…
|
wyoung
|
3946 |
@ <input size="15" name="tagname" id="tagname" value="%h(zNewTag)"> |
|
a60b008…
|
joel
|
3947 |
db_prepare(&q, |
|
64c21ef…
|
jan.nijtmans
|
3948 |
"SELECT tag.tagid, tagname, tagxref.value FROM tagxref, tag" |
|
b893eb0…
|
drh
|
3949 |
" WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid" |
|
b893eb0…
|
drh
|
3950 |
" ORDER BY CASE WHEN tagname GLOB 'sym-*' THEN substr(tagname,5)" |
|
b893eb0…
|
drh
|
3951 |
" ELSE tagname END /*sort*/", |
|
73c23a4…
|
drh
|
3952 |
rid |
|
73c23a4…
|
drh
|
3953 |
); |
|
73c23a4…
|
drh
|
3954 |
while( db_step(&q)==SQLITE_ROW ){ |
|
73c23a4…
|
drh
|
3955 |
int tagid = db_column_int(&q, 0); |
|
73c23a4…
|
drh
|
3956 |
const char *zTagName = db_column_text(&q, 1); |
|
3529f2c…
|
jan.nijtmans
|
3957 |
int isSpecialTag = fossil_strncmp(zTagName, "sym-", 4)!=0; |
|
73c23a4…
|
drh
|
3958 |
char zLabel[30]; |
|
64c21ef…
|
jan.nijtmans
|
3959 |
|
|
3529f2c…
|
jan.nijtmans
|
3960 |
if( tagid == TAG_CLOSED ){ |
|
3529f2c…
|
jan.nijtmans
|
3961 |
fHasClosed = 1; |
|
3529f2c…
|
jan.nijtmans
|
3962 |
}else if( (tagid == TAG_COMMENT) || (tagid == TAG_BRANCH) ){ |
|
3529f2c…
|
jan.nijtmans
|
3963 |
continue; |
|
22a4e0c…
|
jan.nijtmans
|
3964 |
}else if( tagid==TAG_HIDDEN ){ |
|
22a4e0c…
|
jan.nijtmans
|
3965 |
fHasHidden = 1; |
|
3529f2c…
|
jan.nijtmans
|
3966 |
}else if( !isSpecialTag && zTagName && |
|
3529f2c…
|
jan.nijtmans
|
3967 |
fossil_strcmp(&zTagName[4], zBranchName)==0){ |
|
64c21ef…
|
jan.nijtmans
|
3968 |
continue; |
|
64c21ef…
|
jan.nijtmans
|
3969 |
} |
|
e78c49d…
|
drh
|
3970 |
sqlite3_snprintf(sizeof(zLabel), zLabel, "c%d", tagid); |
|
f5482a0…
|
wyoung
|
3971 |
@ <br><label> |
|
e78c49d…
|
drh
|
3972 |
if( P(zLabel) ){ |
|
f5482a0…
|
wyoung
|
3973 |
@ <input type="checkbox" name="c%d(tagid)" checked="checked"> |
|
64c21ef…
|
jan.nijtmans
|
3974 |
}else{ |
|
f5482a0…
|
wyoung
|
3975 |
@ <input type="checkbox" name="c%d(tagid)"> |
|
64c21ef…
|
jan.nijtmans
|
3976 |
} |
|
64c21ef…
|
jan.nijtmans
|
3977 |
if( isSpecialTag ){ |
|
64c21ef…
|
jan.nijtmans
|
3978 |
@ Cancel special tag <b>%h(zTagName)</b></label> |
|
64c21ef…
|
jan.nijtmans
|
3979 |
}else{ |
|
64c21ef…
|
jan.nijtmans
|
3980 |
@ Cancel tag <b>%h(&zTagName[4])</b></label> |
|
73c23a4…
|
drh
|
3981 |
} |
|
73c23a4…
|
drh
|
3982 |
} |
|
73c23a4…
|
drh
|
3983 |
db_finalize(&q); |
|
73c23a4…
|
drh
|
3984 |
@ </td></tr> |
|
73c23a4…
|
drh
|
3985 |
|
|
2cb54f3…
|
jan.nijtmans
|
3986 |
if( !zBranchName ){ |
|
ca0d66b…
|
danield
|
3987 |
zBranchName = fossil_strdup(db_main_branch()); |
|
2cb54f3…
|
jan.nijtmans
|
3988 |
} |
|
2cb54f3…
|
jan.nijtmans
|
3989 |
if( !zNewBranch || !zNewBranch[0]){ |
|
2cb54f3…
|
jan.nijtmans
|
3990 |
zNewBranch = zBranchName; |
|
2cb54f3…
|
jan.nijtmans
|
3991 |
} |
|
64c21ef…
|
jan.nijtmans
|
3992 |
@ <tr><th align="right" valign="top">Branching:</th> |
|
64c21ef…
|
jan.nijtmans
|
3993 |
@ <td valign="top"> |
|
f924823…
|
drh
|
3994 |
@ <label><input id="newbr" type="checkbox" name="newbr" \ |
|
f5482a0…
|
wyoung
|
3995 |
@ data-branch='%h(zBranchName)'%s(zNewBrFlag)> |
|
e053682…
|
andybradford
|
3996 |
@ Starting from this check-in, rename the branch to:</label> |
|
f924823…
|
drh
|
3997 |
@ <input id="brname" type="text" style="width:15;" name="brname" \ |
|
f5482a0…
|
wyoung
|
3998 |
@ value="%h(zNewBranch)"></td></tr> |
|
22a4e0c…
|
jan.nijtmans
|
3999 |
if( !fHasHidden ){ |
|
22a4e0c…
|
jan.nijtmans
|
4000 |
@ <tr><th align="right" valign="top">Branch Hiding:</th> |
|
22a4e0c…
|
jan.nijtmans
|
4001 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
4002 |
@ <label><input type="checkbox" id="hidebr" name="hide"%s(zHideFlag)> |
|
45f3516…
|
jan.nijtmans
|
4003 |
@ Hide branch |
|
22a4e0c…
|
jan.nijtmans
|
4004 |
@ <span style="font-weight:bold" id="hbranch">%h(zBranchName)</span> |
|
22a4e0c…
|
jan.nijtmans
|
4005 |
@ from the timeline starting from this check-in</label> |
|
22a4e0c…
|
jan.nijtmans
|
4006 |
@ </td></tr> |
|
22a4e0c…
|
jan.nijtmans
|
4007 |
} |
|
718cc00…
|
jan.nijtmans
|
4008 |
if( !fHasClosed ){ |
|
718cc00…
|
jan.nijtmans
|
4009 |
if( is_a_leaf(rid) ){ |
|
718cc00…
|
jan.nijtmans
|
4010 |
@ <tr><th align="right" valign="top">Leaf Closure:</th> |
|
718cc00…
|
jan.nijtmans
|
4011 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
4012 |
@ <label><input type="checkbox" name="close"%s(zCloseFlag)> |
|
718cc00…
|
jan.nijtmans
|
4013 |
@ Mark this leaf as "closed" so that it no longer appears on the |
|
718cc00…
|
jan.nijtmans
|
4014 |
@ "leaves" page and is no longer labeled as a "<b>Leaf</b>"</label> |
|
718cc00…
|
jan.nijtmans
|
4015 |
@ </td></tr> |
|
718cc00…
|
jan.nijtmans
|
4016 |
}else if( zBranchName ){ |
|
718cc00…
|
jan.nijtmans
|
4017 |
@ <tr><th align="right" valign="top">Branch Closure:</th> |
|
718cc00…
|
jan.nijtmans
|
4018 |
@ <td valign="top"> |
|
f5482a0…
|
wyoung
|
4019 |
@ <label><input type="checkbox" name="close"%s(zCloseFlag)> |
|
4a43e31…
|
jan.nijtmans
|
4020 |
@ Mark branch |
|
4a43e31…
|
jan.nijtmans
|
4021 |
@ <span style="font-weight:bold" id="cbranch">%h(zBranchName)</span> |
|
5da61d6…
|
drh
|
4022 |
@ as "closed".</label> |
|
718cc00…
|
jan.nijtmans
|
4023 |
@ </td></tr> |
|
718cc00…
|
jan.nijtmans
|
4024 |
} |
|
718cc00…
|
jan.nijtmans
|
4025 |
} |
|
3529f2c…
|
jan.nijtmans
|
4026 |
if( zBranchName ) fossil_free(zBranchName); |
|
42c2a18…
|
drh
|
4027 |
|
|
b7f32a7…
|
drh
|
4028 |
|
|
b7f32a7…
|
drh
|
4029 |
@ <tr><td colspan="2"> |
|
f5482a0…
|
wyoung
|
4030 |
@ <input type="submit" name="cancel" value="Cancel"> |
|
f5482a0…
|
wyoung
|
4031 |
@ <input type="submit" name="preview" value="Preview"> |
|
f8bc3ce…
|
drh
|
4032 |
if( P("preview") ){ |
|
f5482a0…
|
wyoung
|
4033 |
@ <input type="submit" name="apply" value="Apply Changes"> |
|
f8bc3ce…
|
drh
|
4034 |
} |
|
b7f32a7…
|
drh
|
4035 |
@ </td></tr> |
|
b7f32a7…
|
drh
|
4036 |
@ </table> |
|
e454028…
|
drh
|
4037 |
login_insert_csrf_secret(); |
|
5a48a9b…
|
drh
|
4038 |
@ </div></form> |
|
036a9d5…
|
drh
|
4039 |
builtin_request_js("ci_edit.js"); |
|
112c713…
|
drh
|
4040 |
style_finish_page(); |
|
c73c95c…
|
andybradford
|
4041 |
} |
|
c73c95c…
|
andybradford
|
4042 |
|
|
c73c95c…
|
andybradford
|
4043 |
/* |
|
c73c95c…
|
andybradford
|
4044 |
** Prepare an ammended commit comment. Let the user modify it using the |
|
c73c95c…
|
andybradford
|
4045 |
** editor specified in the global_config table or either |
|
c73c95c…
|
andybradford
|
4046 |
** the VISUAL or EDITOR environment variable. |
|
c73c95c…
|
andybradford
|
4047 |
** |
|
c73c95c…
|
andybradford
|
4048 |
** Store the final commit comment in pComment. pComment is assumed |
|
c73c95c…
|
andybradford
|
4049 |
** to be uninitialized - any prior content is overwritten. |
|
c73c95c…
|
andybradford
|
4050 |
** |
|
c73c95c…
|
andybradford
|
4051 |
** Use zInit to initialize the check-in comment so that the user does |
|
c73c95c…
|
andybradford
|
4052 |
** not have to retype. |
|
c73c95c…
|
andybradford
|
4053 |
*/ |
|
c73c95c…
|
andybradford
|
4054 |
static void prepare_amend_comment( |
|
c73c95c…
|
andybradford
|
4055 |
Blob *pComment, |
|
c73c95c…
|
andybradford
|
4056 |
const char *zInit, |
|
c73c95c…
|
andybradford
|
4057 |
const char *zUuid |
|
c73c95c…
|
andybradford
|
4058 |
){ |
|
c73c95c…
|
andybradford
|
4059 |
Blob prompt; |
|
c73c95c…
|
andybradford
|
4060 |
#if defined(_WIN32) || defined(__CYGWIN__) |
|
c73c95c…
|
andybradford
|
4061 |
int bomSize; |
|
c73c95c…
|
andybradford
|
4062 |
const unsigned char *bom = get_utf8_bom(&bomSize); |
|
c73c95c…
|
andybradford
|
4063 |
blob_init(&prompt, (const char *) bom, bomSize); |
|
c73c95c…
|
andybradford
|
4064 |
if( zInit && zInit[0]){ |
|
c73c95c…
|
andybradford
|
4065 |
blob_append(&prompt, zInit, -1); |
|
c73c95c…
|
andybradford
|
4066 |
} |
|
c73c95c…
|
andybradford
|
4067 |
#else |
|
c73c95c…
|
andybradford
|
4068 |
blob_init(&prompt, zInit, -1); |
|
c73c95c…
|
andybradford
|
4069 |
#endif |
|
c73c95c…
|
andybradford
|
4070 |
blob_append(&prompt, "\n# Enter a new comment for check-in ", -1); |
|
c73c95c…
|
andybradford
|
4071 |
if( zUuid && zUuid[0] ){ |
|
c73c95c…
|
andybradford
|
4072 |
blob_append(&prompt, zUuid, -1); |
|
c73c95c…
|
andybradford
|
4073 |
} |
|
c73c95c…
|
andybradford
|
4074 |
blob_append(&prompt, ".\n# Lines beginning with a # are ignored.\n", -1); |
|
c73c95c…
|
andybradford
|
4075 |
prompt_for_user_comment(pComment, &prompt); |
|
c73c95c…
|
andybradford
|
4076 |
blob_reset(&prompt); |
|
c73c95c…
|
andybradford
|
4077 |
} |
|
c73c95c…
|
andybradford
|
4078 |
|
|
8ad5e46…
|
wyoung
|
4079 |
#define AMEND_USAGE_STMT "HASH OPTION ?OPTION ...?" |
|
c73c95c…
|
andybradford
|
4080 |
/* |
|
c73c95c…
|
andybradford
|
4081 |
** COMMAND: amend |
|
c73c95c…
|
andybradford
|
4082 |
** |
|
8ad5e46…
|
wyoung
|
4083 |
** Usage: %fossil amend HASH OPTION ?OPTION ...? |
|
c73c95c…
|
andybradford
|
4084 |
** |
|
8ad5e46…
|
wyoung
|
4085 |
** Amend the tags on check-in HASH to change how it displays in the timeline. |
|
c73c95c…
|
andybradford
|
4086 |
** |
|
c73c95c…
|
andybradford
|
4087 |
** Options: |
|
eff2b2b…
|
drh
|
4088 |
** --author USER Make USER the author for check-in |
|
eff2b2b…
|
drh
|
4089 |
** --bgcolor COLOR Apply COLOR to this check-in |
|
eff2b2b…
|
drh
|
4090 |
** --branch NAME Rename branch of check-in to NAME |
|
eff2b2b…
|
drh
|
4091 |
** --branchcolor COLOR Apply and propagate COLOR to the branch |
|
eff2b2b…
|
drh
|
4092 |
** --cancel TAG Cancel TAG from this check-in |
|
eff2b2b…
|
drh
|
4093 |
** --close Mark this "leaf" as closed |
|
eff2b2b…
|
drh
|
4094 |
** --date DATETIME Make DATETIME the check-in time |
|
eff2b2b…
|
drh
|
4095 |
** --date-override DATETIME Set the change time on the control artifact |
|
eff2b2b…
|
drh
|
4096 |
** -e|--edit-comment Launch editor to revise comment |
|
bb3fbff…
|
florian
|
4097 |
** --editor NAME Text editor to use for check-in comment |
|
eff2b2b…
|
drh
|
4098 |
** --hide Hide branch starting from this check-in |
|
eff2b2b…
|
drh
|
4099 |
** -m|--comment COMMENT Make COMMENT the check-in comment |
|
eff2b2b…
|
drh
|
4100 |
** -M|--message-file FILE Read the amended comment from FILE |
|
eff2b2b…
|
drh
|
4101 |
** -n|--dry-run Print control artifact, but make no changes |
|
eff2b2b…
|
drh
|
4102 |
** --no-verify-comment Do not validate the check-in comment |
|
eff2b2b…
|
drh
|
4103 |
** --tag TAG Add new TAG to this check-in |
|
eff2b2b…
|
drh
|
4104 |
** --user-override USER Set the user name on the control artifact |
|
c73c95c…
|
andybradford
|
4105 |
** |
|
cd77e06…
|
rberteig
|
4106 |
** DATETIME may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in |
|
cd77e06…
|
rberteig
|
4107 |
** year-month-day form, it may be truncated, the "T" may be replaced by |
|
cd77e06…
|
rberteig
|
4108 |
** a space, and it may also name a timezone offset from UTC as "-HH:MM" |
|
cd77e06…
|
rberteig
|
4109 |
** (westward) or "+HH:MM" (eastward). Either no timezone suffix or "Z" |
|
cd77e06…
|
rberteig
|
4110 |
** means UTC. |
|
c73c95c…
|
andybradford
|
4111 |
*/ |
|
c73c95c…
|
andybradford
|
4112 |
void ci_amend_cmd(void){ |
|
c73c95c…
|
andybradford
|
4113 |
int rid; |
|
c73c95c…
|
andybradford
|
4114 |
const char *zComment; /* Current comment on the check-in */ |
|
c73c95c…
|
andybradford
|
4115 |
const char *zNewComment; /* Revised check-in comment */ |
|
c73c95c…
|
andybradford
|
4116 |
const char *zComFile; /* Filename from which to read comment */ |
|
c73c95c…
|
andybradford
|
4117 |
const char *zUser; /* Current user for the check-in */ |
|
c73c95c…
|
andybradford
|
4118 |
const char *zNewUser; /* Revised user */ |
|
c73c95c…
|
andybradford
|
4119 |
const char *zDate; /* Current date of the check-in */ |
|
c73c95c…
|
andybradford
|
4120 |
const char *zNewDate; /* Revised check-in date */ |
|
c73c95c…
|
andybradford
|
4121 |
const char *zColor; |
|
c73c95c…
|
andybradford
|
4122 |
const char *zNewColor; |
|
c73c95c…
|
andybradford
|
4123 |
const char *zNewBrColor; |
|
c73c95c…
|
andybradford
|
4124 |
const char *zNewBranch; |
|
c73c95c…
|
andybradford
|
4125 |
const char **pzNewTags = 0; |
|
c73c95c…
|
andybradford
|
4126 |
const char **pzCancelTags = 0; |
|
c73c95c…
|
andybradford
|
4127 |
int fClose; /* True if leaf should be closed */ |
|
c73c95c…
|
andybradford
|
4128 |
int fHide; /* True if branch should be hidden */ |
|
c73c95c…
|
andybradford
|
4129 |
int fPropagateColor; /* True if color propagates before amend */ |
|
c73c95c…
|
andybradford
|
4130 |
int fNewPropagateColor = 0; /* True if color propagates after amend */ |
|
c73c95c…
|
andybradford
|
4131 |
int fHasHidden = 0; /* True if hidden tag already set */ |
|
c73c95c…
|
andybradford
|
4132 |
int fHasClosed = 0; /* True if closed tag already set */ |
|
c73c95c…
|
andybradford
|
4133 |
int fEditComment; /* True if editor to be used for comment */ |
|
5c99557…
|
drh
|
4134 |
int fDryRun; /* Print control artifact, make no changes */ |
|
eff2b2b…
|
drh
|
4135 |
int noVerifyCom = 0; /* Allow suspicious check-in comments */ |
|
c73c95c…
|
andybradford
|
4136 |
const char *zChngTime; /* The change time on the control artifact */ |
|
5c99557…
|
drh
|
4137 |
const char *zUserOvrd; /* The user name on the control artifact */ |
|
c73c95c…
|
andybradford
|
4138 |
const char *zUuid; |
|
c73c95c…
|
andybradford
|
4139 |
Blob ctrl; |
|
c73c95c…
|
andybradford
|
4140 |
Blob comment; |
|
c73c95c…
|
andybradford
|
4141 |
char *zNow; |
|
c73c95c…
|
andybradford
|
4142 |
int nTags, nCancels; |
|
c73c95c…
|
andybradford
|
4143 |
int i; |
|
c73c95c…
|
andybradford
|
4144 |
Stmt q; |
|
072125b…
|
drh
|
4145 |
int ckComFlgs; /* Flags passed to verify_comment() */ |
|
eff2b2b…
|
drh
|
4146 |
|
|
30f18ce…
|
florian
|
4147 |
|
|
9ea1f14…
|
rberteig
|
4148 |
fEditComment = find_option("edit-comment","e",0)!=0; |
|
c73c95c…
|
andybradford
|
4149 |
zNewComment = find_option("comment","m",1); |
|
c73c95c…
|
andybradford
|
4150 |
zComFile = find_option("message-file","M",1); |
|
c73c95c…
|
andybradford
|
4151 |
zNewBranch = find_option("branch",0,1); |
|
c73c95c…
|
andybradford
|
4152 |
zNewColor = find_option("bgcolor",0,1); |
|
c73c95c…
|
andybradford
|
4153 |
zNewBrColor = find_option("branchcolor",0,1); |
|
c73c95c…
|
andybradford
|
4154 |
if( zNewBrColor ){ |
|
c73c95c…
|
andybradford
|
4155 |
zNewColor = zNewBrColor; |
|
c73c95c…
|
andybradford
|
4156 |
fNewPropagateColor = 1; |
|
c73c95c…
|
andybradford
|
4157 |
} |
|
c73c95c…
|
andybradford
|
4158 |
zNewDate = find_option("date",0,1); |
|
c73c95c…
|
andybradford
|
4159 |
zNewUser = find_option("author",0,1); |
|
c73c95c…
|
andybradford
|
4160 |
pzNewTags = find_repeatable_option("tag",0,&nTags); |
|
c73c95c…
|
andybradford
|
4161 |
pzCancelTags = find_repeatable_option("cancel",0,&nCancels); |
|
c73c95c…
|
andybradford
|
4162 |
fClose = find_option("close",0,0)!=0; |
|
c73c95c…
|
andybradford
|
4163 |
fHide = find_option("hide",0,0)!=0; |
|
5c99557…
|
drh
|
4164 |
fDryRun = find_option("dry-run","n",0)!=0; |
|
5c99557…
|
drh
|
4165 |
zChngTime = find_option("date-override",0,1); |
|
5c99557…
|
drh
|
4166 |
if( zChngTime==0 ) zChngTime = find_option("chngtime",0,1); |
|
5c99557…
|
drh
|
4167 |
zUserOvrd = find_option("user-override",0,1); |
|
eff2b2b…
|
drh
|
4168 |
noVerifyCom = find_option("no-verify-comment",0,0)!=0; |
|
1fff403…
|
andybradford
|
4169 |
db_find_and_open_repository(0,0); |
|
c73c95c…
|
andybradford
|
4170 |
user_select(); |
|
bb3fbff…
|
florian
|
4171 |
(void)fossil_text_editor(); |
|
c73c95c…
|
andybradford
|
4172 |
verify_all_options(); |
|
c73c95c…
|
andybradford
|
4173 |
if( g.argc<3 || g.argc>=4 ) usage(AMEND_USAGE_STMT); |
|
c73c95c…
|
andybradford
|
4174 |
rid = name_to_typed_rid(g.argv[2], "ci"); |
|
c73c95c…
|
andybradford
|
4175 |
if( rid==0 && !is_a_version(rid) ) fossil_fatal("no such check-in"); |
|
c73c95c…
|
andybradford
|
4176 |
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
|
8ad5e46…
|
wyoung
|
4177 |
if( zUuid==0 ) fossil_fatal("Unable to find artifact hash"); |
|
c73c95c…
|
andybradford
|
4178 |
zComment = db_text(0, "SELECT coalesce(ecomment,comment)" |
|
c73c95c…
|
andybradford
|
4179 |
" FROM event WHERE objid=%d", rid); |
|
c73c95c…
|
andybradford
|
4180 |
zUser = db_text(0, "SELECT coalesce(euser,user)" |
|
c73c95c…
|
andybradford
|
4181 |
" FROM event WHERE objid=%d", rid); |
|
c73c95c…
|
andybradford
|
4182 |
zDate = db_text(0, "SELECT datetime(mtime)" |
|
c73c95c…
|
andybradford
|
4183 |
" FROM event WHERE objid=%d", rid); |
|
c73c95c…
|
andybradford
|
4184 |
zColor = db_text("", "SELECT bgcolor" |
|
c73c95c…
|
andybradford
|
4185 |
" FROM event WHERE objid=%d", rid); |
|
c73c95c…
|
andybradford
|
4186 |
fPropagateColor = db_int(0, "SELECT tagtype FROM tagxref" |
|
c73c95c…
|
andybradford
|
4187 |
" WHERE rid=%d AND tagid=%d", |
|
c73c95c…
|
andybradford
|
4188 |
rid, TAG_BGCOLOR)==2; |
|
c73c95c…
|
andybradford
|
4189 |
fNewPropagateColor = zNewColor && zNewColor[0] |
|
c73c95c…
|
andybradford
|
4190 |
? fNewPropagateColor : fPropagateColor; |
|
c73c95c…
|
andybradford
|
4191 |
db_prepare(&q, |
|
c73c95c…
|
andybradford
|
4192 |
"SELECT tag.tagid FROM tagxref, tag" |
|
c73c95c…
|
andybradford
|
4193 |
" WHERE tagxref.rid=%d AND tagtype>0 AND tagxref.tagid=tag.tagid", |
|
c73c95c…
|
andybradford
|
4194 |
rid |
|
c73c95c…
|
andybradford
|
4195 |
); |
|
c73c95c…
|
andybradford
|
4196 |
while( db_step(&q)==SQLITE_ROW ){ |
|
c73c95c…
|
andybradford
|
4197 |
int tagid = db_column_int(&q, 0); |
|
c73c95c…
|
andybradford
|
4198 |
|
|
c73c95c…
|
andybradford
|
4199 |
if( tagid == TAG_CLOSED ){ |
|
c73c95c…
|
andybradford
|
4200 |
fHasClosed = 1; |
|
c73c95c…
|
andybradford
|
4201 |
}else if( tagid==TAG_HIDDEN ){ |
|
c73c95c…
|
andybradford
|
4202 |
fHasHidden = 1; |
|
c73c95c…
|
andybradford
|
4203 |
}else{ |
|
c73c95c…
|
andybradford
|
4204 |
continue; |
|
c73c95c…
|
andybradford
|
4205 |
} |
|
c73c95c…
|
andybradford
|
4206 |
} |
|
c73c95c…
|
andybradford
|
4207 |
db_finalize(&q); |
|
c73c95c…
|
andybradford
|
4208 |
blob_zero(&ctrl); |
|
c73c95c…
|
andybradford
|
4209 |
zNow = date_in_standard_format(zChngTime && zChngTime[0] ? zChngTime : "now"); |
|
c73c95c…
|
andybradford
|
4210 |
blob_appendf(&ctrl, "D %s\n", zNow); |
|
c73c95c…
|
andybradford
|
4211 |
init_newtags(); |
|
c73c95c…
|
andybradford
|
4212 |
if( zNewColor && zNewColor[0] |
|
c73c95c…
|
andybradford
|
4213 |
&& (fPropagateColor!=fNewPropagateColor |
|
c73c95c…
|
andybradford
|
4214 |
|| fossil_strcmp(zColor,zNewColor)!=0) |
|
c73c95c…
|
andybradford
|
4215 |
){ |
|
c73c95c…
|
andybradford
|
4216 |
add_color( |
|
c73c95c…
|
andybradford
|
4217 |
mprintf("%s%s", (zNewColor[0]!='#' && |
|
c73c95c…
|
andybradford
|
4218 |
validate16(zNewColor,strlen(zNewColor)) && |
|
c73c95c…
|
andybradford
|
4219 |
(strlen(zNewColor)==6 || strlen(zNewColor)==3)) ? "#" : "", |
|
c73c95c…
|
andybradford
|
4220 |
zNewColor |
|
c73c95c…
|
andybradford
|
4221 |
), |
|
c73c95c…
|
andybradford
|
4222 |
fNewPropagateColor |
|
c73c95c…
|
andybradford
|
4223 |
); |
|
c73c95c…
|
andybradford
|
4224 |
} |
|
c73c95c…
|
andybradford
|
4225 |
if( (zNewColor!=0 && zNewColor[0]==0) && (zColor && zColor[0] ) ){ |
|
c73c95c…
|
andybradford
|
4226 |
cancel_color(); |
|
c73c95c…
|
andybradford
|
4227 |
} |
|
eff2b2b…
|
drh
|
4228 |
if( fEditComment || zNewComment || zComFile ){ |
|
eff2b2b…
|
drh
|
4229 |
blob_init(&comment, 0, 0); |
|
eff2b2b…
|
drh
|
4230 |
|
|
eff2b2b…
|
drh
|
4231 |
/* Figure out how much comment verification is requested */ |
|
eff2b2b…
|
drh
|
4232 |
if( noVerifyCom ){ |
|
eff2b2b…
|
drh
|
4233 |
ckComFlgs = 0; |
|
eff2b2b…
|
drh
|
4234 |
}else{ |
|
eff2b2b…
|
drh
|
4235 |
const char *zVerComs = db_get("verify-comments","on"); |
|
eff2b2b…
|
drh
|
4236 |
if( is_false(zVerComs) ){ |
|
eff2b2b…
|
drh
|
4237 |
ckComFlgs = 0; |
|
eff2b2b…
|
drh
|
4238 |
}else if( strcmp(zVerComs,"preview")==0 ){ |
|
072125b…
|
drh
|
4239 |
ckComFlgs = COMCK_PREVIEW | COMCK_MARKUP; |
|
eff2b2b…
|
drh
|
4240 |
}else{ |
|
072125b…
|
drh
|
4241 |
ckComFlgs = COMCK_MARKUP; |
|
eff2b2b…
|
drh
|
4242 |
} |
|
eff2b2b…
|
drh
|
4243 |
} |
|
eff2b2b…
|
drh
|
4244 |
if( fEditComment ){ |
|
eff2b2b…
|
drh
|
4245 |
prepare_amend_comment(&comment, zComment, zUuid); |
|
eff2b2b…
|
drh
|
4246 |
}else if( zComFile ){ |
|
eff2b2b…
|
drh
|
4247 |
blob_read_from_file(&comment, zComFile, ExtFILE); |
|
eff2b2b…
|
drh
|
4248 |
blob_to_utf8_no_bom(&comment, 1); |
|
eff2b2b…
|
drh
|
4249 |
}else if( zNewComment ){ |
|
eff2b2b…
|
drh
|
4250 |
blob_init(&comment, zNewComment, -1); |
|
eff2b2b…
|
drh
|
4251 |
} |
|
eff2b2b…
|
drh
|
4252 |
if( blob_size(&comment)>0 |
|
eff2b2b…
|
drh
|
4253 |
&& comment_compare(zComment, blob_str(&comment))==0 |
|
eff2b2b…
|
drh
|
4254 |
){ |
|
eff2b2b…
|
drh
|
4255 |
int rc; |
|
072125b…
|
drh
|
4256 |
while( (rc = verify_comment(&comment, ckComFlgs))!=0 ){ |
|
eff2b2b…
|
drh
|
4257 |
char cReply; |
|
eff2b2b…
|
drh
|
4258 |
Blob ans; |
|
eff2b2b…
|
drh
|
4259 |
if( !fEditComment ){ |
|
eff2b2b…
|
drh
|
4260 |
fossil_fatal("Amend aborted; " |
|
eff2b2b…
|
drh
|
4261 |
"use --no-verify-comment to override"); |
|
eff2b2b…
|
drh
|
4262 |
} |
|
eff2b2b…
|
drh
|
4263 |
if( rc==COMCK_PREVIEW ){ |
|
072125b…
|
drh
|
4264 |
prompt_user("Continue, abort, or edit (C/a/e)? ", &ans); |
|
eff2b2b…
|
drh
|
4265 |
}else{ |
|
072125b…
|
drh
|
4266 |
prompt_user("Edit, abort, or continue (E/a/c)? ", &ans); |
|
eff2b2b…
|
drh
|
4267 |
} |
|
eff2b2b…
|
drh
|
4268 |
cReply = blob_str(&ans)[0]; |
|
eff2b2b…
|
drh
|
4269 |
cReply = fossil_tolower(cReply); |
|
eff2b2b…
|
drh
|
4270 |
blob_reset(&ans); |
|
072125b…
|
drh
|
4271 |
if( cReply=='a' ){ |
|
eff2b2b…
|
drh
|
4272 |
fossil_fatal("Amend aborted."); |
|
eff2b2b…
|
drh
|
4273 |
} |
|
072125b…
|
drh
|
4274 |
if( cReply=='e' || (cReply!='c' && rc!=COMCK_PREVIEW) ){ |
|
eff2b2b…
|
drh
|
4275 |
char *zPrior = blob_materialize(&comment); |
|
eff2b2b…
|
drh
|
4276 |
blob_init(&comment, 0, 0); |
|
eff2b2b…
|
drh
|
4277 |
prepare_amend_comment(&comment, zPrior, zUuid); |
|
eff2b2b…
|
drh
|
4278 |
fossil_free(zPrior); |
|
eff2b2b…
|
drh
|
4279 |
continue; |
|
eff2b2b…
|
drh
|
4280 |
}else{ |
|
eff2b2b…
|
drh
|
4281 |
break; |
|
eff2b2b…
|
drh
|
4282 |
} |
|
eff2b2b…
|
drh
|
4283 |
} |
|
eff2b2b…
|
drh
|
4284 |
} |
|
eff2b2b…
|
drh
|
4285 |
add_comment(blob_str(&comment)); |
|
eff2b2b…
|
drh
|
4286 |
} |
|
c73c95c…
|
andybradford
|
4287 |
if( zNewDate && zNewDate[0] && fossil_strcmp(zDate,zNewDate)!=0 ){ |
|
c73c95c…
|
andybradford
|
4288 |
if( is_datetime(zNewDate) ){ |
|
c73c95c…
|
andybradford
|
4289 |
add_date(zNewDate); |
|
c73c95c…
|
andybradford
|
4290 |
}else{ |
|
c73c95c…
|
andybradford
|
4291 |
fossil_fatal("Unsupported date format, use YYYY-MM-DD HH:MM:SS"); |
|
c73c95c…
|
andybradford
|
4292 |
} |
|
c73c95c…
|
andybradford
|
4293 |
} |
|
c73c95c…
|
andybradford
|
4294 |
if( zNewUser && zNewUser[0] && fossil_strcmp(zUser,zNewUser)!=0 ){ |
|
c73c95c…
|
andybradford
|
4295 |
add_user(zNewUser); |
|
c73c95c…
|
andybradford
|
4296 |
} |
|
c73c95c…
|
andybradford
|
4297 |
if( pzNewTags!=0 ){ |
|
c73c95c…
|
andybradford
|
4298 |
for(i=0; i<nTags; i++){ |
|
c73c95c…
|
andybradford
|
4299 |
if( pzNewTags[i] && pzNewTags[i][0] ) add_tag(pzNewTags[i]); |
|
c73c95c…
|
andybradford
|
4300 |
} |
|
52e3d9d…
|
mistachkin
|
4301 |
fossil_free((void *)pzNewTags); |
|
c73c95c…
|
andybradford
|
4302 |
} |
|
c73c95c…
|
andybradford
|
4303 |
if( pzCancelTags!=0 ){ |
|
c73c95c…
|
andybradford
|
4304 |
for(i=0; i<nCancels; i++){ |
|
c73c95c…
|
andybradford
|
4305 |
if( pzCancelTags[i] && pzCancelTags[i][0] ) |
|
c73c95c…
|
andybradford
|
4306 |
cancel_tag(rid,pzCancelTags[i]); |
|
c73c95c…
|
andybradford
|
4307 |
} |
|
52e3d9d…
|
mistachkin
|
4308 |
fossil_free((void *)pzCancelTags); |
|
c73c95c…
|
andybradford
|
4309 |
} |
|
c73c95c…
|
andybradford
|
4310 |
if( fHide && !fHasHidden ) hide_branch(); |
|
c73c95c…
|
andybradford
|
4311 |
if( fClose && !fHasClosed ) close_leaf(rid); |
|
c73c95c…
|
andybradford
|
4312 |
if( zNewBranch && zNewBranch[0] ) change_branch(rid,zNewBranch); |
|
e454028…
|
drh
|
4313 |
construct_newtags_artifact(&ctrl, rid, zUuid, zUserOvrd); |
|
e454028…
|
drh
|
4314 |
if( fDryRun ){ |
|
e454028…
|
drh
|
4315 |
fossil_print("%s", blob_str(&ctrl)); |
|
e454028…
|
drh
|
4316 |
blob_reset(&ctrl); |
|
e454028…
|
drh
|
4317 |
}else{ |
|
e454028…
|
drh
|
4318 |
db_begin_transaction(); |
|
e454028…
|
drh
|
4319 |
publish_newtags_artifact(&ctrl, rid); |
|
8ad5e46…
|
wyoung
|
4320 |
show_common_info(rid, "hash:", 1, 0); |
|
e454028…
|
drh
|
4321 |
db_end_transaction(0); |
|
5e20a4f…
|
drh
|
4322 |
} |
|
5e20a4f…
|
drh
|
4323 |
if( g.localOpen ){ |
|
5e20a4f…
|
drh
|
4324 |
manifest_to_disk(rid); |
|
de38906…
|
drh
|
4325 |
} |
|
de38906…
|
drh
|
4326 |
} |
|
de38906…
|
drh
|
4327 |
|
|
de38906…
|
drh
|
4328 |
|
|
de38906…
|
drh
|
4329 |
/* |
|
de38906…
|
drh
|
4330 |
** COMMAND: test-symlink-list |
|
de38906…
|
drh
|
4331 |
** |
|
de38906…
|
drh
|
4332 |
** Show all symlinks that have been checked into a Fossil repository. |
|
de38906…
|
drh
|
4333 |
** |
|
de38906…
|
drh
|
4334 |
** This command does a linear scan through all check-ins and so might take |
|
de38906…
|
drh
|
4335 |
** several seconds on a large repository. |
|
de38906…
|
drh
|
4336 |
*/ |
|
de38906…
|
drh
|
4337 |
void test_symlink_list_cmd(void){ |
|
de38906…
|
drh
|
4338 |
Stmt q; |
|
de38906…
|
drh
|
4339 |
db_find_and_open_repository(0,0); |
|
de38906…
|
drh
|
4340 |
add_content_sql_commands(g.db); |
|
de38906…
|
drh
|
4341 |
db_prepare(&q, |
|
de38906…
|
drh
|
4342 |
"SELECT min(date(e.mtime))," |
|
de38906…
|
drh
|
4343 |
" b.uuid," |
|
de38906…
|
drh
|
4344 |
" f.filename," |
|
de38906…
|
drh
|
4345 |
" content(f.uuid)" |
|
de38906…
|
drh
|
4346 |
" FROM event AS e, blob AS b, files_of_checkin(b.uuid) AS f" |
|
de38906…
|
drh
|
4347 |
" WHERE e.type='ci'" |
|
de38906…
|
drh
|
4348 |
" AND b.rid=e.objid" |
|
de38906…
|
drh
|
4349 |
" AND f.perm LIKE '%%l%%'" |
|
de38906…
|
drh
|
4350 |
" GROUP BY 3, 4" |
|
de38906…
|
drh
|
4351 |
" ORDER BY 1 DESC" |
|
de38906…
|
drh
|
4352 |
); |
|
de38906…
|
drh
|
4353 |
while( db_step(&q)==SQLITE_ROW ){ |
|
de38906…
|
drh
|
4354 |
fossil_print("%s %.16s %s -> %s\n", |
|
de38906…
|
drh
|
4355 |
db_column_text(&q,0), |
|
de38906…
|
drh
|
4356 |
db_column_text(&q,1), |
|
de38906…
|
drh
|
4357 |
db_column_text(&q,2), |
|
de38906…
|
drh
|
4358 |
db_column_text(&q,3)); |
|
de38906…
|
drh
|
4359 |
} |
|
de38906…
|
drh
|
4360 |
db_finalize(&q); |
|
36ca266…
|
drh
|
4361 |
} |
|
36ca266…
|
drh
|
4362 |
|
|
36ca266…
|
drh
|
4363 |
#if INTERFACE |
|
534c10f…
|
stephan
|
4364 |
/* |
|
52dd8a9…
|
danield
|
4365 |
** Description of a check-in relative to an earlier, tagged check-in. |
|
36ca266…
|
drh
|
4366 |
*/ |
|
36ca266…
|
drh
|
4367 |
typedef struct CommitDescr { |
|
52dd8a9…
|
danield
|
4368 |
char *zRelTagname; /* Tag name on the relative check-in */ |
|
36ca266…
|
drh
|
4369 |
int nCommitsSince; /* Number of commits since then */ |
|
52dd8a9…
|
danield
|
4370 |
char *zCommitHash; /* Hash of the described check-in */ |
|
36ca266…
|
drh
|
4371 |
int isDirty; /* Working directory has uncommitted changes */ |
|
36ca266…
|
drh
|
4372 |
} CommitDescr; |
|
36ca266…
|
drh
|
4373 |
#endif |
|
36ca266…
|
drh
|
4374 |
|
|
36ca266…
|
drh
|
4375 |
/* |
|
52dd8a9…
|
danield
|
4376 |
** Describe the check-in given by 'zName', and possibly matching 'matchGlob', |
|
52dd8a9…
|
danield
|
4377 |
** relative to an earlier, tagged check-in. Use 'descr' for the output. |
|
36ca266…
|
drh
|
4378 |
** |
|
36ca266…
|
drh
|
4379 |
** Finds the closest ancestor (ignoring merge-ins) that has a non-propagating |
|
36ca266…
|
drh
|
4380 |
** label tag and the number of steps backwards that we had to search in |
|
52dd8a9…
|
danield
|
4381 |
** order to find that tag. Tags applied to more than one check-in are ignored. |
|
36ca266…
|
drh
|
4382 |
** |
|
36ca266…
|
drh
|
4383 |
** Return values: |
|
36ca266…
|
drh
|
4384 |
** 0: ok |
|
36ca266…
|
drh
|
4385 |
** -1: zName does not resolve to a commit |
|
36ca266…
|
drh
|
4386 |
** -2: zName resolves to more than a commit |
|
36ca266…
|
drh
|
4387 |
** -3: no ancestor commit with a fitting non-propagating tag found |
|
36ca266…
|
drh
|
4388 |
*/ |
|
41dc5fc…
|
drh
|
4389 |
int describe_commit( |
|
41dc5fc…
|
drh
|
4390 |
const char *zName, /* Name of the commit to be described */ |
|
41dc5fc…
|
drh
|
4391 |
const char *matchGlob, /* Glob pattern for the tag */ |
|
41dc5fc…
|
drh
|
4392 |
CommitDescr *descr /* Write the description here */ |
|
41dc5fc…
|
drh
|
4393 |
){ |
|
36ca266…
|
drh
|
4394 |
int rid; /* rid for zName */ |
|
36ca266…
|
drh
|
4395 |
const char *zUuid; /* Hash of rid */ |
|
36ca266…
|
drh
|
4396 |
int nRet = 0; /* Value to be returned */ |
|
36ca266…
|
drh
|
4397 |
Stmt q; /* Query for tagged ancestors */ |
|
36ca266…
|
drh
|
4398 |
|
|
36ca266…
|
drh
|
4399 |
rid = symbolic_name_to_rid(zName, "ci"); /* only commits */ |
|
36ca266…
|
drh
|
4400 |
|
|
36ca266…
|
drh
|
4401 |
if( rid<=0 ){ |
|
36ca266…
|
drh
|
4402 |
/* Commit does not exist or is ambiguous */ |
|
36ca266…
|
drh
|
4403 |
descr->zRelTagname = mprintf(""); |
|
36ca266…
|
drh
|
4404 |
descr->nCommitsSince = -1; |
|
36ca266…
|
drh
|
4405 |
descr->zCommitHash = mprintf(""); |
|
36ca266…
|
drh
|
4406 |
descr->isDirty = -1; |
|
36ca266…
|
drh
|
4407 |
return (rid-1); |
|
36ca266…
|
drh
|
4408 |
} |
|
36ca266…
|
drh
|
4409 |
|
|
36ca266…
|
drh
|
4410 |
zUuid = rid_to_uuid(rid); |
|
4c3e172…
|
danield
|
4411 |
descr->zCommitHash = fossil_strdup(zUuid); |
|
36ca266…
|
drh
|
4412 |
descr->isDirty = unsaved_changes(0); |
|
36ca266…
|
drh
|
4413 |
|
|
36ca266…
|
drh
|
4414 |
db_multi_exec( |
|
41dc5fc…
|
drh
|
4415 |
"DROP TABLE IF EXISTS temp.singletonTag;" |
|
41dc5fc…
|
drh
|
4416 |
"CREATE TEMP TABLE singletonTag(" |
|
41dc5fc…
|
drh
|
4417 |
" rid INT," |
|
41dc5fc…
|
drh
|
4418 |
" tagname TEXT," |
|
41dc5fc…
|
drh
|
4419 |
" PRIMARY KEY (rid,tagname)" |
|
41dc5fc…
|
drh
|
4420 |
") WITHOUT ROWID;" |
|
41dc5fc…
|
drh
|
4421 |
"INSERT OR IGNORE INTO singletonTag(rid, tagname)" |
|
41dc5fc…
|
drh
|
4422 |
" SELECT min(rid)," |
|
41dc5fc…
|
drh
|
4423 |
" substr(tagname,5)" |
|
41dc5fc…
|
drh
|
4424 |
" FROM tag, tagxref" |
|
41dc5fc…
|
drh
|
4425 |
" WHERE tag.tagid=tagxref.tagid" |
|
41dc5fc…
|
drh
|
4426 |
" AND tagxref.tagtype=1" |
|
41dc5fc…
|
drh
|
4427 |
" AND tagname GLOB 'sym-%q'" |
|
41dc5fc…
|
drh
|
4428 |
" GROUP BY tagname" |
|
41dc5fc…
|
drh
|
4429 |
" HAVING count(*)==1;", |
|
41dc5fc…
|
drh
|
4430 |
(matchGlob ? matchGlob : "*") |
|
36ca266…
|
drh
|
4431 |
); |
|
36ca266…
|
drh
|
4432 |
|
|
36ca266…
|
drh
|
4433 |
db_prepare(&q, |
|
41dc5fc…
|
drh
|
4434 |
"WITH RECURSIVE" |
|
41dc5fc…
|
drh
|
4435 |
" ancestor(rid,mtime,tagname,n) AS (" |
|
41dc5fc…
|
drh
|
4436 |
" SELECT %d, event.mtime, singletonTag.tagname, 0 " |
|
41dc5fc…
|
drh
|
4437 |
" FROM event" |
|
41dc5fc…
|
drh
|
4438 |
" LEFT JOIN singletonTag ON singletonTag.rid=event.objid" |
|
41dc5fc…
|
drh
|
4439 |
" WHERE event.objid=%d" |
|
41dc5fc…
|
drh
|
4440 |
" UNION ALL" |
|
41dc5fc…
|
drh
|
4441 |
" SELECT plink.pid, event.mtime, singletonTag.tagname, n+1" |
|
41dc5fc…
|
drh
|
4442 |
" FROM ancestor, plink, event" |
|
41dc5fc…
|
drh
|
4443 |
" LEFT JOIN singletonTag ON singletonTag.rid=plink.pid" |
|
41dc5fc…
|
drh
|
4444 |
" WHERE plink.cid=ancestor.rid" |
|
1cc2da2…
|
danield
|
4445 |
" AND plink.isprim=1" |
|
41dc5fc…
|
drh
|
4446 |
" AND event.objid=plink.pid" |
|
41dc5fc…
|
drh
|
4447 |
" AND ancestor.tagname IS NULL" |
|
41dc5fc…
|
drh
|
4448 |
" ORDER BY mtime DESC" |
|
1cc2da2…
|
danield
|
4449 |
" LIMIT 100000" |
|
41dc5fc…
|
drh
|
4450 |
" )" |
|
41dc5fc…
|
drh
|
4451 |
"SELECT tagname, n" |
|
41dc5fc…
|
drh
|
4452 |
" FROM ancestor" |
|
41dc5fc…
|
drh
|
4453 |
" WHERE tagname IS NOT NULL" |
|
41dc5fc…
|
drh
|
4454 |
" ORDER BY n LIMIT 1;", |
|
41dc5fc…
|
drh
|
4455 |
rid, rid |
|
36ca266…
|
drh
|
4456 |
); |
|
36ca266…
|
drh
|
4457 |
|
|
36ca266…
|
drh
|
4458 |
if( db_step(&q)==SQLITE_ROW ){ |
|
41dc5fc…
|
drh
|
4459 |
const char *lastTag = db_column_text(&q, 0); |
|
4c3e172…
|
danield
|
4460 |
descr->zRelTagname = fossil_strdup(lastTag); |
|
41dc5fc…
|
drh
|
4461 |
descr->nCommitsSince = db_column_int(&q, 1); |
|
36ca266…
|
drh
|
4462 |
nRet = 0; |
|
36ca266…
|
drh
|
4463 |
}else{ |
|
36ca266…
|
drh
|
4464 |
/* no ancestor commit with a fitting singleton tag found */ |
|
36ca266…
|
drh
|
4465 |
descr->zRelTagname = mprintf(""); |
|
36ca266…
|
drh
|
4466 |
descr->nCommitsSince = -1; |
|
36ca266…
|
drh
|
4467 |
nRet = -3; |
|
36ca266…
|
drh
|
4468 |
} |
|
36ca266…
|
drh
|
4469 |
|
|
36ca266…
|
drh
|
4470 |
db_finalize(&q); |
|
36ca266…
|
drh
|
4471 |
return nRet; |
|
36ca266…
|
drh
|
4472 |
} |
|
36ca266…
|
drh
|
4473 |
|
|
36ca266…
|
drh
|
4474 |
/* |
|
36ca266…
|
drh
|
4475 |
** COMMAND: describe |
|
36ca266…
|
drh
|
4476 |
** |
|
36ca266…
|
drh
|
4477 |
** Usage: %fossil describe ?VERSION? ?OPTIONS? |
|
36ca266…
|
drh
|
4478 |
** |
|
36ca266…
|
drh
|
4479 |
** Provide a description of the given VERSION by showing a non-propagating |
|
36ca266…
|
drh
|
4480 |
** tag of the youngest tagged ancestor, followed by the number of commits |
|
52dd8a9…
|
danield
|
4481 |
** since that, and the short hash of VERSION. Only tags applied to a single |
|
52dd8a9…
|
danield
|
4482 |
** check-in are considered. |
|
52dd8a9…
|
danield
|
4483 |
** |
|
bc36fdc…
|
danield
|
4484 |
** If no VERSION is provided, describe the currently checked-out version. |
|
36ca266…
|
drh
|
4485 |
** |
|
52dd8a9…
|
danield
|
4486 |
** If VERSION and the found ancestor refer to the same commit, the last two |
|
52dd8a9…
|
danield
|
4487 |
** components are omitted, unless --long is provided. When no fitting tagged |
|
52dd8a9…
|
danield
|
4488 |
** ancestor is found, show only the short hash of VERSION. |
|
36ca266…
|
drh
|
4489 |
** |
|
36ca266…
|
drh
|
4490 |
** Options: |
|
275da70…
|
danield
|
4491 |
** --digits Display so many hex digits of the hash |
|
52dd8a9…
|
danield
|
4492 |
** (default: the larger of 6 and the 'hash-digit' setting) |
|
36ca266…
|
drh
|
4493 |
** -d|--dirty Show whether there are changes to be committed |
|
36ca266…
|
drh
|
4494 |
** --long Always show all three components |
|
36ca266…
|
drh
|
4495 |
** --match GLOB Consider only non-propagating tags matching GLOB |
|
36ca266…
|
drh
|
4496 |
*/ |
|
36ca266…
|
drh
|
4497 |
void describe_cmd(void){ |
|
36ca266…
|
drh
|
4498 |
const char *zName; |
|
36ca266…
|
drh
|
4499 |
const char *zMatchGlob; |
|
36ca266…
|
drh
|
4500 |
const char *zDigits; |
|
36ca266…
|
drh
|
4501 |
int nDigits; |
|
36ca266…
|
drh
|
4502 |
int bDirtyFlag = 0; |
|
36ca266…
|
drh
|
4503 |
int bLongFlag = 0; |
|
36ca266…
|
drh
|
4504 |
CommitDescr descr; |
|
36ca266…
|
drh
|
4505 |
|
|
36ca266…
|
drh
|
4506 |
db_find_and_open_repository(0,0); |
|
36ca266…
|
drh
|
4507 |
bDirtyFlag = find_option("dirty","d",0)!=0; |
|
36ca266…
|
drh
|
4508 |
bLongFlag = find_option("long","",0)!=0; |
|
36ca266…
|
drh
|
4509 |
zMatchGlob = find_option("match", 0, 1); |
|
36ca266…
|
drh
|
4510 |
zDigits = find_option("digits", 0, 1); |
|
36ca266…
|
drh
|
4511 |
|
|
36ca266…
|
drh
|
4512 |
if ( !zDigits || ((nDigits=atoi(zDigits))==0) ){ |
|
951cf9f…
|
danield
|
4513 |
nDigits = hash_digits(0); |
|
36ca266…
|
drh
|
4514 |
} |
|
36ca266…
|
drh
|
4515 |
|
|
36ca266…
|
drh
|
4516 |
/* We should be done with options.. */ |
|
36ca266…
|
drh
|
4517 |
verify_all_options(); |
|
36ca266…
|
drh
|
4518 |
if( g.argc<3 ){ |
|
36ca266…
|
drh
|
4519 |
zName = "current"; |
|
36ca266…
|
drh
|
4520 |
}else{ |
|
36ca266…
|
drh
|
4521 |
zName = g.argv[2]; |
|
36ca266…
|
drh
|
4522 |
} |
|
36ca266…
|
drh
|
4523 |
|
|
36ca266…
|
drh
|
4524 |
if( bDirtyFlag ){ |
|
bc36fdc…
|
danield
|
4525 |
if ( g.argc>=3 ) fossil_fatal("cannot use --dirty with specific check-in"); |
|
36ca266…
|
drh
|
4526 |
} |
|
36ca266…
|
drh
|
4527 |
|
|
36ca266…
|
drh
|
4528 |
switch( describe_commit(zName, zMatchGlob, &descr) ){ |
|
36ca266…
|
drh
|
4529 |
case -1: |
|
36ca266…
|
drh
|
4530 |
fossil_fatal("commit %s does not exist", zName); |
|
36ca266…
|
drh
|
4531 |
break; |
|
36ca266…
|
drh
|
4532 |
case -2: |
|
36ca266…
|
drh
|
4533 |
fossil_fatal("commit %s is ambiguous", zName); |
|
36ca266…
|
drh
|
4534 |
break; |
|
36ca266…
|
drh
|
4535 |
case -3: |
|
36ca266…
|
drh
|
4536 |
fossil_print("%.*s%s\n", nDigits, descr.zCommitHash, |
|
36ca266…
|
drh
|
4537 |
bDirtyFlag ? (descr.isDirty ? "-dirty" : "") : ""); |
|
36ca266…
|
drh
|
4538 |
break; |
|
36ca266…
|
drh
|
4539 |
case 0: |
|
36ca266…
|
drh
|
4540 |
if( descr.nCommitsSince==0 && !bLongFlag ){ |
|
36ca266…
|
drh
|
4541 |
fossil_print("%s%s\n", descr.zRelTagname, |
|
36ca266…
|
drh
|
4542 |
bDirtyFlag ? (descr.isDirty ? "-dirty" : "") : ""); |
|
36ca266…
|
drh
|
4543 |
}else{ |
|
36ca266…
|
drh
|
4544 |
fossil_print("%s-%d-%.*s%s\n", descr.zRelTagname, |
|
36ca266…
|
drh
|
4545 |
descr.nCommitsSince, nDigits, descr.zCommitHash, |
|
36ca266…
|
drh
|
4546 |
bDirtyFlag ? (descr.isDirty ? "-dirty" : "") : ""); |
|
36ca266…
|
drh
|
4547 |
} |
|
36ca266…
|
drh
|
4548 |
break; |
|
36ca266…
|
drh
|
4549 |
default: |
|
36ca266…
|
drh
|
4550 |
fossil_fatal("cannot describe commit"); |
|
36ca266…
|
drh
|
4551 |
break; |
|
36ca266…
|
drh
|
4552 |
} |
|
1a9c6db…
|
drh
|
4553 |
} |