Differences From:
File
src/update.c
part of check-in
[6ae51190cc]
- reserve the use of brackets in stdout for artifacts
by
rwilson on
2009-12-10 02:19:16.
Also file
src/update.c
part of check-in
[1c2d878d12]
- Merge with trunk
by
btheado on
2009-12-13 01:16:13.
[view]
To:
File
src/update.c
part of check-in
[353297a149]
- Change the "revert" command so that it will take multiple file arguments
and revert each one.
by
drh on
2009-12-17 14:21:58.
[view]
@@ -274,64 +274,67 @@
/*
** COMMAND: revert
**
-** Usage: %fossil revert ?--yes? ?-r REVISION? FILE
+** Usage: %fossil revert ?--yes? ?-r REVISION? FILE ...
**
** 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;
+ char *zFile;
const char *zRevision;
Blob fname;
Blob record;
Blob ans;
+ int i;
int rid = 0, yesRevert;
yesRevert = find_option("yes", "y", 0)!=0;
zRevision = find_option("revision", "r", 1);
verify_all_options();
- if( g.argc!=3 ){
- usage("?OPTIONS FILE");
+ if( g.argc<3 ){
+ usage("?OPTIONS FILE ...");
}
db_must_be_within_tree();
- zFile = mprintf("%/", g.argv[g.argc-1]);
-
- file_tree_name(zFile, &fname, 1);
-
- 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);
- prompt_user(prompt, &ans);
- free( prompt );
- if( blob_str(&ans)[0]=='y' ){
- yesRevert = 1;
+ for(i=2; i<g.argc; i++){
+ zFile = mprintf("%/", g.argv[i]);
+ file_tree_name(zFile, &fname, 1);
+ 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);
+ prompt_user(prompt, &ans);
+ free( prompt );
+ if( blob_str(&ans)[0]=='y' ){
+ yesRevert = 1;
+ }
+ blob_reset(&ans);
}
- }
- if( yesRevert==1 && zRevision!=0 ){
- 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 && zRevision!=0 ){
+ 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, zFile);
- printf("%s reverted\n", zFile);
- blob_reset(&record);
- blob_reset(&fname);
- }else{
- printf("revert canceled\n");
+ if( yesRevert==1 ){
+ blob_write_to_file(&record, zFile);
+ printf("%s reverted\n", zFile);
+ blob_reset(&record);
+ blob_reset(&fname);
+ }else{
+ printf("revert canceled\n");
+ }
+ free(zFile);
}
}