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).
Commit
b773dda29bce549a7b66d1a89aea43ad8e87bfc2
Parent
913608a5a6848d5…
2 files changed
+16
+11
-2
+16
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -24,10 +24,26 @@ | ||
| 24 | 24 | ** This file contains code used to push, pull, and sync a repository |
| 25 | 25 | */ |
| 26 | 26 | #include "config.h" |
| 27 | 27 | #include "sync.h" |
| 28 | 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 | +} | |
| 29 | 45 | |
| 30 | 46 | /* |
| 31 | 47 | ** This routine processes the command-line argument for push, pull, |
| 32 | 48 | ** and sync. If a command-line argument is given, that is the URL |
| 33 | 49 | ** of a server to sync against. If no argument is given, use the |
| 34 | 50 |
| --- 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 @@ | ||
| 49 | 49 | ** not overwritten. Edits are merged into the new version. |
| 50 | 50 | ** |
| 51 | 51 | */ |
| 52 | 52 | void update_cmd(void){ |
| 53 | 53 | 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 */ | |
| 55 | 55 | Stmt q; |
| 56 | 56 | int latestFlag; /* Pick the latest version if true */ |
| 57 | 57 | |
| 58 | 58 | latestFlag = find_option("latest",0, 0)!=0; |
| 59 | 59 | if( g.argc!=3 && g.argc!=2 ){ |
| @@ -65,19 +65,28 @@ | ||
| 65 | 65 | fossil_fatal("cannot find current version"); |
| 66 | 66 | } |
| 67 | 67 | if( db_exists("SELECT 1 FROM vmerge") ){ |
| 68 | 68 | fossil_fatal("cannot update an uncommitted merge"); |
| 69 | 69 | } |
| 70 | + | |
| 70 | 71 | if( g.argc==3 ){ |
| 71 | 72 | tid = name_to_rid(g.argv[2]); |
| 72 | 73 | if( tid==0 ){ |
| 73 | 74 | fossil_fatal("not a version: %s", g.argv[2]); |
| 74 | 75 | } |
| 75 | 76 | if( !is_a_version(tid) ){ |
| 76 | 77 | fossil_fatal("not a version: %s", g.argv[2]); |
| 77 | 78 | } |
| 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 ){ | |
| 79 | 88 | compute_leaves(vid); |
| 80 | 89 | if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){ |
| 81 | 90 | db_prepare(&q, |
| 82 | 91 | "%s " |
| 83 | 92 | " AND event.objid IN leaves" |
| 84 | 93 |
| --- 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 |