Fossil SCM
Fix the "pragma client-url" and "pragma req-alt-repo" pragmas to that they are in fact sent on the first message. Begin using "{}" as the value for config setings such as "syncwith" so that the value can later be extended to hold JSON.
Commit
ebcce3ccddf2c404a609cbf23f7d96220c9ee2dd0fc92abef82b5b5823c68341
Parent
b330ce6cfb817d7…
2 files changed
+1
-1
+23
-14
+1
-1
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -1717,11 +1717,11 @@ | ||
| 1717 | 1717 | if( rc ){ |
| 1718 | 1718 | fossil_fatal("cannot push content using: %s", zPushCmd); |
| 1719 | 1719 | }else if( db_is_writeable("repository") ){ |
| 1720 | 1720 | db_unprotect(PROTECT_CONFIG); |
| 1721 | 1721 | db_multi_exec("REPLACE INTO config(name,value,mtime)" |
| 1722 | - "VALUES('gitpush:%q',1,now())", zPushUrl); | |
| 1722 | + "VALUES('gitpush:%q','{}',now())", zPushUrl); | |
| 1723 | 1723 | db_protect_pop(); |
| 1724 | 1724 | } |
| 1725 | 1725 | fossil_free(zPushCmd); |
| 1726 | 1726 | } |
| 1727 | 1727 | } |
| 1728 | 1728 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1717,11 +1717,11 @@ | |
| 1717 | if( rc ){ |
| 1718 | fossil_fatal("cannot push content using: %s", zPushCmd); |
| 1719 | }else if( db_is_writeable("repository") ){ |
| 1720 | db_unprotect(PROTECT_CONFIG); |
| 1721 | db_multi_exec("REPLACE INTO config(name,value,mtime)" |
| 1722 | "VALUES('gitpush:%q',1,now())", zPushUrl); |
| 1723 | db_protect_pop(); |
| 1724 | } |
| 1725 | fossil_free(zPushCmd); |
| 1726 | } |
| 1727 | } |
| 1728 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1717,11 +1717,11 @@ | |
| 1717 | if( rc ){ |
| 1718 | fossil_fatal("cannot push content using: %s", zPushCmd); |
| 1719 | }else if( db_is_writeable("repository") ){ |
| 1720 | db_unprotect(PROTECT_CONFIG); |
| 1721 | db_multi_exec("REPLACE INTO config(name,value,mtime)" |
| 1722 | "VALUES('gitpush:%q','{}',now())", zPushUrl); |
| 1723 | db_protect_pop(); |
| 1724 | } |
| 1725 | fossil_free(zPushCmd); |
| 1726 | } |
| 1727 | } |
| 1728 |
+23
-14
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1154,21 +1154,24 @@ | ||
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /* |
| 1157 | 1157 | ** This routine makes a "syncwith:URL" entry in the CONFIG table to |
| 1158 | 1158 | ** indicate that a sync is occuring with zUrl. |
| 1159 | +** | |
| 1160 | +** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true. | |
| 1159 | 1161 | */ |
| 1160 | -static void xfer_syncwith(const char *zUrl){ | |
| 1162 | +static void xfer_syncwith(const char *zUrl, int bSyncFrom){ | |
| 1161 | 1163 | UrlData x; |
| 1162 | 1164 | memset(&x, 0, sizeof(x)); |
| 1163 | 1165 | url_parse_local(zUrl, URL_OMIT_USER, &x); |
| 1164 | 1166 | if( x.protocol && strncmp(x.protocol,"http",4)==0 |
| 1165 | 1167 | && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0 |
| 1166 | 1168 | ){ |
| 1167 | 1169 | db_unprotect(PROTECT_CONFIG); |
| 1168 | 1170 | db_multi_exec("REPLACE INTO config(name,value,mtime)" |
| 1169 | - "VALUES('syncwith:%q',1,now())", x.canonical); | |
| 1171 | + "VALUES('sync%q:%q','{}',now())", | |
| 1172 | + bSyncFrom ? "from" : "with", x.canonical); | |
| 1170 | 1173 | db_protect_pop(); |
| 1171 | 1174 | } |
| 1172 | 1175 | url_unparse(&x); |
| 1173 | 1176 | } |
| 1174 | 1177 | |
| @@ -1737,11 +1740,11 @@ | ||
| 1737 | 1740 | */ |
| 1738 | 1741 | if( blob_eq(&xfer.aToken[1], "client-url") |
| 1739 | 1742 | && xfer.nToken==3 |
| 1740 | 1743 | && g.perm.Write |
| 1741 | 1744 | ){ |
| 1742 | - xfer_syncwith(blob_str(&xfer.aToken[2])); | |
| 1745 | + xfer_syncwith(blob_str(&xfer.aToken[2]), 1); | |
| 1743 | 1746 | } |
| 1744 | 1747 | |
| 1745 | 1748 | }else |
| 1746 | 1749 | |
| 1747 | 1750 | /* Unknown message |
| @@ -2038,10 +2041,26 @@ | ||
| 2038 | 2041 | } |
| 2039 | 2042 | if( syncFlags & SYNC_VERBOSE ){ |
| 2040 | 2043 | fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/, |
| 2041 | 2044 | "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 2042 | 2045 | } |
| 2046 | + | |
| 2047 | + /* Send the client-url pragma on the first cycle if the client has | |
| 2048 | + ** a known public url. | |
| 2049 | + */ | |
| 2050 | + if( zAltPCode==0 ){ | |
| 2051 | + const char *zSelfUrl = public_url(); | |
| 2052 | + if( zSelfUrl ){ | |
| 2053 | + blob_appendf(&send, "pragma client-url %s\n", zSelfUrl); | |
| 2054 | + } | |
| 2055 | + } | |
| 2056 | + | |
| 2057 | + /* Request names of alternative repositories | |
| 2058 | + */ | |
| 2059 | + if( zAltPCode==0 ){ | |
| 2060 | + blob_appendf(&send, "pragma req-alt-repo\n"); | |
| 2061 | + } | |
| 2043 | 2062 | |
| 2044 | 2063 | while( go ){ |
| 2045 | 2064 | int newPhantom = 0; |
| 2046 | 2065 | char *zRandomness; |
| 2047 | 2066 | db_begin_transaction(); |
| @@ -2196,21 +2215,11 @@ | ||
| 2196 | 2215 | } |
| 2197 | 2216 | |
| 2198 | 2217 | /* Remember the URL of the sync target in the config file on the |
| 2199 | 2218 | ** first successful round-trip */ |
| 2200 | 2219 | if( nCycle==0 && db_is_writeable("repository") ){ |
| 2201 | - xfer_syncwith(g.url.canonical); | |
| 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 | - } | |
| 2220 | + xfer_syncwith(g.url.canonical, 0); | |
| 2212 | 2221 | } |
| 2213 | 2222 | |
| 2214 | 2223 | /* Output current stats */ |
| 2215 | 2224 | if( syncFlags & SYNC_VERBOSE ){ |
| 2216 | 2225 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:", |
| 2217 | 2226 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1154,21 +1154,24 @@ | |
| 1154 | } |
| 1155 | |
| 1156 | /* |
| 1157 | ** This routine makes a "syncwith:URL" entry in the CONFIG table to |
| 1158 | ** indicate that a sync is occuring with zUrl. |
| 1159 | */ |
| 1160 | static void xfer_syncwith(const char *zUrl){ |
| 1161 | UrlData x; |
| 1162 | memset(&x, 0, sizeof(x)); |
| 1163 | url_parse_local(zUrl, URL_OMIT_USER, &x); |
| 1164 | if( x.protocol && strncmp(x.protocol,"http",4)==0 |
| 1165 | && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0 |
| 1166 | ){ |
| 1167 | db_unprotect(PROTECT_CONFIG); |
| 1168 | db_multi_exec("REPLACE INTO config(name,value,mtime)" |
| 1169 | "VALUES('syncwith:%q',1,now())", x.canonical); |
| 1170 | db_protect_pop(); |
| 1171 | } |
| 1172 | url_unparse(&x); |
| 1173 | } |
| 1174 | |
| @@ -1737,11 +1740,11 @@ | |
| 1737 | */ |
| 1738 | if( blob_eq(&xfer.aToken[1], "client-url") |
| 1739 | && xfer.nToken==3 |
| 1740 | && g.perm.Write |
| 1741 | ){ |
| 1742 | xfer_syncwith(blob_str(&xfer.aToken[2])); |
| 1743 | } |
| 1744 | |
| 1745 | }else |
| 1746 | |
| 1747 | /* Unknown message |
| @@ -2038,10 +2041,26 @@ | |
| 2038 | } |
| 2039 | if( syncFlags & SYNC_VERBOSE ){ |
| 2040 | fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/, |
| 2041 | "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 2042 | } |
| 2043 | |
| 2044 | while( go ){ |
| 2045 | int newPhantom = 0; |
| 2046 | char *zRandomness; |
| 2047 | db_begin_transaction(); |
| @@ -2196,21 +2215,11 @@ | |
| 2196 | } |
| 2197 | |
| 2198 | /* Remember the URL of the sync target in the config file on the |
| 2199 | ** first successful round-trip */ |
| 2200 | if( nCycle==0 && db_is_writeable("repository") ){ |
| 2201 | xfer_syncwith(g.url.canonical); |
| 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 | |
| 2214 | /* Output current stats */ |
| 2215 | if( syncFlags & SYNC_VERBOSE ){ |
| 2216 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:", |
| 2217 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1154,21 +1154,24 @@ | |
| 1154 | } |
| 1155 | |
| 1156 | /* |
| 1157 | ** This routine makes a "syncwith:URL" entry in the CONFIG table to |
| 1158 | ** indicate that a sync is occuring with zUrl. |
| 1159 | ** |
| 1160 | ** Add a "syncfrom:URL" entry instead of "syncwith:URL" if bSyncFrom is true. |
| 1161 | */ |
| 1162 | static void xfer_syncwith(const char *zUrl, int bSyncFrom){ |
| 1163 | UrlData x; |
| 1164 | memset(&x, 0, sizeof(x)); |
| 1165 | url_parse_local(zUrl, URL_OMIT_USER, &x); |
| 1166 | if( x.protocol && strncmp(x.protocol,"http",4)==0 |
| 1167 | && x.name && sqlite3_strlike("%localhost%", x.name, 0)!=0 |
| 1168 | ){ |
| 1169 | db_unprotect(PROTECT_CONFIG); |
| 1170 | db_multi_exec("REPLACE INTO config(name,value,mtime)" |
| 1171 | "VALUES('sync%q:%q','{}',now())", |
| 1172 | bSyncFrom ? "from" : "with", x.canonical); |
| 1173 | db_protect_pop(); |
| 1174 | } |
| 1175 | url_unparse(&x); |
| 1176 | } |
| 1177 | |
| @@ -1737,11 +1740,11 @@ | |
| 1740 | */ |
| 1741 | if( blob_eq(&xfer.aToken[1], "client-url") |
| 1742 | && xfer.nToken==3 |
| 1743 | && g.perm.Write |
| 1744 | ){ |
| 1745 | xfer_syncwith(blob_str(&xfer.aToken[2]), 1); |
| 1746 | } |
| 1747 | |
| 1748 | }else |
| 1749 | |
| 1750 | /* Unknown message |
| @@ -2038,10 +2041,26 @@ | |
| 2041 | } |
| 2042 | if( syncFlags & SYNC_VERBOSE ){ |
| 2043 | fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/, |
| 2044 | "", "Bytes", "Cards", "Artifacts", "Deltas"); |
| 2045 | } |
| 2046 | |
| 2047 | /* Send the client-url pragma on the first cycle if the client has |
| 2048 | ** a known public url. |
| 2049 | */ |
| 2050 | if( zAltPCode==0 ){ |
| 2051 | const char *zSelfUrl = public_url(); |
| 2052 | if( zSelfUrl ){ |
| 2053 | blob_appendf(&send, "pragma client-url %s\n", zSelfUrl); |
| 2054 | } |
| 2055 | } |
| 2056 | |
| 2057 | /* Request names of alternative repositories |
| 2058 | */ |
| 2059 | if( zAltPCode==0 ){ |
| 2060 | blob_appendf(&send, "pragma req-alt-repo\n"); |
| 2061 | } |
| 2062 | |
| 2063 | while( go ){ |
| 2064 | int newPhantom = 0; |
| 2065 | char *zRandomness; |
| 2066 | db_begin_transaction(); |
| @@ -2196,21 +2215,11 @@ | |
| 2215 | } |
| 2216 | |
| 2217 | /* Remember the URL of the sync target in the config file on the |
| 2218 | ** first successful round-trip */ |
| 2219 | if( nCycle==0 && db_is_writeable("repository") ){ |
| 2220 | xfer_syncwith(g.url.canonical, 0); |
| 2221 | } |
| 2222 | |
| 2223 | /* Output current stats */ |
| 2224 | if( syncFlags & SYNC_VERBOSE ){ |
| 2225 | fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:", |
| 2226 |