Overview
SHA1 Hash: | 371dd6574c3aa26439bb597f9bd69f0a88e7b3f5 |
---|---|
Date: | 2007-12-04 01:26:21 |
User: | drh |
Comment: | Fix the revert command so that it works from subdirectories. Other minor comment and help-text changes. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/checkin.c from [6e8cb78df8] to [5435deb841].
@@ -44,12 +44,15 @@ while( db_step(&q)==SQLITE_ROW ){ const char *zPathname = db_column_text(&q,0); int isDeleted = db_column_int(&q, 1); int isChnged = db_column_int(&q,2); int isNew = db_column_int(&q,3)==0; + char *zFullName = mprintf("%s/%s", g.zLocalRoot, zPathname); blob_append(report, zPrefix, nPrefix); - if( isNew ){ + if( access(zFullName, 0) ){ + blob_appendf(report, "MISSING %s\n", zPathname); + }else if( isNew ){ blob_appendf(report, "ADDED %s\n", zPathname); }else if( isDeleted ){ blob_appendf(report, "DELETED %s\n", zPathname); }else if( isChnged==2 ){ blob_appendf(report, "UPDATED_BY_MERGE %s\n", zPathname); @@ -56,10 +59,11 @@ }else if( isChnged==3 ){ blob_appendf(report, "ADDED_BY_MERGE %s\n", zPathname); }else{ blob_appendf(report, "EDITED %s\n", zPathname); } + free(zFullName); } db_finalize(&q); db_prepare(&q, "SELECT uuid FROM vmerge JOIN blob ON merge=rid" " WHERE id=0"); while( db_step(&q)==SQLITE_ROW ){
Modified src/db.c from [dab15ea695] to [dc61149835].
@@ -323,11 +323,11 @@ } const char *db_column_name(Stmt *pStmt, int N){ return (char*)sqlite3_column_name(pStmt->pStmt, N); } int db_column_count(Stmt *pStmt){ - return (char*)sqlite3_column_count(pStmt->pStmt); + return sqlite3_column_count(pStmt->pStmt); } char *db_column_malloc(Stmt *pStmt, int N){ return mprintf("%s", db_column_text(pStmt, N)); } void db_column_blob(Stmt *pStmt, int N, Blob *pBlob){
Modified src/diffcmd.c from [dfc5dfd350] to [a54672e2c8].
@@ -44,11 +44,11 @@ /* ** COMMAND: diff ** COMMAND: gdiff ** -** Usage: %fossil diff|gdiff ?-i ?-r REVISION FILE... +** Usage: %fossil diff|gdiff ?-i? ?-r REVISION? FILE... ** ** Show the difference between the current version of a file (as it ** exists on disk) and that same file as it was checked out. ** ** diff will show a textual diff while gdiff will attempt to run a @@ -59,18 +59,18 @@ ** If -i is supplied for either diff or gdiff, the internal textual ** diff command will be executed. ** ** Here are a few external diff command settings, for example: ** -** %fossil config diff-command=diff +** %fossil setting diff-command diff ** -** %fossil config gdiff-command=tkdiff -** %fossil config gdiff-command=eskill22 -** %fossil config gdiff-command=tortoisemerge -** %fossil config gdiff-command=meld -** %fossil config gdiff-command=xxdiff -** %fossil config gdiff-command=kdiff3 +** %fossil setting gdiff-command tkdiff +** %fossil setting gdiff-command eskill22 +** %fossil setting gdiff-command tortoisemerge +** %fossil setting gdiff-command meld +** %fossil setting gdiff-command xxdiff +** %fossil setting gdiff-command kdiff3 */ void diff_cmd(void){ const char *zFile, *zRevision; Blob cmd; Blob fname; @@ -116,11 +116,11 @@ if( rid==0 ){ fossil_panic("no history for file: %b", &fname); } content_get(rid, &record); }else{ - content_get_historical_file(zRevision, zFile, &record); + historical_version_of_file(zRevision, zFile, &record); } if( internalDiff==1 ){ Blob out; Blob current; blob_zero(¤t);
Modified src/update.c from [86ce400827] to [676d19419e].
@@ -243,18 +243,50 @@ manifest_to_disk(tid); db_lset_int("checkout", tid); db_end_transaction(0); } + +/* +** Get the contents of a file within a given revision. +*/ +int historical_version_of_file( + const char *revision, /* The baseline name containing the file */ + const char *file, /* Full treename of the file */ + Blob *content /* Put the content here */ +){ + Blob mfile; + Manifest m; + int i, rid=0; + + rid = name_to_rid(revision); + content_get(rid, &mfile); + + if( manifest_parse(&m, &mfile) ){ + for(i=0; i<m.nFile; i++){ + if( strcmp(m.aFile[i].zName, file)==0 ){ + rid = uuid_to_rid(m.aFile[i].zUuid, 0); + return content_get(rid, content); + } + } + fossil_fatal("file %s does not exist in baseline: %s", file, revision); + }else{ + fossil_panic("could not parse manifest for baseline: %s", revision); + } + return 0; +} + + /* ** COMMAND: revert ** ** Usage: %fossil revert ?--yes? ?-r REVISION? FILE ** -** Revert to the current repository version of FILE. This -** command will confirm your operation, unless you do so -** at the command line via the -yes option. +** Revert to the current repository version of FILE, or to +** the version associated with baseline REVISION if the -r flag +** appears. This command will confirm your operation unless the +** file is missing or the --yes option is used. **/ void revert_cmd(void){ const char *zFile; const char *zRevision; Blob fname; @@ -269,16 +301,17 @@ if( g.argc<3 ){ usage("?OPTIONS FILE"); } db_must_be_within_tree(); - zFile = g.argv[g.argc-1]; + zFile = mprintf("%/", g.argv[g.argc-1]); if( !file_tree_name(zFile, &fname) ){ fossil_panic("unknown file: %s", zFile); } + if( access(zFile, 0) ) yesRevert = 1; if( yesRevert==0 ){ char *prompt = mprintf("revert file %B? this will" " destroy local changes [y/N]? ", &fname); blob_zero(&ans); @@ -287,23 +320,23 @@ yesRevert = 1; } } if( yesRevert==1 && zRevision!=0 ){ - content_get_historical_file(zRevision, zFile, &record); + historical_version_of_file(zRevision, zFile, &record); }else if( yesRevert==1 ){ rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname); if( rid==0 ){ fossil_panic("no history for file: %b", &fname); } content_get(rid, &record); } if( yesRevert==1 ){ - blob_write_to_file(&record, blob_str(&fname)); - printf("%s reverted\n", blob_str(&fname)); + blob_write_to_file(&record, zFile); + printf("%s reverted\n", zFile); blob_reset(&record); blob_reset(&fname); }else{ printf("revert canceled\n"); } }
Modified src/wikiformat.c from [e974e96172] to [d9ba82df4d].
@@ -774,11 +774,10 @@ ** If the input string corresponds to an existing baseline, ** return true. */ static int is_valid_uuid(const char *z){ int n = strlen(z); - int rid; if( n<4 || n>UUID_SIZE ) return 0; if( !validate16(z, n) ) return 0; return 1; }