Fossil SCM

Add the uv-sync setting, which if enabled causes the server to automatically send all unversioned content as part of a clone, and which causes all syncs to also sync unversioned content.

drh 2016-09-20 16:17 trunk
Commit b9fd5947effbda64cbd50470ccf12c8b1c6aa6a8
+6
--- src/db.c
+++ src/db.c
@@ -2597,10 +2597,11 @@
25972597
#ifdef FOSSIL_ENABLE_TH1_HOOKS
25982598
{ "th1-hooks", 0, 0, 0, 0, "off" },
25992599
#endif
26002600
{ "th1-setup", 0, 40, 1, 1, "" },
26012601
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
2602
+ { "uv-sync", 0, 0, 0, 0, "off" },
26022603
{ "web-browser", 0, 32, 0, 0, "" },
26032604
{ 0,0,0,0,0,0 }
26042605
};
26052606
26062607
/*
@@ -2871,10 +2872,15 @@
28712872
** is empty and no extra setup is performed.
28722873
**
28732874
** th1-uri-regexp Specify which URI's are allowed in HTTP requests from
28742875
** (versionable) TH1 scripts. If empty, no HTTP requests are allowed
28752876
** whatsoever. The default is an empty string.
2877
+**
2878
+** uv-sync If true, automatically send unversioned files as part
2879
+** of a "fossil clone" or "fossil sync" command. The
2880
+** default is false, in which case the -u option is
2881
+** needed to clone or sync unversioned files.
28762882
**
28772883
** web-browser A shell command used to launch your preferred
28782884
** web browser when given a URL as an argument.
28792885
** Defaults to "start" on windows, "open" on Mac,
28802886
** and "firefox" on Unix.
28812887
--- src/db.c
+++ src/db.c
@@ -2597,10 +2597,11 @@
2597 #ifdef FOSSIL_ENABLE_TH1_HOOKS
2598 { "th1-hooks", 0, 0, 0, 0, "off" },
2599 #endif
2600 { "th1-setup", 0, 40, 1, 1, "" },
2601 { "th1-uri-regexp", 0, 40, 1, 0, "" },
 
2602 { "web-browser", 0, 32, 0, 0, "" },
2603 { 0,0,0,0,0,0 }
2604 };
2605
2606 /*
@@ -2871,10 +2872,15 @@
2871 ** is empty and no extra setup is performed.
2872 **
2873 ** th1-uri-regexp Specify which URI's are allowed in HTTP requests from
2874 ** (versionable) TH1 scripts. If empty, no HTTP requests are allowed
2875 ** whatsoever. The default is an empty string.
 
 
 
 
 
2876 **
2877 ** web-browser A shell command used to launch your preferred
2878 ** web browser when given a URL as an argument.
2879 ** Defaults to "start" on windows, "open" on Mac,
2880 ** and "firefox" on Unix.
2881
--- src/db.c
+++ src/db.c
@@ -2597,10 +2597,11 @@
2597 #ifdef FOSSIL_ENABLE_TH1_HOOKS
2598 { "th1-hooks", 0, 0, 0, 0, "off" },
2599 #endif
2600 { "th1-setup", 0, 40, 1, 1, "" },
2601 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2602 { "uv-sync", 0, 0, 0, 0, "off" },
2603 { "web-browser", 0, 32, 0, 0, "" },
2604 { 0,0,0,0,0,0 }
2605 };
2606
2607 /*
@@ -2871,10 +2872,15 @@
2872 ** is empty and no extra setup is performed.
2873 **
2874 ** th1-uri-regexp Specify which URI's are allowed in HTTP requests from
2875 ** (versionable) TH1 scripts. If empty, no HTTP requests are allowed
2876 ** whatsoever. The default is an empty string.
2877 **
2878 ** uv-sync If true, automatically send unversioned files as part
2879 ** of a "fossil clone" or "fossil sync" command. The
2880 ** default is false, in which case the -u option is
2881 ** needed to clone or sync unversioned files.
2882 **
2883 ** web-browser A shell command used to launch your preferred
2884 ** web browser when given a URL as an argument.
2885 ** Defaults to "start" on windows, "open" on Mac,
2886 ** and "firefox" on Unix.
2887
+1 -1
--- src/setup.c
+++ src/setup.c
@@ -1538,11 +1538,11 @@
15381538
@ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>
15391539
@ in the check-out root.
15401540
@ If such a file is present, the corresponding field above is not
15411541
@ editable.</p><hr /><p>
15421542
@ These settings work the same as the
1543
- @ <a href='%R/help?cmd=set'>fossil set</a> command.
1543
+ @ <a href='%R/help?cmd=settings'>fossil set</a> command.
15441544
db_end_transaction(0);
15451545
style_footer();
15461546
}
15471547
15481548
/*
15491549
--- src/setup.c
+++ src/setup.c
@@ -1538,11 +1538,11 @@
1538 @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>
1539 @ in the check-out root.
1540 @ If such a file is present, the corresponding field above is not
1541 @ editable.</p><hr /><p>
1542 @ These settings work the same as the
1543 @ <a href='%R/help?cmd=set'>fossil set</a> command.
1544 db_end_transaction(0);
1545 style_footer();
1546 }
1547
1548 /*
1549
--- src/setup.c
+++ src/setup.c
@@ -1538,11 +1538,11 @@
1538 @ by the contents of files named <tt>.fossil-settings/PROPERTY</tt>
1539 @ in the check-out root.
1540 @ If such a file is present, the corresponding field above is not
1541 @ editable.</p><hr /><p>
1542 @ These settings work the same as the
1543 @ <a href='%R/help?cmd=settings'>fossil set</a> command.
1544 db_end_transaction(0);
1545 style_footer();
1546 }
1547
1548 /*
1549
+10
--- src/sync.c
+++ src/sync.c
@@ -86,10 +86,15 @@
8686
** if they answer "yes" then return zero in spite of the failure.
8787
*/
8888
int autosync_loop(int flags, int nTries, int doPrompt){
8989
int n = 0;
9090
int rc = 0;
91
+ if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
92
+ && db_get_boolean("uv-sync",0)
93
+ ){
94
+ flags |= SYNC_UNVERSIONED;
95
+ }
9196
while( (n==0 || n<nTries) && (rc=autosync(flags)) ){
9297
if( rc ){
9398
if( ++n<nTries ){
9499
fossil_warning("Autosync failed, making another attempt.");
95100
sqlite3_sleep(500);
@@ -123,10 +128,15 @@
123128
const char *zUrl = 0;
124129
const char *zHttpAuth = 0;
125130
unsigned configSync = 0;
126131
unsigned urlFlags = URL_REMEMBER | URL_PROMPT_PW;
127132
int urlOptional = 0;
133
+ if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
134
+ && db_get_boolean("uv-sync",0)
135
+ ){
136
+ *pSyncFlags |= SYNC_UNVERSIONED;
137
+ }
128138
if( find_option("autourl",0,0)!=0 ){
129139
urlOptional = 1;
130140
urlFlags = 0;
131141
}
132142
zHttpAuth = find_option("httpauth","B",1);
133143
--- src/sync.c
+++ src/sync.c
@@ -86,10 +86,15 @@
86 ** if they answer "yes" then return zero in spite of the failure.
87 */
88 int autosync_loop(int flags, int nTries, int doPrompt){
89 int n = 0;
90 int rc = 0;
 
 
 
 
 
91 while( (n==0 || n<nTries) && (rc=autosync(flags)) ){
92 if( rc ){
93 if( ++n<nTries ){
94 fossil_warning("Autosync failed, making another attempt.");
95 sqlite3_sleep(500);
@@ -123,10 +128,15 @@
123 const char *zUrl = 0;
124 const char *zHttpAuth = 0;
125 unsigned configSync = 0;
126 unsigned urlFlags = URL_REMEMBER | URL_PROMPT_PW;
127 int urlOptional = 0;
 
 
 
 
 
128 if( find_option("autourl",0,0)!=0 ){
129 urlOptional = 1;
130 urlFlags = 0;
131 }
132 zHttpAuth = find_option("httpauth","B",1);
133
--- src/sync.c
+++ src/sync.c
@@ -86,10 +86,15 @@
86 ** if they answer "yes" then return zero in spite of the failure.
87 */
88 int autosync_loop(int flags, int nTries, int doPrompt){
89 int n = 0;
90 int rc = 0;
91 if( (flags & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
92 && db_get_boolean("uv-sync",0)
93 ){
94 flags |= SYNC_UNVERSIONED;
95 }
96 while( (n==0 || n<nTries) && (rc=autosync(flags)) ){
97 if( rc ){
98 if( ++n<nTries ){
99 fossil_warning("Autosync failed, making another attempt.");
100 sqlite3_sleep(500);
@@ -123,10 +128,15 @@
128 const char *zUrl = 0;
129 const char *zHttpAuth = 0;
130 unsigned configSync = 0;
131 unsigned urlFlags = URL_REMEMBER | URL_PROMPT_PW;
132 int urlOptional = 0;
133 if( ((*pSyncFlags) & (SYNC_PUSH|SYNC_PULL))==(SYNC_PUSH|SYNC_PULL)
134 && db_get_boolean("uv-sync",0)
135 ){
136 *pSyncFlags |= SYNC_UNVERSIONED;
137 }
138 if( find_option("autourl",0,0)!=0 ){
139 urlOptional = 1;
140 urlFlags = 0;
141 }
142 zHttpAuth = find_option("httpauth","B",1);
143
+16 -7
--- src/xfer.c
+++ src/xfer.c
@@ -1152,10 +1152,11 @@
11521152
const char *zScript = 0;
11531153
char *zUuidList = 0;
11541154
int nUuidList = 0;
11551155
char **pzUuidList = 0;
11561156
int *pnUuidList = 0;
1157
+ int uvCatalogSent = 0;
11571158
11581159
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
11591160
fossil_redirect_home();
11601161
}
11611162
g.zLogin = "anonymous";
@@ -1362,10 +1363,15 @@
13621363
@ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x"))
13631364
@ error not\sauthorized\sto\sclone
13641365
nErr++;
13651366
break;
13661367
}
1368
+ if( db_get_boolean("uv-sync",0) && !uvCatalogSent ){
1369
+ @ pragma uv-pull-only
1370
+ send_unversioned_catalog(&xfer);
1371
+ uvCatalogSent = 1;
1372
+ }
13671373
if( xfer.nToken==3
13681374
&& blob_is_int(&xfer.aToken[1], &iVers)
13691375
&& iVers>=2
13701376
){
13711377
int seqno, max;
@@ -1538,17 +1544,20 @@
15381544
** "uvigot" cards.
15391545
*/
15401546
if( blob_eq(&xfer.aToken[1], "uv-hash")
15411547
&& blob_is_uuid(&xfer.aToken[2])
15421548
){
1543
- if( g.perm.Read && g.perm.WrUnver ){
1544
- @ pragma uv-push-ok
1545
- send_unversioned_catalog(&xfer);
1546
- }else if( g.perm.Read ){
1547
- @ pragma uv-pull-only
1548
- send_unversioned_catalog(&xfer);
1549
+ if( !uvCatalogSent ){
1550
+ if( g.perm.Read && g.perm.WrUnver ){
1551
+ @ pragma uv-push-ok
1552
+ send_unversioned_catalog(&xfer);
1553
+ }else if( g.perm.Read ){
1554
+ @ pragma uv-pull-only
1555
+ send_unversioned_catalog(&xfer);
1556
+ }
15491557
}
1558
+ uvCatalogSent = 1;
15501559
}
15511560
}else
15521561
15531562
/* Unknown message
15541563
*/
@@ -1759,11 +1768,11 @@
17591768
** The initial assumption is that all unversioned files need to be sent
17601769
** to the other side. But "uvigot" cards received back from the remote
17611770
** side will normally cause many of these entries to be removed since they
17621771
** do not really need to be sent.
17631772
*/
1764
- if( (syncFlags & SYNC_UNVERSIONED)!=0 ){
1773
+ if( (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0 ){
17651774
unversioned_schema();
17661775
db_multi_exec(
17671776
"CREATE TEMP TABLE uv_tosend("
17681777
" name TEXT PRIMARY KEY," /* Name of file to send client->server */
17691778
" mtimeOnly BOOLEAN" /* True to only send mtime, not content */
17701779
--- src/xfer.c
+++ src/xfer.c
@@ -1152,10 +1152,11 @@
1152 const char *zScript = 0;
1153 char *zUuidList = 0;
1154 int nUuidList = 0;
1155 char **pzUuidList = 0;
1156 int *pnUuidList = 0;
 
1157
1158 if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
1159 fossil_redirect_home();
1160 }
1161 g.zLogin = "anonymous";
@@ -1362,10 +1363,15 @@
1362 @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x"))
1363 @ error not\sauthorized\sto\sclone
1364 nErr++;
1365 break;
1366 }
 
 
 
 
 
1367 if( xfer.nToken==3
1368 && blob_is_int(&xfer.aToken[1], &iVers)
1369 && iVers>=2
1370 ){
1371 int seqno, max;
@@ -1538,17 +1544,20 @@
1538 ** "uvigot" cards.
1539 */
1540 if( blob_eq(&xfer.aToken[1], "uv-hash")
1541 && blob_is_uuid(&xfer.aToken[2])
1542 ){
1543 if( g.perm.Read && g.perm.WrUnver ){
1544 @ pragma uv-push-ok
1545 send_unversioned_catalog(&xfer);
1546 }else if( g.perm.Read ){
1547 @ pragma uv-pull-only
1548 send_unversioned_catalog(&xfer);
 
 
1549 }
 
1550 }
1551 }else
1552
1553 /* Unknown message
1554 */
@@ -1759,11 +1768,11 @@
1759 ** The initial assumption is that all unversioned files need to be sent
1760 ** to the other side. But "uvigot" cards received back from the remote
1761 ** side will normally cause many of these entries to be removed since they
1762 ** do not really need to be sent.
1763 */
1764 if( (syncFlags & SYNC_UNVERSIONED)!=0 ){
1765 unversioned_schema();
1766 db_multi_exec(
1767 "CREATE TEMP TABLE uv_tosend("
1768 " name TEXT PRIMARY KEY," /* Name of file to send client->server */
1769 " mtimeOnly BOOLEAN" /* True to only send mtime, not content */
1770
--- src/xfer.c
+++ src/xfer.c
@@ -1152,10 +1152,11 @@
1152 const char *zScript = 0;
1153 char *zUuidList = 0;
1154 int nUuidList = 0;
1155 char **pzUuidList = 0;
1156 int *pnUuidList = 0;
1157 int uvCatalogSent = 0;
1158
1159 if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
1160 fossil_redirect_home();
1161 }
1162 g.zLogin = "anonymous";
@@ -1362,10 +1363,15 @@
1363 @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x"))
1364 @ error not\sauthorized\sto\sclone
1365 nErr++;
1366 break;
1367 }
1368 if( db_get_boolean("uv-sync",0) && !uvCatalogSent ){
1369 @ pragma uv-pull-only
1370 send_unversioned_catalog(&xfer);
1371 uvCatalogSent = 1;
1372 }
1373 if( xfer.nToken==3
1374 && blob_is_int(&xfer.aToken[1], &iVers)
1375 && iVers>=2
1376 ){
1377 int seqno, max;
@@ -1538,17 +1544,20 @@
1544 ** "uvigot" cards.
1545 */
1546 if( blob_eq(&xfer.aToken[1], "uv-hash")
1547 && blob_is_uuid(&xfer.aToken[2])
1548 ){
1549 if( !uvCatalogSent ){
1550 if( g.perm.Read && g.perm.WrUnver ){
1551 @ pragma uv-push-ok
1552 send_unversioned_catalog(&xfer);
1553 }else if( g.perm.Read ){
1554 @ pragma uv-pull-only
1555 send_unversioned_catalog(&xfer);
1556 }
1557 }
1558 uvCatalogSent = 1;
1559 }
1560 }else
1561
1562 /* Unknown message
1563 */
@@ -1759,11 +1768,11 @@
1768 ** The initial assumption is that all unversioned files need to be sent
1769 ** to the other side. But "uvigot" cards received back from the remote
1770 ** side will normally cause many of these entries to be removed since they
1771 ** do not really need to be sent.
1772 */
1773 if( (syncFlags & (SYNC_UNVERSIONED|SYNC_CLONE))!=0 ){
1774 unversioned_schema();
1775 db_multi_exec(
1776 "CREATE TEMP TABLE uv_tosend("
1777 " name TEXT PRIMARY KEY," /* Name of file to send client->server */
1778 " mtimeOnly BOOLEAN" /* True to only send mtime, not content */
1779

Keyboard Shortcuts

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