Fossil SCM

For sync, the client should only send "pragma client-url" if not doing a cross-project import.

drh 2021-12-21 14:04 trunk
Commit b330ce6cfb817d77424df5ceb7529f44c5696185133e2e89c2204486684d62e0
1 file changed +23 -4
+23 -4
--- src/xfer.c
+++ src/xfer.c
@@ -1917,21 +1917,40 @@
19171917
const char *zClientId; /* A unique identifier for this check-out */
19181918
unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
19191919
19201920
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
19211921
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
1922
- && configRcvMask==0 && configSendMask==0 ) return 0;
1922
+ && configRcvMask==0
1923
+ && configSendMask==0
1924
+ ){
1925
+ return 0; /* Nothing to do */
1926
+ }
1927
+
1928
+ /* Compute an appropriate project code. zPCode is the project code
1929
+ ** for the local repository. zAltPCode will usually be NULL, but might
1930
+ ** also be an alternative project code to expect on the server. When
1931
+ ** zAltPCode is not NULL, that means we are doing a cross-project import -
1932
+ ** in other words, reading content from one project into a different
1933
+ ** project.
1934
+ */
19231935
if( syncFlags & SYNC_FROMPARENT ){
1936
+ const char *zPX;
19241937
configRcvMask = 0;
19251938
configSendMask = 0;
19261939
syncFlags &= ~(SYNC_PUSH);
1927
- zPCode = db_get("parent-project-code", 0);
1928
- if( zPCode==0 || db_get("parent-project-name",0)==0 ){
1940
+ zPX = db_get("parent-project-code", 0);
1941
+ if( zPX==0 || db_get("parent-project-name",0)==0 ){
19291942
fossil_fatal("there is no parent project: set the 'parent-project-code'"
19301943
" and 'parent-project-name' config parameters in order"
19311944
" to pull from a parent project");
19321945
}
1946
+ if( zPX ){
1947
+ zAltPCode = zPX;
1948
+ }
1949
+ }
1950
+ if( zAltPCode!=0 && zPCode!=0 && sqlite3_stricmp(zPCode, zAltPCode)==0 ){
1951
+ zAltPCode = 0;
19331952
}
19341953
19351954
transport_stats(0, 0, 1);
19361955
socket_global_init();
19371956
memset(&xfer, 0, sizeof(xfer));
@@ -2183,11 +2202,11 @@
21832202
}
21842203
21852204
/* Send the client-url pragma on the first cycle if the client has
21862205
** a known public url.
21872206
*/
2188
- if( nCycle==0 ){
2207
+ if( nCycle==0 && zAltPCode==0 ){
21892208
const char *zSelfUrl = public_url();
21902209
if( zSelfUrl ){
21912210
blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
21922211
}
21932212
}
21942213
--- src/xfer.c
+++ src/xfer.c
@@ -1917,21 +1917,40 @@
1917 const char *zClientId; /* A unique identifier for this check-out */
1918 unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
1919
1920 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
1921 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
1922 && configRcvMask==0 && configSendMask==0 ) return 0;
 
 
 
 
 
 
 
 
 
 
 
 
1923 if( syncFlags & SYNC_FROMPARENT ){
 
1924 configRcvMask = 0;
1925 configSendMask = 0;
1926 syncFlags &= ~(SYNC_PUSH);
1927 zPCode = db_get("parent-project-code", 0);
1928 if( zPCode==0 || db_get("parent-project-name",0)==0 ){
1929 fossil_fatal("there is no parent project: set the 'parent-project-code'"
1930 " and 'parent-project-name' config parameters in order"
1931 " to pull from a parent project");
1932 }
 
 
 
 
 
 
1933 }
1934
1935 transport_stats(0, 0, 1);
1936 socket_global_init();
1937 memset(&xfer, 0, sizeof(xfer));
@@ -2183,11 +2202,11 @@
2183 }
2184
2185 /* Send the client-url pragma on the first cycle if the client has
2186 ** a known public url.
2187 */
2188 if( nCycle==0 ){
2189 const char *zSelfUrl = public_url();
2190 if( zSelfUrl ){
2191 blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
2192 }
2193 }
2194
--- src/xfer.c
+++ src/xfer.c
@@ -1917,21 +1917,40 @@
1917 const char *zClientId; /* A unique identifier for this check-out */
1918 unsigned int mHttpFlags;/* Flags for the http_exchange() subsystem */
1919
1920 if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
1921 if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE|SYNC_UNVERSIONED))==0
1922 && configRcvMask==0
1923 && configSendMask==0
1924 ){
1925 return 0; /* Nothing to do */
1926 }
1927
1928 /* Compute an appropriate project code. zPCode is the project code
1929 ** for the local repository. zAltPCode will usually be NULL, but might
1930 ** also be an alternative project code to expect on the server. When
1931 ** zAltPCode is not NULL, that means we are doing a cross-project import -
1932 ** in other words, reading content from one project into a different
1933 ** project.
1934 */
1935 if( syncFlags & SYNC_FROMPARENT ){
1936 const char *zPX;
1937 configRcvMask = 0;
1938 configSendMask = 0;
1939 syncFlags &= ~(SYNC_PUSH);
1940 zPX = db_get("parent-project-code", 0);
1941 if( zPX==0 || db_get("parent-project-name",0)==0 ){
1942 fossil_fatal("there is no parent project: set the 'parent-project-code'"
1943 " and 'parent-project-name' config parameters in order"
1944 " to pull from a parent project");
1945 }
1946 if( zPX ){
1947 zAltPCode = zPX;
1948 }
1949 }
1950 if( zAltPCode!=0 && zPCode!=0 && sqlite3_stricmp(zPCode, zAltPCode)==0 ){
1951 zAltPCode = 0;
1952 }
1953
1954 transport_stats(0, 0, 1);
1955 socket_global_init();
1956 memset(&xfer, 0, sizeof(xfer));
@@ -2183,11 +2202,11 @@
2202 }
2203
2204 /* Send the client-url pragma on the first cycle if the client has
2205 ** a known public url.
2206 */
2207 if( nCycle==0 && zAltPCode==0 ){
2208 const char *zSelfUrl = public_url();
2209 if( zSelfUrl ){
2210 blob_appendf(&send, "pragma client-url %s\n", zSelfUrl);
2211 }
2212 }
2213

Keyboard Shortcuts

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