Overview
SHA1 Hash: | b773dda29bce549a7b66d1a89aea43ad8e87bfc2 |
---|---|
Date: | 2007-09-25 06:56:54 |
User: | jnc |
Comment: | 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). |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/sync.c from [fc0e1584ee] to [49100c83b1].
@@ -24,10 +24,26 @@ ** This file contains code used to push, pull, and sync a repository */ #include "config.h" #include "sync.h" #include <assert.h> + +/* +** Determine if an autosync should be done or not. The config setting, +** autosync must start with 1, y or Y. The last-sync-url must also be +** defined. +*/ +int do_autosync(void){ + const char *zAutoSync = db_global_get("autosync", 0); + if( zAutoSync != 0 + && (zAutoSync[0]=='1' || zAutoSync[0]=='y' || zAutoSync=='Y') + && db_get("last-sync-url", 0)!=0 ){ + return 1; + }else{ + return 0; + } +} /* ** This routine processes the command-line argument for push, pull, ** and sync. If a command-line argument is given, that is the URL ** of a server to sync against. If no argument is given, use the
Modified src/update.c from [7eb6f9c777] to [ee3b58703f].
@@ -49,11 +49,11 @@ ** not overwritten. Edits are merged into the new version. ** */ void update_cmd(void){ int vid; /* Current version */ - int tid; /* Target version - version we are changing to */ + int tid=0; /* 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 ){ @@ -65,19 +65,28 @@ fossil_fatal("cannot find current version"); } if( db_exists("SELECT 1 FROM vmerge") ){ fossil_fatal("cannot update an uncommitted merge"); } + if( g.argc==3 ){ tid = name_to_rid(g.argv[2]); if( tid==0 ){ fossil_fatal("not a version: %s", g.argv[2]); } if( !is_a_version(tid) ){ fossil_fatal("not a version: %s", g.argv[2]); } - }else{ + } + + if( do_autosync() ){ + g.argc=2; + g.argv[1]="pull"; + pull_cmd(); + } + + if( tid==0 ){ compute_leaves(vid); if( !latestFlag && db_int(0, "SELECT count(*) FROM leaves")>1 ){ db_prepare(&q, "%s " " AND event.objid IN leaves"