Fossil SCM

Fixes to the timeline webpage and the "open" and "update" commands.

drh 2007-09-23 18:49 trunk
Commit ff4cc5fae2e88f97c536462ac5b63387b5a5605f
3 files changed +8 -1 +7 -1 +7 -3
+8 -1
--- src/db.c
+++ src/db.c
@@ -872,10 +872,12 @@
872872
** for the repository is created with its root at the working directory.
873873
** See also the "close" command.
874874
*/
875875
void cmd_open(void){
876876
Blob path;
877
+ int vid;
878
+ static char *azNewArgv[] = { 0, "update", "--latest", 0 };
877879
if( g.argc!=3 ){
878880
usage("REPOSITORY-FILENAME");
879881
}
880882
if( db_open_local() ){
881883
fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
@@ -883,11 +885,16 @@
883885
file_canonical_name(g.argv[2], &path);
884886
db_open_repository(blob_str(&path));
885887
db_init_database("./_FOSSIL_", zLocalSchema, (char*)0);
886888
db_open_local();
887889
db_lset("repository", blob_str(&path));
888
- db_lset_int("checkout", 1);
890
+ vid = db_int(0, "SELECT pid FROM plink y"
891
+ " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
892
+ db_lset_int("checkout", vid);
893
+ g.argv = azNewArgv;
894
+ g.argc = 3;
895
+ update_cmd();
889896
}
890897
891898
/*
892899
** COMMAND: config
893900
**
894901
--- src/db.c
+++ src/db.c
@@ -872,10 +872,12 @@
872 ** for the repository is created with its root at the working directory.
873 ** See also the "close" command.
874 */
875 void cmd_open(void){
876 Blob path;
 
 
877 if( g.argc!=3 ){
878 usage("REPOSITORY-FILENAME");
879 }
880 if( db_open_local() ){
881 fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
@@ -883,11 +885,16 @@
883 file_canonical_name(g.argv[2], &path);
884 db_open_repository(blob_str(&path));
885 db_init_database("./_FOSSIL_", zLocalSchema, (char*)0);
886 db_open_local();
887 db_lset("repository", blob_str(&path));
888 db_lset_int("checkout", 1);
 
 
 
 
 
889 }
890
891 /*
892 ** COMMAND: config
893 **
894
--- src/db.c
+++ src/db.c
@@ -872,10 +872,12 @@
872 ** for the repository is created with its root at the working directory.
873 ** See also the "close" command.
874 */
875 void cmd_open(void){
876 Blob path;
877 int vid;
878 static char *azNewArgv[] = { 0, "update", "--latest", 0 };
879 if( g.argc!=3 ){
880 usage("REPOSITORY-FILENAME");
881 }
882 if( db_open_local() ){
883 fossil_panic("already within an open tree rooted at %s", g.zLocalRoot);
@@ -883,11 +885,16 @@
885 file_canonical_name(g.argv[2], &path);
886 db_open_repository(blob_str(&path));
887 db_init_database("./_FOSSIL_", zLocalSchema, (char*)0);
888 db_open_local();
889 db_lset("repository", blob_str(&path));
890 vid = db_int(0, "SELECT pid FROM plink y"
891 " WHERE NOT EXISTS(SELECT 1 FROM plink x WHERE x.cid=y.pid)");
892 db_lset_int("checkout", vid);
893 g.argv = azNewArgv;
894 g.argc = 3;
895 update_cmd();
896 }
897
898 /*
899 ** COMMAND: config
900 **
901
+7 -1
--- src/timeline.c
+++ src/timeline.c
@@ -364,14 +364,20 @@
364364
@ Number Of Entries:
365365
@ <input type="text" size="4" value="%d(nEntry)" name="n">
366366
@ <br><input type="submit" value="Submit">
367367
@ </form>
368368
@ <form method="GET" action="%s(g.zBaseURL)/timeline">
369
- @ <input type="hidden" value="%h(zDate)" name="d">
369
+ @ <input type="hidden" value="%d(lastEvent)" name="e">
370370
@ <input type="hidden" value="%d(nEntry)" name="n">
371371
@ <input type="submit" value="Next %d(nEntry) Rows">
372372
@ </form>
373
+ @ <form method="GET" action="%s(g.zBaseURL)/timeline">
374
+ @ <input type="hidden" value="%d(firstEvent)" name="e">
375
+ @ <input type="hidden" value="1" name="a">
376
+ @ <input type="hidden" value="%d(nEntry)" name="n">
377
+ @ <input type="submit" value="Previous %d(nEntry) Rows">
378
+ @ </form>
373379
style_footer();
374380
}
375381
376382
/*
377383
** The input query q selects various records. Print a human-readable
378384
--- src/timeline.c
+++ src/timeline.c
@@ -364,14 +364,20 @@
364 @ Number Of Entries:
365 @ <input type="text" size="4" value="%d(nEntry)" name="n">
366 @ <br><input type="submit" value="Submit">
367 @ </form>
368 @ <form method="GET" action="%s(g.zBaseURL)/timeline">
369 @ <input type="hidden" value="%h(zDate)" name="d">
370 @ <input type="hidden" value="%d(nEntry)" name="n">
371 @ <input type="submit" value="Next %d(nEntry) Rows">
372 @ </form>
 
 
 
 
 
 
373 style_footer();
374 }
375
376 /*
377 ** The input query q selects various records. Print a human-readable
378
--- src/timeline.c
+++ src/timeline.c
@@ -364,14 +364,20 @@
364 @ Number Of Entries:
365 @ <input type="text" size="4" value="%d(nEntry)" name="n">
366 @ <br><input type="submit" value="Submit">
367 @ </form>
368 @ <form method="GET" action="%s(g.zBaseURL)/timeline">
369 @ <input type="hidden" value="%d(lastEvent)" name="e">
370 @ <input type="hidden" value="%d(nEntry)" name="n">
371 @ <input type="submit" value="Next %d(nEntry) Rows">
372 @ </form>
373 @ <form method="GET" action="%s(g.zBaseURL)/timeline">
374 @ <input type="hidden" value="%d(firstEvent)" name="e">
375 @ <input type="hidden" value="1" name="a">
376 @ <input type="hidden" value="%d(nEntry)" name="n">
377 @ <input type="submit" value="Previous %d(nEntry) Rows">
378 @ </form>
379 style_footer();
380 }
381
382 /*
383 ** The input query q selects various records. Print a human-readable
384
+7 -3
--- src/update.c
+++ src/update.c
@@ -51,18 +51,20 @@
5151
*/
5252
void update_cmd(void){
5353
int vid; /* Current version */
5454
int tid; /* Target version - version we are changing to */
5555
Stmt q;
56
+ int latestFlag; /* Pick the latest version if true */
5657
58
+ latestFlag = find_option("latest",0, 0)!=0;
5759
if( g.argc!=3 && g.argc!=2 ){
5860
usage("?VERSION?");
5961
}
6062
db_must_be_within_tree();
6163
vid = db_lget_int("checkout", 0);
6264
if( vid==0 ){
63
- vid = 1;
65
+ fossil_fatal("cannot find current version");
6466
}
6567
if( db_exists("SELECT 1 FROM vmerge") ){
6668
fossil_fatal("cannot update an uncommitted merge");
6769
}
6870
if( g.argc==3 ){
@@ -73,11 +75,11 @@
7375
if( !is_a_version(tid) ){
7476
fossil_fatal("not a version: %s", g.argv[2]);
7577
}
7678
}else{
7779
compute_leaves(vid);
78
- if( db_int(0, "SELECT count(*) FROM leaves")>1 ){
80
+ if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
7981
db_prepare(&q,
8082
"%s "
8183
" AND event.objid IN leaves"
8284
" ORDER BY event.mtime DESC",
8385
timeline_query_for_tty()
@@ -84,11 +86,13 @@
8486
);
8587
print_timeline(&q, 100);
8688
db_finalize(&q);
8789
fossil_fatal("Multiple descendents");
8890
}
89
- tid = db_int(0, "SELECT rid FROM leaves");
91
+ tid = db_int(0, "SELECT rid FROM leaves, event"
92
+ " WHERE event.objid=leaves.rid"
93
+ " ORDER BY event.mtime DESC");
9094
}
9195
9296
db_begin_transaction();
9397
vfile_check_signature(vid);
9498
undo_begin();
9599
--- src/update.c
+++ src/update.c
@@ -51,18 +51,20 @@
51 */
52 void update_cmd(void){
53 int vid; /* Current version */
54 int tid; /* Target version - version we are changing to */
55 Stmt q;
 
56
 
57 if( g.argc!=3 && g.argc!=2 ){
58 usage("?VERSION?");
59 }
60 db_must_be_within_tree();
61 vid = db_lget_int("checkout", 0);
62 if( vid==0 ){
63 vid = 1;
64 }
65 if( db_exists("SELECT 1 FROM vmerge") ){
66 fossil_fatal("cannot update an uncommitted merge");
67 }
68 if( g.argc==3 ){
@@ -73,11 +75,11 @@
73 if( !is_a_version(tid) ){
74 fossil_fatal("not a version: %s", g.argv[2]);
75 }
76 }else{
77 compute_leaves(vid);
78 if( db_int(0, "SELECT count(*) FROM leaves")>1 ){
79 db_prepare(&q,
80 "%s "
81 " AND event.objid IN leaves"
82 " ORDER BY event.mtime DESC",
83 timeline_query_for_tty()
@@ -84,11 +86,13 @@
84 );
85 print_timeline(&q, 100);
86 db_finalize(&q);
87 fossil_fatal("Multiple descendents");
88 }
89 tid = db_int(0, "SELECT rid FROM leaves");
 
 
90 }
91
92 db_begin_transaction();
93 vfile_check_signature(vid);
94 undo_begin();
95
--- src/update.c
+++ src/update.c
@@ -51,18 +51,20 @@
51 */
52 void update_cmd(void){
53 int vid; /* Current version */
54 int tid; /* Target version - version we are changing to */
55 Stmt q;
56 int latestFlag; /* Pick the latest version if true */
57
58 latestFlag = find_option("latest",0, 0)!=0;
59 if( g.argc!=3 && g.argc!=2 ){
60 usage("?VERSION?");
61 }
62 db_must_be_within_tree();
63 vid = db_lget_int("checkout", 0);
64 if( vid==0 ){
65 fossil_fatal("cannot find current version");
66 }
67 if( db_exists("SELECT 1 FROM vmerge") ){
68 fossil_fatal("cannot update an uncommitted merge");
69 }
70 if( g.argc==3 ){
@@ -73,11 +75,11 @@
75 if( !is_a_version(tid) ){
76 fossil_fatal("not a version: %s", g.argv[2]);
77 }
78 }else{
79 compute_leaves(vid);
80 if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
81 db_prepare(&q,
82 "%s "
83 " AND event.objid IN leaves"
84 " ORDER BY event.mtime DESC",
85 timeline_query_for_tty()
@@ -84,11 +86,13 @@
86 );
87 print_timeline(&q, 100);
88 db_finalize(&q);
89 fossil_fatal("Multiple descendents");
90 }
91 tid = db_int(0, "SELECT rid FROM leaves, event"
92 " WHERE event.objid=leaves.rid"
93 " ORDER BY event.mtime DESC");
94 }
95
96 db_begin_transaction();
97 vfile_check_signature(vid);
98 undo_begin();
99

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button