Fossil SCM

Autosync config parameter added (autosync). Setting this to 1, y or Y (or yes, Yes, yes, YES, etc...) will cause autosync's to happen during certian operations. Right now, the only operation paying attention to this is update. If autosync and you do fossil update, a pull takes place first, then an update. Others will follow (commit for one).

jnc 2007-09-25 06:56 trunk
Commit b773dda29bce549a7b66d1a89aea43ad8e87bfc2
2 files changed +16 +11 -2
+16
--- src/sync.c
+++ src/sync.c
@@ -24,10 +24,26 @@
2424
** This file contains code used to push, pull, and sync a repository
2525
*/
2626
#include "config.h"
2727
#include "sync.h"
2828
#include <assert.h>
29
+
30
+/*
31
+** Determine if an autosync should be done or not. The config setting,
32
+** autosync must start with 1, y or Y. The last-sync-url must also be
33
+** defined.
34
+*/
35
+int do_autosync(void){
36
+ const char *zAutoSync = db_global_get("autosync", 0);
37
+ if( zAutoSync != 0
38
+ && (zAutoSync[0]=='1' || zAutoSync[0]=='y' || zAutoSync=='Y')
39
+ && db_get("last-sync-url", 0)!=0 ){
40
+ return 1;
41
+ }else{
42
+ return 0;
43
+ }
44
+}
2945
3046
/*
3147
** This routine processes the command-line argument for push, pull,
3248
** and sync. If a command-line argument is given, that is the URL
3349
** of a server to sync against. If no argument is given, use the
3450
--- src/sync.c
+++ src/sync.c
@@ -24,10 +24,26 @@
24 ** This file contains code used to push, pull, and sync a repository
25 */
26 #include "config.h"
27 #include "sync.h"
28 #include <assert.h>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
30 /*
31 ** This routine processes the command-line argument for push, pull,
32 ** and sync. If a command-line argument is given, that is the URL
33 ** of a server to sync against. If no argument is given, use the
34
--- src/sync.c
+++ src/sync.c
@@ -24,10 +24,26 @@
24 ** This file contains code used to push, pull, and sync a repository
25 */
26 #include "config.h"
27 #include "sync.h"
28 #include <assert.h>
29
30 /*
31 ** Determine if an autosync should be done or not. The config setting,
32 ** autosync must start with 1, y or Y. The last-sync-url must also be
33 ** defined.
34 */
35 int do_autosync(void){
36 const char *zAutoSync = db_global_get("autosync", 0);
37 if( zAutoSync != 0
38 && (zAutoSync[0]=='1' || zAutoSync[0]=='y' || zAutoSync=='Y')
39 && db_get("last-sync-url", 0)!=0 ){
40 return 1;
41 }else{
42 return 0;
43 }
44 }
45
46 /*
47 ** This routine processes the command-line argument for push, pull,
48 ** and sync. If a command-line argument is given, that is the URL
49 ** of a server to sync against. If no argument is given, use the
50
+11 -2
--- src/update.c
+++ src/update.c
@@ -49,11 +49,11 @@
4949
** not overwritten. Edits are merged into the new version.
5050
**
5151
*/
5252
void update_cmd(void){
5353
int vid; /* Current version */
54
- int tid; /* Target version - version we are changing to */
54
+ int tid=0; /* Target version - version we are changing to */
5555
Stmt q;
5656
int latestFlag; /* Pick the latest version if true */
5757
5858
latestFlag = find_option("latest",0, 0)!=0;
5959
if( g.argc!=3 && g.argc!=2 ){
@@ -65,19 +65,28 @@
6565
fossil_fatal("cannot find current version");
6666
}
6767
if( db_exists("SELECT 1 FROM vmerge") ){
6868
fossil_fatal("cannot update an uncommitted merge");
6969
}
70
+
7071
if( g.argc==3 ){
7172
tid = name_to_rid(g.argv[2]);
7273
if( tid==0 ){
7374
fossil_fatal("not a version: %s", g.argv[2]);
7475
}
7576
if( !is_a_version(tid) ){
7677
fossil_fatal("not a version: %s", g.argv[2]);
7778
}
78
- }else{
79
+ }
80
+
81
+ if( do_autosync() ){
82
+ g.argc=2;
83
+ g.argv[1]="pull";
84
+ pull_cmd();
85
+ }
86
+
87
+ if( tid==0 ){
7988
compute_leaves(vid);
8089
if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
8190
db_prepare(&q,
8291
"%s "
8392
" AND event.objid IN leaves"
8493
--- src/update.c
+++ src/update.c
@@ -49,11 +49,11 @@
49 ** not overwritten. Edits are merged into the new version.
50 **
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 ){
@@ -65,19 +65,28 @@
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 ){
71 tid = name_to_rid(g.argv[2]);
72 if( tid==0 ){
73 fossil_fatal("not a version: %s", g.argv[2]);
74 }
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
--- src/update.c
+++ src/update.c
@@ -49,11 +49,11 @@
49 ** not overwritten. Edits are merged into the new version.
50 **
51 */
52 void update_cmd(void){
53 int vid; /* Current version */
54 int tid=0; /* 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 ){
@@ -65,19 +65,28 @@
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
71 if( g.argc==3 ){
72 tid = name_to_rid(g.argv[2]);
73 if( tid==0 ){
74 fossil_fatal("not a version: %s", g.argv[2]);
75 }
76 if( !is_a_version(tid) ){
77 fossil_fatal("not a version: %s", g.argv[2]);
78 }
79 }
80
81 if( do_autosync() ){
82 g.argc=2;
83 g.argv[1]="pull";
84 pull_cmd();
85 }
86
87 if( tid==0 ){
88 compute_leaves(vid);
89 if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){
90 db_prepare(&q,
91 "%s "
92 " AND event.objid IN leaves"
93

Keyboard Shortcuts

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