File Annotation
Not logged in
dbda8d6ce9 2007-07-21       drh: /*
dbda8d6ce9 2007-07-21       drh: ** Copyright (c) 2007 D. Richard Hipp
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is free software; you can redistribute it and/or
dbda8d6ce9 2007-07-21       drh: ** modify it under the terms of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License version 2 as published by the Free Software Foundation.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This program is distributed in the hope that it will be useful,
dbda8d6ce9 2007-07-21       drh: ** but WITHOUT ANY WARRANTY; without even the implied warranty of
dbda8d6ce9 2007-07-21       drh: ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dbda8d6ce9 2007-07-21       drh: ** General Public License for more details.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** You should have received a copy of the GNU General Public
dbda8d6ce9 2007-07-21       drh: ** License along with this library; if not, write to the
dbda8d6ce9 2007-07-21       drh: ** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
dbda8d6ce9 2007-07-21       drh: ** Boston, MA  02111-1307, USA.
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** Author contact information:
dbda8d6ce9 2007-07-21       drh: **   drh@hwaci.com
dbda8d6ce9 2007-07-21       drh: **   http://www.hwaci.com/drh/
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: *******************************************************************************
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** This file contains code used to merge the changes in the current
dbda8d6ce9 2007-07-21       drh: ** checkout into a different version and switch to that version.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: #include "config.h"
dbda8d6ce9 2007-07-21       drh: #include "update.h"
dbda8d6ce9 2007-07-21       drh: #include <assert.h>
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh: /*
b5d82ebd7e 2007-09-22       drh: ** Return true if artifact rid is a version
b5d82ebd7e 2007-09-22       drh: */
b5d82ebd7e 2007-09-22       drh: int is_a_version(int rid){
b5d82ebd7e 2007-09-22       drh:   return db_exists("SELECT 1 FROM plink WHERE cid=%d", rid);
b5d82ebd7e 2007-09-22       drh: }
b5d82ebd7e 2007-09-22       drh: 
b5d82ebd7e 2007-09-22       drh: /*
dbda8d6ce9 2007-07-21       drh: ** COMMAND: update
6607844a01 2007-08-18       drh: **
5cc845cfeb 2008-02-08       drh: ** Usage: %fossil update ?VERSION? ?--latest?
dbda8d6ce9 2007-07-21       drh: **
dbda8d6ce9 2007-07-21       drh: ** The optional argument is a version that should become the current
dbda8d6ce9 2007-07-21       drh: ** version.  If the argument is omitted, then use the leaf of the
6607844a01 2007-08-18       drh: ** tree that begins with the current version, if there is only a
7eecb079ed 2007-09-26       drh: ** single leaf.  If there are a multiple leaves, the latest is used
7eecb079ed 2007-09-26       drh: ** if the --latest flag is present.
dbda8d6ce9 2007-07-21       drh: **
6607844a01 2007-08-18       drh: ** This command is different from the "checkout" in that edits are
6607844a01 2007-08-18       drh: ** not overwritten.  Edits are merged into the new version.
dbda8d6ce9 2007-07-21       drh: */
dbda8d6ce9 2007-07-21       drh: void update_cmd(void){
dbda8d6ce9 2007-07-21       drh:   int vid;              /* Current version */
b773dda29b 2007-09-25       jnc:   int tid=0;            /* Target version - version we are changing to */
dbda8d6ce9 2007-07-21       drh:   Stmt q;
ff4cc5fae2 2007-09-23       drh:   int latestFlag;       /* Pick the latest version if true */
7eecb079ed 2007-09-26       drh:   int forceFlag;        /* True force the update */
7eecb079ed 2007-09-26       drh: 
b714ab1ea7 2008-05-07       drh:   url_proxy_options();
ff4cc5fae2 2007-09-23       drh:   latestFlag = find_option("latest",0, 0)!=0;
7eecb079ed 2007-09-26       drh:   forceFlag = find_option("force","f",0)!=0;
dbda8d6ce9 2007-07-21       drh:   if( g.argc!=3 && g.argc!=2 ){
dbda8d6ce9 2007-07-21       drh:     usage("?VERSION?");
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_must_be_within_tree();
dbda8d6ce9 2007-07-21       drh:   vid = db_lget_int("checkout", 0);
dbda8d6ce9 2007-07-21       drh:   if( vid==0 ){
ff4cc5fae2 2007-09-23       drh:     fossil_fatal("cannot find current version");
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   if( db_exists("SELECT 1 FROM vmerge") ){
dbda8d6ce9 2007-07-21       drh:     fossil_fatal("cannot update an uncommitted merge");
dbda8d6ce9 2007-07-21       drh:   }
b773dda29b 2007-09-25       jnc: 
dbda8d6ce9 2007-07-21       drh:   if( g.argc==3 ){
dbda8d6ce9 2007-07-21       drh:     tid = name_to_rid(g.argv[2]);
dbda8d6ce9 2007-07-21       drh:     if( tid==0 ){
dbda8d6ce9 2007-07-21       drh:       fossil_fatal("not a version: %s", g.argv[2]);
dbda8d6ce9 2007-07-21       drh:     }
b5d82ebd7e 2007-09-22       drh:     if( !is_a_version(tid) ){
dbda8d6ce9 2007-07-21       drh:       fossil_fatal("not a version: %s", g.argv[2]);
dbda8d6ce9 2007-07-21       drh:     }
b773dda29b 2007-09-25       jnc:   }
b773dda29b 2007-09-25       jnc: 
41561125cd 2007-09-26       jnc:   if( tid==0 ){
41561125cd 2007-09-26       jnc:     /*
41561125cd 2007-09-26       jnc:     ** Do an autosync pull prior to the update, if autosync is on and they
41561125cd 2007-09-26       jnc:     ** did not want a specific version (i.e. another branch, a past revision).
41561125cd 2007-09-26       jnc:     ** By not giving a specific version, they are asking for the latest, thus
41561125cd 2007-09-26       jnc:     ** pull to get the latest, then update.
41561125cd 2007-09-26       jnc:     */
49b59bc559 2008-02-09       drh:     autosync(AUTOSYNC_PULL);
b773dda29b 2007-09-25       jnc:   }
b773dda29b 2007-09-25       jnc: 
b773dda29b 2007-09-25       jnc:   if( tid==0 ){
b6e22e62cf 2009-01-20       drh:     compute_leaves(vid, 1);
ff4cc5fae2 2007-09-23       drh:     if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
fcabd4774c 2007-09-13       drh:       db_prepare(&q,
9395aba4f4 2007-09-22       drh:         "%s "
fcabd4774c 2007-09-13       drh:         "   AND event.objid IN leaves"
9395aba4f4 2007-09-22       drh:         " ORDER BY event.mtime DESC",
9395aba4f4 2007-09-22       drh:         timeline_query_for_tty()
fcabd4774c 2007-09-13       drh:       );
fcabd4774c 2007-09-13       drh:       print_timeline(&q, 100);
fcabd4774c 2007-09-13       drh:       db_finalize(&q);
6458f020fc 2008-05-14       drh:       fossil_fatal("Multiple descendants");
dbda8d6ce9 2007-07-21       drh:     }
ff4cc5fae2 2007-09-23       drh:     tid = db_int(0, "SELECT rid FROM leaves, event"
ff4cc5fae2 2007-09-23       drh:                     " WHERE event.objid=leaves.rid"
ff4cc5fae2 2007-09-23       drh:                     " ORDER BY event.mtime DESC");
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   db_begin_transaction();
dbda8d6ce9 2007-07-21       drh:   vfile_check_signature(vid);
a36177bcce 2007-09-11       drh:   undo_begin();
dbda8d6ce9 2007-07-21       drh:   load_vfile_from_rid(tid);
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   /*
dbda8d6ce9 2007-07-21       drh:   ** The record.fn field is used to match files against each other.  The
dbda8d6ce9 2007-07-21       drh:   ** FV table contains one row for each each unique filename in
dbda8d6ce9 2007-07-21       drh:   ** in the current checkout, the pivot, and the version being merged.
dbda8d6ce9 2007-07-21       drh:   */
dbda8d6ce9 2007-07-21       drh:   db_multi_exec(
dbda8d6ce9 2007-07-21       drh:     "DROP TABLE IF EXISTS fv;"
dbda8d6ce9 2007-07-21       drh:     "CREATE TEMP TABLE fv("
dbda8d6ce9 2007-07-21       drh:     "  fn TEXT PRIMARY KEY,"      /* The filename */
dbda8d6ce9 2007-07-21       drh:     "  idv INTEGER,"              /* VFILE entry for current version */
dbda8d6ce9 2007-07-21       drh:     "  idt INTEGER,"              /* VFILE entry for target version */
dbda8d6ce9 2007-07-21       drh:     "  chnged BOOLEAN,"           /* True if current version has been edited */
dbda8d6ce9 2007-07-21       drh:     "  ridv INTEGER,"             /* Record ID for current version */
dbda8d6ce9 2007-07-21       drh:     "  ridt INTEGER "             /* Record ID for target */
dbda8d6ce9 2007-07-21       drh:     ");"
dbda8d6ce9 2007-07-21       drh:     "INSERT OR IGNORE INTO fv"
dbda8d6ce9 2007-07-21       drh:     " SELECT pathname, 0, 0, 0, 0, 0 FROM vfile"
dbda8d6ce9 2007-07-21       drh:   );
dbda8d6ce9 2007-07-21       drh:   db_prepare(&q,
dbda8d6ce9 2007-07-21       drh:     "SELECT id, pathname, rid FROM vfile"
dbda8d6ce9 2007-07-21       drh:     " WHERE vid=%d", tid
dbda8d6ce9 2007-07-21       drh:   );
dbda8d6ce9 2007-07-21       drh:   while( db_step(&q)==SQLITE_ROW ){
dbda8d6ce9 2007-07-21       drh:     int id = db_column_int(&q, 0);
dbda8d6ce9 2007-07-21       drh:     const char *fn = db_column_text(&q, 1);
dbda8d6ce9 2007-07-21       drh:     int rid = db_column_int(&q, 2);
dbda8d6ce9 2007-07-21       drh:     db_multi_exec(
dbda8d6ce9 2007-07-21       drh:       "UPDATE fv SET idt=%d, ridt=%d WHERE fn=%Q",
dbda8d6ce9 2007-07-21       drh:       id, rid, fn
dbda8d6ce9 2007-07-21       drh:     );
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_finalize(&q);
dbda8d6ce9 2007-07-21       drh:   db_prepare(&q,
dbda8d6ce9 2007-07-21       drh:     "SELECT id, pathname, rid, chnged FROM vfile"
dbda8d6ce9 2007-07-21       drh:     " WHERE vid=%d", vid
dbda8d6ce9 2007-07-21       drh:   );
dbda8d6ce9 2007-07-21       drh:   while( db_step(&q)==SQLITE_ROW ){
dbda8d6ce9 2007-07-21       drh:     int id = db_column_int(&q, 0);
dbda8d6ce9 2007-07-21       drh:     const char *fn = db_column_text(&q, 1);
dbda8d6ce9 2007-07-21       drh:     int rid = db_column_int(&q, 2);
dbda8d6ce9 2007-07-21       drh:     int chnged = db_column_int(&q, 3);
dbda8d6ce9 2007-07-21       drh:     db_multi_exec(
dbda8d6ce9 2007-07-21       drh:       "UPDATE fv SET idv=%d, ridv=%d, chnged=%d WHERE fn=%Q",
dbda8d6ce9 2007-07-21       drh:       id, rid, chnged, fn
dbda8d6ce9 2007-07-21       drh:     );
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_finalize(&q);
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   db_prepare(&q,
dbda8d6ce9 2007-07-21       drh:     "SELECT fn, idv, ridv, idt, ridt, chnged FROM fv ORDER BY 1"
dbda8d6ce9 2007-07-21       drh:   );
dbda8d6ce9 2007-07-21       drh:   while( db_step(&q)==SQLITE_ROW ){
dbda8d6ce9 2007-07-21       drh:     const char *zName = db_column_text(&q, 0);
dbda8d6ce9 2007-07-21       drh:     int idv = db_column_int(&q, 1);
dbda8d6ce9 2007-07-21       drh:     int ridv = db_column_int(&q, 2);
dbda8d6ce9 2007-07-21       drh:     int idt = db_column_int(&q, 3);
dbda8d6ce9 2007-07-21       drh:     int ridt = db_column_int(&q, 4);
dbda8d6ce9 2007-07-21       drh:     int chnged = db_column_int(&q, 5);
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:     if( idv>0 && ridv==0 && idt>0 ){
dbda8d6ce9 2007-07-21       drh:       /* Conflict.  This file has been added to the current checkout
dbda8d6ce9 2007-07-21       drh:       ** but also exists in the target checkout.  Use the current version.
dbda8d6ce9 2007-07-21       drh:       */
dbda8d6ce9 2007-07-21       drh:       printf("CONFLICT %s\n", zName);
dbda8d6ce9 2007-07-21       drh:     }else if( idt>0 && idv==0 ){
dbda8d6ce9 2007-07-21       drh:       /* File added in the target. */
dbda8d6ce9 2007-07-21       drh:       printf("ADD %s\n", zName);
a36177bcce 2007-09-11       drh:       undo_save(zName);
dbda8d6ce9 2007-07-21       drh:       vfile_to_disk(0, idt, 0);
dbda8d6ce9 2007-07-21       drh:     }else if( idt>0 && idv>0 && ridt!=ridv && chnged==0 ){
dbda8d6ce9 2007-07-21       drh:       /* The file is unedited.  Change it to the target version */
dbda8d6ce9 2007-07-21       drh:       printf("UPDATE %s\n", zName);
a36177bcce 2007-09-11       drh:       undo_save(zName);
dbda8d6ce9 2007-07-21       drh:       vfile_to_disk(0, idt, 0);
dbda8d6ce9 2007-07-21       drh:     }else if( idt==0 && idv>0 ){
fe6ee8a431 2007-08-08       drh:       if( chnged ){
fe6ee8a431 2007-08-08       drh:         printf("CONFLICT %s\n", zName);
fe6ee8a431 2007-08-08       drh:       }else{
fe6ee8a431 2007-08-08       drh:         char *zFullPath;
fe6ee8a431 2007-08-08       drh:         printf("REMOVE %s\n", zName);
a36177bcce 2007-09-11       drh:         undo_save(zName);
fe6ee8a431 2007-08-08       drh:         zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
fe6ee8a431 2007-08-08       drh:         unlink(zFullPath);
fe6ee8a431 2007-08-08       drh:         free(zFullPath);
fe6ee8a431 2007-08-08       drh:       }
dbda8d6ce9 2007-07-21       drh:     }else if( idt>0 && idv>0 && ridt!=ridv && chnged ){
dbda8d6ce9 2007-07-21       drh:       /* Merge the changes in the current tree into the target version */
dbda8d6ce9 2007-07-21       drh:       Blob e, r, t, v;
36b96b8616 2007-11-16       drh:       int rc;
dbda8d6ce9 2007-07-21       drh:       char *zFullPath;
dbda8d6ce9 2007-07-21       drh:       printf("MERGE %s\n", zName);
a36177bcce 2007-09-11       drh:       undo_save(zName);
dbda8d6ce9 2007-07-21       drh:       zFullPath = mprintf("%s/%s", g.zLocalRoot, zName);
dbda8d6ce9 2007-07-21       drh:       content_get(ridt, &t);
dbda8d6ce9 2007-07-21       drh:       content_get(ridv, &v);
dbda8d6ce9 2007-07-21       drh:       blob_zero(&e);
dbda8d6ce9 2007-07-21       drh:       blob_read_from_file(&e, zFullPath);
36b96b8616 2007-11-16       drh:       rc = blob_merge(&v, &e, &t, &r);
36b96b8616 2007-11-16       drh:       if( rc>=0 ){
36b96b8616 2007-11-16       drh:         blob_write_to_file(&r, zFullPath);
36b96b8616 2007-11-16       drh:         if( rc>0 ){
36b96b8616 2007-11-16       drh:           printf("***** %d merge conflicts in %s\n", rc, zName);
36b96b8616 2007-11-16       drh:         }
36b96b8616 2007-11-16       drh:       }else{
36b96b8616 2007-11-16       drh:         printf("***** Cannot merge binary file %s\n", zName);
36b96b8616 2007-11-16       drh:       }
dbda8d6ce9 2007-07-21       drh:       free(zFullPath);
dbda8d6ce9 2007-07-21       drh:       blob_reset(&v);
dbda8d6ce9 2007-07-21       drh:       blob_reset(&e);
dbda8d6ce9 2007-07-21       drh:       blob_reset(&t);
dbda8d6ce9 2007-07-21       drh:       blob_reset(&r);
36b96b8616 2007-11-16       drh: 
dbda8d6ce9 2007-07-21       drh:     }
dbda8d6ce9 2007-07-21       drh:   }
dbda8d6ce9 2007-07-21       drh:   db_finalize(&q);
dbda8d6ce9 2007-07-21       drh: 
dbda8d6ce9 2007-07-21       drh:   /*
dbda8d6ce9 2007-07-21       drh:   ** Clean up the mid and pid VFILE entries.  Then commit the changes.
dbda8d6ce9 2007-07-21       drh:   */
dbda8d6ce9 2007-07-21       drh:   db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
a040ae6e17 2007-08-08       drh:   manifest_to_disk(tid);
dbda8d6ce9 2007-07-21       drh:   db_lset_int("checkout", tid);
dbda8d6ce9 2007-07-21       drh:   db_end_transaction(0);
255bacf907 2007-09-24       jnc: }
255bacf907 2007-09-24       jnc: 
371dd6574c 2007-12-04       drh: 
371dd6574c 2007-12-04       drh: /*
371dd6574c 2007-12-04       drh: ** Get the contents of a file within a given revision.
371dd6574c 2007-12-04       drh: */
371dd6574c 2007-12-04       drh: int historical_version_of_file(
371dd6574c 2007-12-04       drh:   const char *revision,    /* The baseline name containing the file */
371dd6574c 2007-12-04       drh:   const char *file,        /* Full treename of the file */
371dd6574c 2007-12-04       drh:   Blob *content            /* Put the content here */
371dd6574c 2007-12-04       drh: ){
371dd6574c 2007-12-04       drh:   Blob mfile;
371dd6574c 2007-12-04       drh:   Manifest m;
371dd6574c 2007-12-04       drh:   int i, rid=0;
371dd6574c 2007-12-04       drh: 
371dd6574c 2007-12-04       drh:   rid = name_to_rid(revision);
371dd6574c 2007-12-04       drh:   content_get(rid, &mfile);
371dd6574c 2007-12-04       drh: 
371dd6574c 2007-12-04       drh:   if( manifest_parse(&m, &mfile) ){
371dd6574c 2007-12-04       drh:     for(i=0; i<m.nFile; i++){
371dd6574c 2007-12-04       drh:       if( strcmp(m.aFile[i].zName, file)==0 ){
371dd6574c 2007-12-04       drh:         rid = uuid_to_rid(m.aFile[i].zUuid, 0);
371dd6574c 2007-12-04       drh:         return content_get(rid, content);
371dd6574c 2007-12-04       drh:       }
371dd6574c 2007-12-04       drh:     }
371dd6574c 2007-12-04       drh:     fossil_fatal("file %s does not exist in baseline: %s", file, revision);
371dd6574c 2007-12-04       drh:   }else{
371dd6574c 2007-12-04       drh:     fossil_panic("could not parse manifest for baseline: %s", revision);
371dd6574c 2007-12-04       drh:   }
371dd6574c 2007-12-04       drh:   return 0;
371dd6574c 2007-12-04       drh: }
371dd6574c 2007-12-04       drh: 
371dd6574c 2007-12-04       drh: 
255bacf907 2007-09-24       jnc: /*
255bacf907 2007-09-24       jnc: ** COMMAND: revert
255bacf907 2007-09-24       jnc: **
7eecb079ed 2007-09-26       drh: ** Usage: %fossil revert ?--yes? ?-r REVISION? FILE
255bacf907 2007-09-24       jnc: **
371dd6574c 2007-12-04       drh: ** Revert to the current repository version of FILE, or to
371dd6574c 2007-12-04       drh: ** the version associated with baseline REVISION if the -r flag
371dd6574c 2007-12-04       drh: ** appears.  This command will confirm your operation unless the
371dd6574c 2007-12-04       drh: ** file is missing or the --yes option is used.
255bacf907 2007-09-24       jnc: **/
255bacf907 2007-09-24       jnc: void revert_cmd(void){
255bacf907 2007-09-24       jnc:   const char *zFile;
574763bab9 2007-09-26       jnc:   const char *zRevision;
255bacf907 2007-09-24       jnc:   Blob fname;
255bacf907 2007-09-24       jnc:   Blob record;
255bacf907 2007-09-24       jnc:   Blob ans;
574763bab9 2007-09-26       jnc:   int rid = 0, yesRevert;
255bacf907 2007-09-24       jnc: 
574763bab9 2007-09-26       jnc:   yesRevert = find_option("yes", "y", 0)!=0;
574763bab9 2007-09-26       jnc:   zRevision = find_option("revision", "r", 1);
255bacf907 2007-09-24       jnc:   verify_all_options();
255bacf907 2007-09-24       jnc: 
255bacf907 2007-09-24       jnc:   if( g.argc<3 ){
255bacf907 2007-09-24       jnc:     usage("?OPTIONS FILE");
255bacf907 2007-09-24       jnc:   }
255bacf907 2007-09-24       jnc:   db_must_be_within_tree();
255bacf907 2007-09-24       jnc: 
371dd6574c 2007-12-04       drh:   zFile = mprintf("%/", g.argv[g.argc-1]);
574763bab9 2007-09-26       jnc: 
2ecc407d9b 2008-07-23       drh:   file_tree_name(zFile, &fname, 1);
255bacf907 2007-09-24       jnc: 
371dd6574c 2007-12-04       drh:   if( access(zFile, 0) ) yesRevert = 1;
255bacf907 2007-09-24       jnc:   if( yesRevert==0 ){
7eecb079ed 2007-09-26       drh:     char *prompt = mprintf("revert file %B? this will"
7eecb079ed 2007-09-26       drh:                            " destroy local changes [y/N]? ",
255bacf907 2007-09-24       jnc:                            &fname);
255bacf907 2007-09-24       jnc:     blob_zero(&ans);
255bacf907 2007-09-24       jnc:     prompt_user(prompt, &ans);
22cc813f8e 2008-02-02   stephan:     free( prompt );
255bacf907 2007-09-24       jnc:     if( blob_str(&ans)[0]=='y' ){
255bacf907 2007-09-24       jnc:       yesRevert = 1;
255bacf907 2007-09-24       jnc:     }
255bacf907 2007-09-24       jnc:   }
574763bab9 2007-09-26       jnc: 
574763bab9 2007-09-26       jnc:   if( yesRevert==1 && zRevision!=0 ){
371dd6574c 2007-12-04       drh:     historical_version_of_file(zRevision, zFile, &record);
574763bab9 2007-09-26       jnc:   }else if( yesRevert==1 ){
574763bab9 2007-09-26       jnc:     rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
574763bab9 2007-09-26       jnc:     if( rid==0 ){
574763bab9 2007-09-26       jnc:       fossil_panic("no history for file: %b", &fname);
574763bab9 2007-09-26       jnc:     }
255bacf907 2007-09-24       jnc:     content_get(rid, &record);
574763bab9 2007-09-26       jnc:   }
574763bab9 2007-09-26       jnc: 
574763bab9 2007-09-26       jnc:   if( yesRevert==1 ){
371dd6574c 2007-12-04       drh:     blob_write_to_file(&record, zFile);
371dd6574c 2007-12-04       drh:     printf("%s reverted\n", zFile);
255bacf907 2007-09-24       jnc:     blob_reset(&record);
255bacf907 2007-09-24       jnc:     blob_reset(&fname);
255bacf907 2007-09-24       jnc:   }else{
255bacf907 2007-09-24       jnc:     printf("revert canceled\n");
255bacf907 2007-09-24       jnc:   }
dbda8d6ce9 2007-07-21       drh: }