Differences From:
File
src/update.c
part of check-in
[b5d82ebd7e]
- Bug fix in the update command.
by
drh on
2007-09-22 19:03:22.
[view]
To:
File
src/update.c
part of check-in
[ff4cc5fae2]
- Fixes to the timeline webpage and the "open" and "update" commands.
by
drh on
2007-09-23 18:49:50.
[view]
@@ -52,16 +52,18 @@
void update_cmd(void){
int vid; /* Current version */
int tid; /* Target version - version we are changing to */
Stmt q;
+ int latestFlag; /* Pick the latest version if true */
+ latestFlag = find_option("latest",0, 0)!=0;
if( g.argc!=3 && g.argc!=2 ){
usage("?VERSION?");
}
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
if( vid==0 ){
- vid = 1;
+ fossil_fatal("cannot find current version");
}
if( db_exists("SELECT 1 FROM vmerge") ){
fossil_fatal("cannot update an uncommitted merge");
}
@@ -74,9 +76,9 @@
fossil_fatal("not a version: %s", g.argv[2]);
}
}else{
compute_leaves(vid);
- if( db_int(0, "SELECT count(*) FROM leaves")>1 ){
+ if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
db_prepare(&q,
"%s "
" AND event.objid IN leaves"
" ORDER BY event.mtime DESC",
@@ -85,9 +87,11 @@
print_timeline(&q, 100);
db_finalize(&q);
fossil_fatal("Multiple descendents");
}
- tid = db_int(0, "SELECT rid FROM leaves");
+ tid = db_int(0, "SELECT rid FROM leaves, event"
+ " WHERE event.objid=leaves.rid"
+ " ORDER BY event.mtime DESC");
}
db_begin_transaction();
vfile_check_signature(vid);