Fossil SCM

Add the --project-code option to the "fossil pull" command. Use of this option allows one project to pull content from another project.

drh 2020-02-06 23:26 trunk
Commit 21e8aed945d875f26d6a74740d54d64e95cd141f51d355c2b5e6425305ddcf08
+1 -1
--- src/clone.c
+++ src/clone.c
@@ -204,11 +204,11 @@
204204
);
205205
url_enable_proxy(0);
206206
clone_ssh_db_set_options();
207207
url_get_password_if_needed();
208208
g.xlinkClusterOnly = 1;
209
- nErr = client_sync(syncFlags,CONFIGSET_ALL,0);
209
+ nErr = client_sync(syncFlags,CONFIGSET_ALL,0,0);
210210
g.xlinkClusterOnly = 0;
211211
verify_cancel();
212212
db_end_transaction(0);
213213
db_close(1);
214214
if( nErr ){
215215
--- src/clone.c
+++ src/clone.c
@@ -204,11 +204,11 @@
204 );
205 url_enable_proxy(0);
206 clone_ssh_db_set_options();
207 url_get_password_if_needed();
208 g.xlinkClusterOnly = 1;
209 nErr = client_sync(syncFlags,CONFIGSET_ALL,0);
210 g.xlinkClusterOnly = 0;
211 verify_cancel();
212 db_end_transaction(0);
213 db_close(1);
214 if( nErr ){
215
--- src/clone.c
+++ src/clone.c
@@ -204,11 +204,11 @@
204 );
205 url_enable_proxy(0);
206 clone_ssh_db_set_options();
207 url_get_password_if_needed();
208 g.xlinkClusterOnly = 1;
209 nErr = client_sync(syncFlags,CONFIGSET_ALL,0,0);
210 g.xlinkClusterOnly = 0;
211 verify_cancel();
212 db_end_transaction(0);
213 db_close(1);
214 if( nErr ){
215
+3 -3
--- src/configure.c
+++ src/configure.c
@@ -814,15 +814,15 @@
814814
if( g.url.protocol==0 ) fossil_fatal("no server URL specified");
815815
user_select();
816816
url_enable_proxy("via proxy: ");
817817
if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
818818
if( strncmp(zMethod, "push", n)==0 ){
819
- client_sync(0,0,(unsigned)mask);
819
+ client_sync(0,0,(unsigned)mask,0);
820820
}else if( strncmp(zMethod, "pull", n)==0 ){
821
- client_sync(0,(unsigned)mask,0);
821
+ client_sync(0,(unsigned)mask,0,0);
822822
}else{
823
- client_sync(0,(unsigned)mask,(unsigned)mask);
823
+ client_sync(0,(unsigned)mask,(unsigned)mask,0);
824824
}
825825
}else
826826
if( strncmp(zMethod, "reset", n)==0 ){
827827
int mask, i;
828828
char *zBackup;
829829
--- src/configure.c
+++ src/configure.c
@@ -814,15 +814,15 @@
814 if( g.url.protocol==0 ) fossil_fatal("no server URL specified");
815 user_select();
816 url_enable_proxy("via proxy: ");
817 if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
818 if( strncmp(zMethod, "push", n)==0 ){
819 client_sync(0,0,(unsigned)mask);
820 }else if( strncmp(zMethod, "pull", n)==0 ){
821 client_sync(0,(unsigned)mask,0);
822 }else{
823 client_sync(0,(unsigned)mask,(unsigned)mask);
824 }
825 }else
826 if( strncmp(zMethod, "reset", n)==0 ){
827 int mask, i;
828 char *zBackup;
829
--- src/configure.c
+++ src/configure.c
@@ -814,15 +814,15 @@
814 if( g.url.protocol==0 ) fossil_fatal("no server URL specified");
815 user_select();
816 url_enable_proxy("via proxy: ");
817 if( overwriteFlag ) mask |= CONFIGSET_OVERWRITE;
818 if( strncmp(zMethod, "push", n)==0 ){
819 client_sync(0,0,(unsigned)mask,0);
820 }else if( strncmp(zMethod, "pull", n)==0 ){
821 client_sync(0,(unsigned)mask,0,0);
822 }else{
823 client_sync(0,(unsigned)mask,(unsigned)mask,0);
824 }
825 }else
826 if( strncmp(zMethod, "reset", n)==0 ){
827 int mask, i;
828 char *zBackup;
829
+8 -6
--- src/sync.c
+++ src/sync.c
@@ -76,11 +76,11 @@
7676
}
7777
#endif
7878
if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
7979
fossil_print("Autosync: %s\n", g.url.canonical);
8080
url_enable_proxy("via proxy: ");
81
- rc = client_sync(flags, configSync, 0);
81
+ rc = client_sync(flags, configSync, 0, 0);
8282
return rc;
8383
}
8484
8585
/*
8686
** This routine will try a number of times to perform autosync with a
@@ -217,12 +217,13 @@
217217
** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
218218
** if required by the remote website
219219
** --from-parent-project Pull content from the parent project
220220
** --ipv4 Use only IPv4, not IPv6
221221
** --once Do not remember URL for subsequent syncs
222
-** --proxy PROXY Use the specified HTTP proxy
223222
** --private Pull private branches too
223
+** --project-code CODE Use CODE as the project code
224
+** --proxy PROXY Use the specified HTTP proxy
224225
** -R|--repository REPO Local repository to pull into
225226
** --ssl-identity FILE Local SSL credentials, if requested by remote
226227
** --ssh-command SSH Use SSH as the "ssh" command
227228
** -v|--verbose Additional (debugging) output
228229
** --verily Exchange extra information with the remote
@@ -231,19 +232,20 @@
231232
** See also: clone, config pull, push, remote-url, sync
232233
*/
233234
void pull_cmd(void){
234235
unsigned configFlags = 0;
235236
unsigned syncFlags = SYNC_PULL;
237
+ const char *zAltPCode = find_option("project-code",0,1);
236238
if( find_option("from-parent-project",0,0)!=0 ){
237239
syncFlags |= SYNC_FROMPARENT;
238240
}
239241
process_sync_args(&configFlags, &syncFlags, 0);
240242
241243
/* We should be done with options.. */
242244
verify_all_options();
243245
244
- client_sync(syncFlags, configFlags, 0);
246
+ client_sync(syncFlags, configFlags, 0, zAltPCode);
245247
}
246248
247249
/*
248250
** COMMAND: push
249251
**
@@ -285,11 +287,11 @@
285287
verify_all_options();
286288
287289
if( db_get_boolean("dont-push",0) ){
288290
fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
289291
}
290
- client_sync(syncFlags, 0, 0);
292
+ client_sync(syncFlags, 0, 0, 0);
291293
}
292294
293295
294296
/*
295297
** COMMAND: sync
@@ -332,11 +334,11 @@
332334
333335
/* We should be done with options.. */
334336
verify_all_options();
335337
336338
if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
337
- client_sync(syncFlags, configFlags, 0);
339
+ client_sync(syncFlags, configFlags, 0, 0);
338340
if( (syncFlags & SYNC_PUSH)==0 ){
339341
fossil_warning("pull only: the 'dont-push' option is set");
340342
}
341343
}
342344
@@ -347,11 +349,11 @@
347349
void sync_unversioned(unsigned syncFlags){
348350
unsigned configFlags = 0;
349351
(void)find_option("uv-noop",0,0);
350352
process_sync_args(&configFlags, &syncFlags, 1);
351353
verify_all_options();
352
- client_sync(syncFlags, 0, 0);
354
+ client_sync(syncFlags, 0, 0, 0);
353355
}
354356
355357
/*
356358
** COMMAND: remote-url
357359
**
358360
--- src/sync.c
+++ src/sync.c
@@ -76,11 +76,11 @@
76 }
77 #endif
78 if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
79 fossil_print("Autosync: %s\n", g.url.canonical);
80 url_enable_proxy("via proxy: ");
81 rc = client_sync(flags, configSync, 0);
82 return rc;
83 }
84
85 /*
86 ** This routine will try a number of times to perform autosync with a
@@ -217,12 +217,13 @@
217 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
218 ** if required by the remote website
219 ** --from-parent-project Pull content from the parent project
220 ** --ipv4 Use only IPv4, not IPv6
221 ** --once Do not remember URL for subsequent syncs
222 ** --proxy PROXY Use the specified HTTP proxy
223 ** --private Pull private branches too
 
 
224 ** -R|--repository REPO Local repository to pull into
225 ** --ssl-identity FILE Local SSL credentials, if requested by remote
226 ** --ssh-command SSH Use SSH as the "ssh" command
227 ** -v|--verbose Additional (debugging) output
228 ** --verily Exchange extra information with the remote
@@ -231,19 +232,20 @@
231 ** See also: clone, config pull, push, remote-url, sync
232 */
233 void pull_cmd(void){
234 unsigned configFlags = 0;
235 unsigned syncFlags = SYNC_PULL;
 
236 if( find_option("from-parent-project",0,0)!=0 ){
237 syncFlags |= SYNC_FROMPARENT;
238 }
239 process_sync_args(&configFlags, &syncFlags, 0);
240
241 /* We should be done with options.. */
242 verify_all_options();
243
244 client_sync(syncFlags, configFlags, 0);
245 }
246
247 /*
248 ** COMMAND: push
249 **
@@ -285,11 +287,11 @@
285 verify_all_options();
286
287 if( db_get_boolean("dont-push",0) ){
288 fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
289 }
290 client_sync(syncFlags, 0, 0);
291 }
292
293
294 /*
295 ** COMMAND: sync
@@ -332,11 +334,11 @@
332
333 /* We should be done with options.. */
334 verify_all_options();
335
336 if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
337 client_sync(syncFlags, configFlags, 0);
338 if( (syncFlags & SYNC_PUSH)==0 ){
339 fossil_warning("pull only: the 'dont-push' option is set");
340 }
341 }
342
@@ -347,11 +349,11 @@
347 void sync_unversioned(unsigned syncFlags){
348 unsigned configFlags = 0;
349 (void)find_option("uv-noop",0,0);
350 process_sync_args(&configFlags, &syncFlags, 1);
351 verify_all_options();
352 client_sync(syncFlags, 0, 0);
353 }
354
355 /*
356 ** COMMAND: remote-url
357 **
358
--- src/sync.c
+++ src/sync.c
@@ -76,11 +76,11 @@
76 }
77 #endif
78 if( find_option("verbose","v",0)!=0 ) flags |= SYNC_VERBOSE;
79 fossil_print("Autosync: %s\n", g.url.canonical);
80 url_enable_proxy("via proxy: ");
81 rc = client_sync(flags, configSync, 0, 0);
82 return rc;
83 }
84
85 /*
86 ** This routine will try a number of times to perform autosync with a
@@ -217,12 +217,13 @@
217 ** -B|--httpauth USER:PASS Credentials for the simple HTTP auth protocol,
218 ** if required by the remote website
219 ** --from-parent-project Pull content from the parent project
220 ** --ipv4 Use only IPv4, not IPv6
221 ** --once Do not remember URL for subsequent syncs
 
222 ** --private Pull private branches too
223 ** --project-code CODE Use CODE as the project code
224 ** --proxy PROXY Use the specified HTTP proxy
225 ** -R|--repository REPO Local repository to pull into
226 ** --ssl-identity FILE Local SSL credentials, if requested by remote
227 ** --ssh-command SSH Use SSH as the "ssh" command
228 ** -v|--verbose Additional (debugging) output
229 ** --verily Exchange extra information with the remote
@@ -231,19 +232,20 @@
232 ** See also: clone, config pull, push, remote-url, sync
233 */
234 void pull_cmd(void){
235 unsigned configFlags = 0;
236 unsigned syncFlags = SYNC_PULL;
237 const char *zAltPCode = find_option("project-code",0,1);
238 if( find_option("from-parent-project",0,0)!=0 ){
239 syncFlags |= SYNC_FROMPARENT;
240 }
241 process_sync_args(&configFlags, &syncFlags, 0);
242
243 /* We should be done with options.. */
244 verify_all_options();
245
246 client_sync(syncFlags, configFlags, 0, zAltPCode);
247 }
248
249 /*
250 ** COMMAND: push
251 **
@@ -285,11 +287,11 @@
287 verify_all_options();
288
289 if( db_get_boolean("dont-push",0) ){
290 fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
291 }
292 client_sync(syncFlags, 0, 0, 0);
293 }
294
295
296 /*
297 ** COMMAND: sync
@@ -332,11 +334,11 @@
334
335 /* We should be done with options.. */
336 verify_all_options();
337
338 if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
339 client_sync(syncFlags, configFlags, 0, 0);
340 if( (syncFlags & SYNC_PUSH)==0 ){
341 fossil_warning("pull only: the 'dont-push' option is set");
342 }
343 }
344
@@ -347,11 +349,11 @@
349 void sync_unversioned(unsigned syncFlags){
350 unsigned configFlags = 0;
351 (void)find_option("uv-noop",0,0);
352 process_sync_args(&configFlags, &syncFlags, 1);
353 verify_all_options();
354 client_sync(syncFlags, 0, 0, 0);
355 }
356
357 /*
358 ** COMMAND: remote-url
359 **
360
+8 -5
--- src/xfer.c
+++ src/xfer.c
@@ -1746,13 +1746,14 @@
17461746
** Records are pushed to the server if pushFlag is true. Records
17471747
** are pulled if pullFlag is true. A full sync occurs if both are
17481748
** true.
17491749
*/
17501750
int client_sync(
1751
- unsigned syncFlags, /* Mask of SYNC_* flags */
1752
- unsigned configRcvMask, /* Receive these configuration items */
1753
- unsigned configSendMask /* Send these configuration items */
1751
+ unsigned syncFlags, /* Mask of SYNC_* flags */
1752
+ unsigned configRcvMask, /* Receive these configuration items */
1753
+ unsigned configSendMask, /* Send these configuration items */
1754
+ const char *zAltPCode /* Alternative project code (usually NULL) */
17541755
){
17551756
int go = 1; /* Loop until zero */
17561757
int nCardSent = 0; /* Number of cards sent */
17571758
int nCardRcvd = 0; /* Number of cards received */
17581759
int nCycle = 0; /* Number of round trips to the server */
@@ -1866,11 +1867,12 @@
18661867
nCardSent++;
18671868
/* TBD: Request all transferable configuration values */
18681869
content_enable_dephantomize(0);
18691870
zOpType = "Clone";
18701871
}else if( syncFlags & SYNC_PULL ){
1871
- blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
1872
+ blob_appendf(&send, "pull %s %s\n", zSCode,
1873
+ zAltPCode ? zAltPCode : zPCode);
18721874
nCardSent++;
18731875
zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
18741876
if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
18751877
blob_appendf(&send, "pragma send-catalog\n");
18761878
nCardSent++;
@@ -2065,11 +2067,12 @@
20652067
20662068
/* Begin constructing the next message (which might never be
20672069
** sent) by beginning with the pull or push cards
20682070
*/
20692071
if( syncFlags & SYNC_PULL ){
2070
- blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
2072
+ blob_appendf(&send, "pull %s %s\n", zSCode,
2073
+ zAltPCode ? zAltPCode : zPCode);
20712074
nCardSent++;
20722075
}
20732076
if( syncFlags & SYNC_PUSH ){
20742077
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
20752078
nCardSent++;
20762079
--- src/xfer.c
+++ src/xfer.c
@@ -1746,13 +1746,14 @@
1746 ** Records are pushed to the server if pushFlag is true. Records
1747 ** are pulled if pullFlag is true. A full sync occurs if both are
1748 ** true.
1749 */
1750 int client_sync(
1751 unsigned syncFlags, /* Mask of SYNC_* flags */
1752 unsigned configRcvMask, /* Receive these configuration items */
1753 unsigned configSendMask /* Send these configuration items */
 
1754 ){
1755 int go = 1; /* Loop until zero */
1756 int nCardSent = 0; /* Number of cards sent */
1757 int nCardRcvd = 0; /* Number of cards received */
1758 int nCycle = 0; /* Number of round trips to the server */
@@ -1866,11 +1867,12 @@
1866 nCardSent++;
1867 /* TBD: Request all transferable configuration values */
1868 content_enable_dephantomize(0);
1869 zOpType = "Clone";
1870 }else if( syncFlags & SYNC_PULL ){
1871 blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
 
1872 nCardSent++;
1873 zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
1874 if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
1875 blob_appendf(&send, "pragma send-catalog\n");
1876 nCardSent++;
@@ -2065,11 +2067,12 @@
2065
2066 /* Begin constructing the next message (which might never be
2067 ** sent) by beginning with the pull or push cards
2068 */
2069 if( syncFlags & SYNC_PULL ){
2070 blob_appendf(&send, "pull %s %s\n", zSCode, zPCode);
 
2071 nCardSent++;
2072 }
2073 if( syncFlags & SYNC_PUSH ){
2074 blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
2075 nCardSent++;
2076
--- src/xfer.c
+++ src/xfer.c
@@ -1746,13 +1746,14 @@
1746 ** Records are pushed to the server if pushFlag is true. Records
1747 ** are pulled if pullFlag is true. A full sync occurs if both are
1748 ** true.
1749 */
1750 int client_sync(
1751 unsigned syncFlags, /* Mask of SYNC_* flags */
1752 unsigned configRcvMask, /* Receive these configuration items */
1753 unsigned configSendMask, /* Send these configuration items */
1754 const char *zAltPCode /* Alternative project code (usually NULL) */
1755 ){
1756 int go = 1; /* Loop until zero */
1757 int nCardSent = 0; /* Number of cards sent */
1758 int nCardRcvd = 0; /* Number of cards received */
1759 int nCycle = 0; /* Number of round trips to the server */
@@ -1866,11 +1867,12 @@
1867 nCardSent++;
1868 /* TBD: Request all transferable configuration values */
1869 content_enable_dephantomize(0);
1870 zOpType = "Clone";
1871 }else if( syncFlags & SYNC_PULL ){
1872 blob_appendf(&send, "pull %s %s\n", zSCode,
1873 zAltPCode ? zAltPCode : zPCode);
1874 nCardSent++;
1875 zOpType = (syncFlags & SYNC_PUSH)?"Sync":"Pull";
1876 if( (syncFlags & SYNC_RESYNC)!=0 && nCycle<2 ){
1877 blob_appendf(&send, "pragma send-catalog\n");
1878 nCardSent++;
@@ -2065,11 +2067,12 @@
2067
2068 /* Begin constructing the next message (which might never be
2069 ** sent) by beginning with the pull or push cards
2070 */
2071 if( syncFlags & SYNC_PULL ){
2072 blob_appendf(&send, "pull %s %s\n", zSCode,
2073 zAltPCode ? zAltPCode : zPCode);
2074 nCardSent++;
2075 }
2076 if( syncFlags & SYNC_PUSH ){
2077 blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
2078 nCardSent++;
2079
+1 -1
--- src/xfersetup.c
+++ src/xfersetup.c
@@ -80,11 +80,11 @@
8080
@
8181
if( P("sync") ){
8282
user_select();
8383
url_enable_proxy(0);
8484
@ <pre class="xfersetup">
85
- client_sync(syncFlags, 0, 0);
85
+ client_sync(syncFlags, 0, 0, 0);
8686
@ </pre>
8787
}
8888
}
8989
9090
style_footer();
9191
--- src/xfersetup.c
+++ src/xfersetup.c
@@ -80,11 +80,11 @@
80 @
81 if( P("sync") ){
82 user_select();
83 url_enable_proxy(0);
84 @ <pre class="xfersetup">
85 client_sync(syncFlags, 0, 0);
86 @ </pre>
87 }
88 }
89
90 style_footer();
91
--- src/xfersetup.c
+++ src/xfersetup.c
@@ -80,11 +80,11 @@
80 @
81 if( P("sync") ){
82 user_select();
83 url_enable_proxy(0);
84 @ <pre class="xfersetup">
85 client_sync(syncFlags, 0, 0, 0);
86 @ </pre>
87 }
88 }
89
90 style_footer();
91

Keyboard Shortcuts

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