Fossil SCM
Fixes to the "fossil unversioned revert" command.
Commit
122ab3fbfdb12ee8b87b11e6c4df8e24a6cef4fd
Parent
515229c5cd33428…
1 file changed
+17
-4
+17
-4
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1750,18 +1750,23 @@ | ||
| 1750 | 1750 | if( syncFlags & SYNC_PRIVATE ){ |
| 1751 | 1751 | blob_append(&send, "pragma send-private\n", -1); |
| 1752 | 1752 | } |
| 1753 | 1753 | |
| 1754 | 1754 | /* When syncing unversioned files, create a TEMP table in which to store |
| 1755 | - ** the names of files that do not need to be sent from client to server. | |
| 1755 | + ** the names of files that need to be sent from client to server. | |
| 1756 | + ** | |
| 1757 | + ** The initial assumption is that all unversioned files need to be sent | |
| 1758 | + ** to the other side. But "uvigot" cards received back from the remote | |
| 1759 | + ** side will normally cause many of these entries to be removed since they | |
| 1760 | + ** do not really need to be sent. | |
| 1756 | 1761 | */ |
| 1757 | 1762 | if( (syncFlags & SYNC_UNVERSIONED)!=0 ){ |
| 1758 | 1763 | unversioned_schema(); |
| 1759 | 1764 | db_multi_exec( |
| 1760 | 1765 | "CREATE TEMP TABLE uv_tosend(" |
| 1761 | - " name TEXT PRIMARY KEY," | |
| 1762 | - " mtimeOnly BOOLEAN" | |
| 1766 | + " name TEXT PRIMARY KEY," /* Name of file to send client->server */ | |
| 1767 | + " mtimeOnly BOOLEAN" /* True to only send mtime, not content */ | |
| 1763 | 1768 | ") WITHOUT ROWID;" |
| 1764 | 1769 | "INSERT INTO uv_toSend(name,mtimeOnly)" |
| 1765 | 1770 | " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;" |
| 1766 | 1771 | ); |
| 1767 | 1772 | } |
| @@ -1884,10 +1889,14 @@ | ||
| 1884 | 1889 | /* Send unversioned files present here on the client but missing or |
| 1885 | 1890 | ** obsolete on the server. |
| 1886 | 1891 | ** |
| 1887 | 1892 | ** Or, if the SYNC_UV_REVERT flag is set, delete the local unversioned |
| 1888 | 1893 | ** files that do not exist on the server. |
| 1894 | + ** | |
| 1895 | + ** This happens on the second exchange, since we do not know what files | |
| 1896 | + ** need to be sent until after the uvigot cards from the first exchange | |
| 1897 | + ** have been processed. | |
| 1889 | 1898 | */ |
| 1890 | 1899 | if( uvDoPush ){ |
| 1891 | 1900 | assert( (syncFlags & SYNC_UNVERSIONED)!=0 ); |
| 1892 | 1901 | if( syncFlags & SYNC_UV_REVERT ){ |
| 1893 | 1902 | db_multi_exec( |
| @@ -2110,16 +2119,20 @@ | ||
| 2110 | 2119 | ){ |
| 2111 | 2120 | const char *zName = blob_str(&xfer.aToken[1]); |
| 2112 | 2121 | const char *zHash = blob_str(&xfer.aToken[3]); |
| 2113 | 2122 | int iStatus; |
| 2114 | 2123 | iStatus = unversioned_status(zName, mtime, zHash); |
| 2115 | - if( (syncFlags & SYNC_UV_REVERT)!=0 && iStatus==4 ) iStatus = 2; | |
| 2124 | + if( (syncFlags & SYNC_UV_REVERT)!=0 ){ | |
| 2125 | + if( iStatus==4 ) iStatus = 2; | |
| 2126 | + if( iStatus==5 ) iStatus = 1; | |
| 2127 | + } | |
| 2116 | 2128 | if( iStatus<=1 ){ |
| 2117 | 2129 | if( zHash[0]!='-' ){ |
| 2118 | 2130 | blob_appendf(xfer.pOut, "uvgimme %s\n", zName); |
| 2119 | 2131 | nCardSent++; |
| 2120 | 2132 | nUvGimmeSent++; |
| 2133 | + db_multi_exec("DELETE FROM unversioned WHERE name=%Q", zName); | |
| 2121 | 2134 | }else if( iStatus==1 ){ |
| 2122 | 2135 | db_multi_exec( |
| 2123 | 2136 | "UPDATE unversioned" |
| 2124 | 2137 | " SET mtime=%lld, hash=NULL, sz=0, encoding=0, content=NULL" |
| 2125 | 2138 | " WHERE name=%Q", mtime, zName |
| 2126 | 2139 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1750,18 +1750,23 @@ | |
| 1750 | if( syncFlags & SYNC_PRIVATE ){ |
| 1751 | blob_append(&send, "pragma send-private\n", -1); |
| 1752 | } |
| 1753 | |
| 1754 | /* When syncing unversioned files, create a TEMP table in which to store |
| 1755 | ** the names of files that do not need to be sent from client to server. |
| 1756 | */ |
| 1757 | if( (syncFlags & SYNC_UNVERSIONED)!=0 ){ |
| 1758 | unversioned_schema(); |
| 1759 | db_multi_exec( |
| 1760 | "CREATE TEMP TABLE uv_tosend(" |
| 1761 | " name TEXT PRIMARY KEY," |
| 1762 | " mtimeOnly BOOLEAN" |
| 1763 | ") WITHOUT ROWID;" |
| 1764 | "INSERT INTO uv_toSend(name,mtimeOnly)" |
| 1765 | " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;" |
| 1766 | ); |
| 1767 | } |
| @@ -1884,10 +1889,14 @@ | |
| 1884 | /* Send unversioned files present here on the client but missing or |
| 1885 | ** obsolete on the server. |
| 1886 | ** |
| 1887 | ** Or, if the SYNC_UV_REVERT flag is set, delete the local unversioned |
| 1888 | ** files that do not exist on the server. |
| 1889 | */ |
| 1890 | if( uvDoPush ){ |
| 1891 | assert( (syncFlags & SYNC_UNVERSIONED)!=0 ); |
| 1892 | if( syncFlags & SYNC_UV_REVERT ){ |
| 1893 | db_multi_exec( |
| @@ -2110,16 +2119,20 @@ | |
| 2110 | ){ |
| 2111 | const char *zName = blob_str(&xfer.aToken[1]); |
| 2112 | const char *zHash = blob_str(&xfer.aToken[3]); |
| 2113 | int iStatus; |
| 2114 | iStatus = unversioned_status(zName, mtime, zHash); |
| 2115 | if( (syncFlags & SYNC_UV_REVERT)!=0 && iStatus==4 ) iStatus = 2; |
| 2116 | if( iStatus<=1 ){ |
| 2117 | if( zHash[0]!='-' ){ |
| 2118 | blob_appendf(xfer.pOut, "uvgimme %s\n", zName); |
| 2119 | nCardSent++; |
| 2120 | nUvGimmeSent++; |
| 2121 | }else if( iStatus==1 ){ |
| 2122 | db_multi_exec( |
| 2123 | "UPDATE unversioned" |
| 2124 | " SET mtime=%lld, hash=NULL, sz=0, encoding=0, content=NULL" |
| 2125 | " WHERE name=%Q", mtime, zName |
| 2126 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1750,18 +1750,23 @@ | |
| 1750 | if( syncFlags & SYNC_PRIVATE ){ |
| 1751 | blob_append(&send, "pragma send-private\n", -1); |
| 1752 | } |
| 1753 | |
| 1754 | /* When syncing unversioned files, create a TEMP table in which to store |
| 1755 | ** the names of files that need to be sent from client to server. |
| 1756 | ** |
| 1757 | ** The initial assumption is that all unversioned files need to be sent |
| 1758 | ** to the other side. But "uvigot" cards received back from the remote |
| 1759 | ** side will normally cause many of these entries to be removed since they |
| 1760 | ** do not really need to be sent. |
| 1761 | */ |
| 1762 | if( (syncFlags & SYNC_UNVERSIONED)!=0 ){ |
| 1763 | unversioned_schema(); |
| 1764 | db_multi_exec( |
| 1765 | "CREATE TEMP TABLE uv_tosend(" |
| 1766 | " name TEXT PRIMARY KEY," /* Name of file to send client->server */ |
| 1767 | " mtimeOnly BOOLEAN" /* True to only send mtime, not content */ |
| 1768 | ") WITHOUT ROWID;" |
| 1769 | "INSERT INTO uv_toSend(name,mtimeOnly)" |
| 1770 | " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;" |
| 1771 | ); |
| 1772 | } |
| @@ -1884,10 +1889,14 @@ | |
| 1889 | /* Send unversioned files present here on the client but missing or |
| 1890 | ** obsolete on the server. |
| 1891 | ** |
| 1892 | ** Or, if the SYNC_UV_REVERT flag is set, delete the local unversioned |
| 1893 | ** files that do not exist on the server. |
| 1894 | ** |
| 1895 | ** This happens on the second exchange, since we do not know what files |
| 1896 | ** need to be sent until after the uvigot cards from the first exchange |
| 1897 | ** have been processed. |
| 1898 | */ |
| 1899 | if( uvDoPush ){ |
| 1900 | assert( (syncFlags & SYNC_UNVERSIONED)!=0 ); |
| 1901 | if( syncFlags & SYNC_UV_REVERT ){ |
| 1902 | db_multi_exec( |
| @@ -2110,16 +2119,20 @@ | |
| 2119 | ){ |
| 2120 | const char *zName = blob_str(&xfer.aToken[1]); |
| 2121 | const char *zHash = blob_str(&xfer.aToken[3]); |
| 2122 | int iStatus; |
| 2123 | iStatus = unversioned_status(zName, mtime, zHash); |
| 2124 | if( (syncFlags & SYNC_UV_REVERT)!=0 ){ |
| 2125 | if( iStatus==4 ) iStatus = 2; |
| 2126 | if( iStatus==5 ) iStatus = 1; |
| 2127 | } |
| 2128 | if( iStatus<=1 ){ |
| 2129 | if( zHash[0]!='-' ){ |
| 2130 | blob_appendf(xfer.pOut, "uvgimme %s\n", zName); |
| 2131 | nCardSent++; |
| 2132 | nUvGimmeSent++; |
| 2133 | db_multi_exec("DELETE FROM unversioned WHERE name=%Q", zName); |
| 2134 | }else if( iStatus==1 ){ |
| 2135 | db_multi_exec( |
| 2136 | "UPDATE unversioned" |
| 2137 | " SET mtime=%lld, hash=NULL, sz=0, encoding=0, content=NULL" |
| 2138 | " WHERE name=%Q", mtime, zName |
| 2139 |