Fossil SCM

Fixes to the "fossil unversioned revert" command.

drh 2016-09-20 15:10 trunk
Commit 122ab3fbfdb12ee8b87b11e6c4df8e24a6cef4fd
1 file changed +17 -4
+17 -4
--- src/xfer.c
+++ src/xfer.c
@@ -1750,18 +1750,23 @@
17501750
if( syncFlags & SYNC_PRIVATE ){
17511751
blob_append(&send, "pragma send-private\n", -1);
17521752
}
17531753
17541754
/* 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.
17561761
*/
17571762
if( (syncFlags & SYNC_UNVERSIONED)!=0 ){
17581763
unversioned_schema();
17591764
db_multi_exec(
17601765
"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 */
17631768
") WITHOUT ROWID;"
17641769
"INSERT INTO uv_toSend(name,mtimeOnly)"
17651770
" SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;"
17661771
);
17671772
}
@@ -1884,10 +1889,14 @@
18841889
/* Send unversioned files present here on the client but missing or
18851890
** obsolete on the server.
18861891
**
18871892
** Or, if the SYNC_UV_REVERT flag is set, delete the local unversioned
18881893
** 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.
18891898
*/
18901899
if( uvDoPush ){
18911900
assert( (syncFlags & SYNC_UNVERSIONED)!=0 );
18921901
if( syncFlags & SYNC_UV_REVERT ){
18931902
db_multi_exec(
@@ -2110,16 +2119,20 @@
21102119
){
21112120
const char *zName = blob_str(&xfer.aToken[1]);
21122121
const char *zHash = blob_str(&xfer.aToken[3]);
21132122
int iStatus;
21142123
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
+ }
21162128
if( iStatus<=1 ){
21172129
if( zHash[0]!='-' ){
21182130
blob_appendf(xfer.pOut, "uvgimme %s\n", zName);
21192131
nCardSent++;
21202132
nUvGimmeSent++;
2133
+ db_multi_exec("DELETE FROM unversioned WHERE name=%Q", zName);
21212134
}else if( iStatus==1 ){
21222135
db_multi_exec(
21232136
"UPDATE unversioned"
21242137
" SET mtime=%lld, hash=NULL, sz=0, encoding=0, content=NULL"
21252138
" WHERE name=%Q", mtime, zName
21262139
--- 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

Keyboard Shortcuts

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