Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add an "finfo" command to give file history. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
8c8f8616a64ad4868e93e07c4d230f72 |
| User & Date: | drh 2009-10-31 15:07:45.000 |
References
|
2009-11-09
| ||
| 21:25 | • Closed ticket [7bb8f2359a]: please add a fossil command to retrieve the history for a given file plus 2 other changes artifact: 60a3ba9a25 user: drh | |
Context
|
2009-10-31
| ||
| 17:01 | Add the "artifact" command for extracting the content of individual artifacts. The new "artifact" command is really just a renaming of "test-content-get". check-in: 8480dd38d2 user: drh tags: trunk | |
| 15:07 | Add an "finfo" command to give file history. check-in: 8c8f8616a6 user: drh tags: trunk | |
| 14:03 | Fix the "remote-url" command so that it preserves the userid and password. Ticket [68c7f7bee951302]. check-in: 11ecd5c0b5 user: drh tags: trunk | |
Changes
Added src/finfo.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
/*
** Copyright (c) 2009 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public
** License version 2 as published by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public
** License along with this library; if not, write to the
** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
** Boston, MA 02111-1307, USA.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains code to implement the "finfo" command.
*/
#include "config.h"
#include "finfo.h"
/*
** COMMAND: finfo
**
** Usage: %fossil finfo FILENAME
**
** Print the change history for a single file.
**
** The "--limit N" and "--offset P" options limits the output to the first
** N changes after skipping P changes.
*/
void finfo_cmd(void){
Stmt q;
int vid;
Blob dest;
const char *zFilename;
const char *zLimit;
const char *zOffset;
int iLimit, iOffset;
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
if( vid==0 ){
fossil_panic("no checkout to finfo files in");
}
zLimit = find_option("limit",0,1);
iLimit = zLimit ? atoi(zLimit) : -1;
zOffset = find_option("offset",0,1);
iOffset = zOffset ? atoi(zOffset) : 0;
if (g.argc<3) {
usage("FILENAME");
}
file_tree_name(g.argv[2], &dest, 1);
zFilename = blob_str(&dest);
db_prepare(&q,
"SELECT b.uuid, ci.uuid, date(event.mtime,'localtime'),"
" coalesce(event.ecomment, event.comment),"
" coalesce(event.euser, event.user)"
" FROM mlink, blob b, event, blob ci"
" WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
" AND b.rid=mlink.fid"
" AND event.objid=mlink.mid"
" AND event.objid=ci.rid"
" ORDER BY event.mtime DESC LIMIT %d OFFSET %d",
zFilename, iLimit, iOffset
);
printf("History of %s\n", zFilename);
while( db_step(&q)==SQLITE_ROW ){
const char *zFileUuid = db_column_text(&q, 0);
const char *zCiUuid = db_column_text(&q, 1);
const char *zDate = db_column_text(&q, 2);
const char *zCom = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 4);
char *zOut;
printf("%s ", zDate);
zOut = sqlite3_mprintf("[%.10s] %s (user: %s, artifact: [%.10s])",
zCiUuid, zCom, zUser, zFileUuid);
comment_print(zOut, 11, 79);
sqlite3_free(zOut);
}
db_finalize(&q);
blob_reset(&dest);
}
/*
** WEBPAGE: finfo
** URL: /finfo?name=FILENAME
**
** Show the complete change history for a single file.
*/
void finfo_page(void){
Stmt q;
const char *zFilename;
char zPrevDate[20];
Blob title;
login_check_credentials();
if( !g.okRead ){ login_needed(); return; }
style_header("File History");
login_anonymous_available();
zPrevDate[0] = 0;
zFilename = PD("name","");
db_prepare(&q,
"SELECT substr(b.uuid,1,10), datetime(event.mtime,'localtime'),"
" coalesce(event.ecomment, event.comment),"
" coalesce(event.euser, event.user),"
" mlink.pid, mlink.fid, mlink.mid, mlink.fnid, ci.uuid"
" FROM mlink, blob b, event, blob ci"
" WHERE mlink.fnid=(SELECT fnid FROM filename WHERE name=%Q)"
" AND b.rid=mlink.fid"
" AND event.objid=mlink.mid"
" AND event.objid=ci.rid"
" ORDER BY event.mtime DESC",
zFilename
);
blob_zero(&title);
blob_appendf(&title, "History of ");
hyperlinked_path(zFilename, &title);
@ <h2>%b(&title)</h2>
blob_reset(&title);
@ <table cellspacing=0 border=0 cellpadding=0>
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
int fpid = db_column_int(&q, 4);
int frid = db_column_int(&q, 5);
int mid = db_column_int(&q, 6);
int fnid = db_column_int(&q, 7);
const char *zCkin = db_column_text(&q,8);
char zShort[20];
char zShortCkin[20];
if( memcmp(zDate, zPrevDate, 10) ){
sprintf(zPrevDate, "%.10s", zDate);
@ <tr><td colspan=3>
@ <div class="divider">%s(zPrevDate)</div>
@ </td></tr>
}
@ <tr><td valign="top">%s(&zDate[11])</td>
@ <td width="20"></td>
@ <td valign="top" align="left">
sqlite3_snprintf(sizeof(zShort), zShort, "%.10s", zUuid);
sqlite3_snprintf(sizeof(zShortCkin), zShortCkin, "%.10s", zCkin);
if( g.okHistory ){
@ <a href="%s(g.zTop)/artifact/%s(zUuid)">[%s(zShort)]</a>
}else{
@ [%s(zShort)]
}
@ part of check-in
hyperlink_to_uuid(zShortCkin);
@ %h(zCom) (By:
hyperlink_to_user(zUser, zDate, " on");
hyperlink_to_date(zDate, ")");
if( g.okHistory ){
if( fpid ){
@ <a href="%s(g.zBaseURL)/fdiff?v1=%d(fpid)&v2=%d(frid)">[diff]</a>
}
@ <a href="%s(g.zBaseURL)/annotate?mid=%d(mid)&fnid=%d(fnid)">
@ [annotate]</a>
@ </td>
}
}
db_finalize(&q);
@ </table>
style_footer();
}
|
Changes to src/info.c.
| ︙ | ︙ | |||
473 474 475 476 477 478 479 |
wiki_convert(&wiki, 0, 0);
blob_reset(&wiki);
}
manifest_clear(&m);
}
style_footer();
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 |
wiki_convert(&wiki, 0, 0);
blob_reset(&wiki);
}
manifest_clear(&m);
}
style_footer();
}
/*
** WEBPAGE: vdiff
** URL: /vdiff?name=RID
**
** Show all differences for a particular check-in.
*/
|
| ︙ | ︙ |
Changes to src/main.mk.
| ︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 45 46 47 | $(SRCDIR)/deltacmd.c \ $(SRCDIR)/descendants.c \ $(SRCDIR)/diff.c \ $(SRCDIR)/diffcmd.c \ $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/file.c \ $(SRCDIR)/http.c \ $(SRCDIR)/http_socket.c \ $(SRCDIR)/http_transport.c \ $(SRCDIR)/info.c \ $(SRCDIR)/login.c \ $(SRCDIR)/main.c \ $(SRCDIR)/manifest.c \ | > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | $(SRCDIR)/deltacmd.c \ $(SRCDIR)/descendants.c \ $(SRCDIR)/diff.c \ $(SRCDIR)/diffcmd.c \ $(SRCDIR)/doc.c \ $(SRCDIR)/encode.c \ $(SRCDIR)/file.c \ $(SRCDIR)/finfo.c \ $(SRCDIR)/http.c \ $(SRCDIR)/http_socket.c \ $(SRCDIR)/http_transport.c \ $(SRCDIR)/info.c \ $(SRCDIR)/login.c \ $(SRCDIR)/main.c \ $(SRCDIR)/manifest.c \ |
| ︙ | ︙ | |||
103 104 105 106 107 108 109 110 111 112 113 114 115 116 | deltacmd_.c \ descendants_.c \ diff_.c \ diffcmd_.c \ doc_.c \ encode_.c \ file_.c \ http_.c \ http_socket_.c \ http_transport_.c \ info_.c \ login_.c \ main_.c \ manifest_.c \ | > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | deltacmd_.c \ descendants_.c \ diff_.c \ diffcmd_.c \ doc_.c \ encode_.c \ file_.c \ finfo_.c \ http_.c \ http_socket_.c \ http_transport_.c \ info_.c \ login_.c \ main_.c \ manifest_.c \ |
| ︙ | ︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 | deltacmd.o \ descendants.o \ diff.o \ diffcmd.o \ doc.o \ encode.o \ file.o \ http.o \ http_socket.o \ http_transport.o \ info.o \ login.o \ main.o \ manifest.o \ | > | 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | deltacmd.o \ descendants.o \ diff.o \ diffcmd.o \ doc.o \ encode.o \ file.o \ finfo.o \ http.o \ http_socket.o \ http_transport.o \ info.o \ login.o \ main.o \ manifest.o \ |
| ︙ | ︙ | |||
256 257 258 259 260 261 262 | # $(SRCDIR)/../manifest: # noop clean: rm -f *.o *_.c $(APPNAME) VERSION.h rm -f translate makeheaders mkindex page_index.h headers | | | | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | # $(SRCDIR)/../manifest: # noop clean: rm -f *.o *_.c $(APPNAME) VERSION.h rm -f translate makeheaders mkindex page_index.h headers rm -f add.h allrepo.h bag.h blob.h branch.h browse.h captcha.h cgi.h checkin.h checkout.h clearsign.h clone.h comformat.h configure.h construct.h content.h db.h delta.h deltacmd.h descendants.h diff.h diffcmd.h doc.h encode.h file.h finfo.h http.h http_socket.h http_transport.h info.h login.h main.h manifest.h md5.h merge.h merge3.h name.h pivot.h pqueue.h printf.h rebuild.h report.h rss.h rstats.h schema.h search.h setup.h sha1.h shun.h stat.h style.h sync.h tag.h th_main.h timeline.h tkt.h tktsetup.h undo.h update.h url.h user.h verify.h vfile.h wiki.h wikiformat.h winhttp.h xfer.h zip.h page_index.h: $(TRANS_SRC) mkindex ./mkindex $(TRANS_SRC) >$@ headers: page_index.h makeheaders VERSION.h ./makeheaders add_.c:add.h allrepo_.c:allrepo.h bag_.c:bag.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h construct_.c:construct.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h file_.c:file.h finfo_.c:finfo.h http_.c:http.h http_socket_.c:http_socket.h http_transport_.c:http_transport.h info_.c:info.h login_.c:login.h main_.c:main.h manifest_.c:manifest.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h name_.c:name.h pivot_.c:pivot.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h report_.c:report.h rss_.c:rss.h rstats_.c:rstats.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h update_.c:update.h url_.c:url.h user_.c:user.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winhttp_.c:winhttp.h xfer_.c:xfer.h zip_.c:zip.h $(SRCDIR)/sqlite3.h $(SRCDIR)/th.h VERSION.h touch headers headers: Makefile Makefile: add_.c: $(SRCDIR)/add.c translate ./translate $(SRCDIR)/add.c >add_.c add.o: add_.c add.h $(SRCDIR)/config.h |
| ︙ | ︙ | |||
440 441 442 443 444 445 446 447 448 449 450 451 452 453 | file_.c: $(SRCDIR)/file.c translate ./translate $(SRCDIR)/file.c >file_.c file.o: file_.c file.h $(SRCDIR)/config.h $(XTCC) -o file.o -c file_.c file.h: headers http_.c: $(SRCDIR)/http.c translate ./translate $(SRCDIR)/http.c >http_.c http.o: http_.c http.h $(SRCDIR)/config.h $(XTCC) -o http.o -c http_.c http.h: headers | > > > > > > > | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 | file_.c: $(SRCDIR)/file.c translate ./translate $(SRCDIR)/file.c >file_.c file.o: file_.c file.h $(SRCDIR)/config.h $(XTCC) -o file.o -c file_.c file.h: headers finfo_.c: $(SRCDIR)/finfo.c translate ./translate $(SRCDIR)/finfo.c >finfo_.c finfo.o: finfo_.c finfo.h $(SRCDIR)/config.h $(XTCC) -o finfo.o -c finfo_.c finfo.h: headers http_.c: $(SRCDIR)/http.c translate ./translate $(SRCDIR)/http.c >http_.c http.o: http_.c http.h $(SRCDIR)/config.h $(XTCC) -o http.o -c http_.c http.h: headers |
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | deltacmd descendants diff diffcmd doc encode file http http_socket http_transport info login main manifest | > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | deltacmd descendants diff diffcmd doc encode file finfo http http_socket http_transport info login main manifest |
| ︙ | ︙ |