Fossil SCM
Do not acquire check-in locks if autosync is pullonly, as the lock will not be cancelled by a subsequent push and will need to time out.
Commit
0d5251d3eecdfc82cbbed5e6346a43883c11cf05b5a35b338c8f6eac6c1414fd
Parent
18d588015bd508c…
1 file changed
+19
-15
+19
-15
| --- src/sync.c | ||
| +++ src/sync.c | ||
| @@ -21,35 +21,39 @@ | ||
| 21 | 21 | #include "sync.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | 24 | /* |
| 25 | 25 | ** If the repository is configured for autosyncing, then do an |
| 26 | -** autosync. This will be a pull if the argument is true or a push | |
| 27 | -** if the argument is false. | |
| 26 | +** autosync. Bits of the "flags" parameter determine details of behavior: | |
| 27 | +** | |
| 28 | +** SYNC_PULL Pull content from the server to the local repo | |
| 29 | +** SYNC_PUSH Push content from local up to the server | |
| 30 | +** SYNC_CKIN_LOCK Take a check-in lock on the current checkout. | |
| 31 | +** SYNC_VERBOSE Extra output | |
| 28 | 32 | ** |
| 29 | 33 | ** Return the number of errors. |
| 34 | +** | |
| 35 | +** The autosync setting can be a boolean or "pullonly". No autosync | |
| 36 | +** is attempted if the autosync setting is off, and only auto-pull is | |
| 37 | +** attempted if autosync is set to "pullonly". The check-in lock is | |
| 38 | +** not acquired unless autosync is set to "on". | |
| 39 | +** | |
| 40 | +** If dont-push setting is true, that is the same as having autosync | |
| 41 | +** set to pullonly. | |
| 30 | 42 | */ |
| 31 | 43 | int autosync(int flags){ |
| 32 | 44 | const char *zAutosync; |
| 33 | 45 | int rc; |
| 34 | 46 | int configSync = 0; /* configuration changes transferred */ |
| 35 | 47 | if( g.fNoSync ){ |
| 36 | 48 | return 0; |
| 37 | 49 | } |
| 38 | - if( flags==SYNC_PUSH && db_get_boolean("dont-push",0) ){ | |
| 39 | - return 0; | |
| 40 | - } | |
| 41 | - zAutosync = db_get("autosync", 0); | |
| 42 | - if( zAutosync ){ | |
| 43 | - if( (flags & SYNC_PUSH)!=0 && fossil_strncmp(zAutosync,"pull",4)==0 ){ | |
| 44 | - return 0; /* Do not auto-push when autosync=pullonly */ | |
| 45 | - } | |
| 46 | - if( is_false(zAutosync) ){ | |
| 47 | - return 0; /* Autosync is completely off */ | |
| 48 | - } | |
| 49 | - }else{ | |
| 50 | - /* Autosync defaults on. To make it default off, "return" here. */ | |
| 50 | + zAutosync = db_get("autosync", "on"); | |
| 51 | + if( is_false(zAutosync) ) return 0; | |
| 52 | + if( db_get_boolean("dont-push",0) || fossil_strncmp(zAutosync,"pull",4)==0 ){ | |
| 53 | + flags &= ~SYNC_CKIN_LOCK; | |
| 54 | + if( flags & SYNC_PUSH ) return 0; | |
| 51 | 55 | } |
| 52 | 56 | url_parse(0, URL_REMEMBER); |
| 53 | 57 | if( g.url.protocol==0 ) return 0; |
| 54 | 58 | if( g.url.user!=0 && g.url.passwd==0 ){ |
| 55 | 59 | g.url.passwd = unobscure(db_get("last-sync-pw", 0)); |
| 56 | 60 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -21,35 +21,39 @@ | |
| 21 | #include "sync.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | /* |
| 25 | ** If the repository is configured for autosyncing, then do an |
| 26 | ** autosync. This will be a pull if the argument is true or a push |
| 27 | ** if the argument is false. |
| 28 | ** |
| 29 | ** Return the number of errors. |
| 30 | */ |
| 31 | int autosync(int flags){ |
| 32 | const char *zAutosync; |
| 33 | int rc; |
| 34 | int configSync = 0; /* configuration changes transferred */ |
| 35 | if( g.fNoSync ){ |
| 36 | return 0; |
| 37 | } |
| 38 | if( flags==SYNC_PUSH && db_get_boolean("dont-push",0) ){ |
| 39 | return 0; |
| 40 | } |
| 41 | zAutosync = db_get("autosync", 0); |
| 42 | if( zAutosync ){ |
| 43 | if( (flags & SYNC_PUSH)!=0 && fossil_strncmp(zAutosync,"pull",4)==0 ){ |
| 44 | return 0; /* Do not auto-push when autosync=pullonly */ |
| 45 | } |
| 46 | if( is_false(zAutosync) ){ |
| 47 | return 0; /* Autosync is completely off */ |
| 48 | } |
| 49 | }else{ |
| 50 | /* Autosync defaults on. To make it default off, "return" here. */ |
| 51 | } |
| 52 | url_parse(0, URL_REMEMBER); |
| 53 | if( g.url.protocol==0 ) return 0; |
| 54 | if( g.url.user!=0 && g.url.passwd==0 ){ |
| 55 | g.url.passwd = unobscure(db_get("last-sync-pw", 0)); |
| 56 |
| --- src/sync.c | |
| +++ src/sync.c | |
| @@ -21,35 +21,39 @@ | |
| 21 | #include "sync.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | /* |
| 25 | ** If the repository is configured for autosyncing, then do an |
| 26 | ** autosync. Bits of the "flags" parameter determine details of behavior: |
| 27 | ** |
| 28 | ** SYNC_PULL Pull content from the server to the local repo |
| 29 | ** SYNC_PUSH Push content from local up to the server |
| 30 | ** SYNC_CKIN_LOCK Take a check-in lock on the current checkout. |
| 31 | ** SYNC_VERBOSE Extra output |
| 32 | ** |
| 33 | ** Return the number of errors. |
| 34 | ** |
| 35 | ** The autosync setting can be a boolean or "pullonly". No autosync |
| 36 | ** is attempted if the autosync setting is off, and only auto-pull is |
| 37 | ** attempted if autosync is set to "pullonly". The check-in lock is |
| 38 | ** not acquired unless autosync is set to "on". |
| 39 | ** |
| 40 | ** If dont-push setting is true, that is the same as having autosync |
| 41 | ** set to pullonly. |
| 42 | */ |
| 43 | int autosync(int flags){ |
| 44 | const char *zAutosync; |
| 45 | int rc; |
| 46 | int configSync = 0; /* configuration changes transferred */ |
| 47 | if( g.fNoSync ){ |
| 48 | return 0; |
| 49 | } |
| 50 | zAutosync = db_get("autosync", "on"); |
| 51 | if( is_false(zAutosync) ) return 0; |
| 52 | if( db_get_boolean("dont-push",0) || fossil_strncmp(zAutosync,"pull",4)==0 ){ |
| 53 | flags &= ~SYNC_CKIN_LOCK; |
| 54 | if( flags & SYNC_PUSH ) return 0; |
| 55 | } |
| 56 | url_parse(0, URL_REMEMBER); |
| 57 | if( g.url.protocol==0 ) return 0; |
| 58 | if( g.url.user!=0 && g.url.passwd==0 ){ |
| 59 | g.url.passwd = unobscure(db_get("last-sync-pw", 0)); |
| 60 |