Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Add the --verbose and --dryrun options to the "fossil unversioned revert" and "fossil unversioned sync" commands. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
b5641c5cffeef36f4bcaf8f93c90c50e |
| User & Date: | drh 2016-09-20 15:48:01.020 |
Context
|
2016-09-20
| ||
| 16:17 | Add the uv-sync setting, which if enabled causes the server to automatically send all unversioned content as part of a clone, and which causes all syncs to also sync unversioned content. check-in: b9fd5947ef user: drh tags: trunk | |
| 15:48 | Add the --verbose and --dryrun options to the "fossil unversioned revert" and "fossil unversioned sync" commands. check-in: b5641c5cff user: drh tags: trunk | |
| 15:10 | Fixes to the "fossil unversioned revert" command. check-in: 122ab3fbfd user: drh tags: trunk | |
Changes
Changes to src/unversioned.c.
| ︙ | ︙ | |||
140 141 142 143 144 145 146 |
blob_reset(&hash);
db_finalize(&ins);
db_unset("uv-hash", 0);
}
/*
| | > | | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
blob_reset(&hash);
db_finalize(&ins);
db_unset("uv-hash", 0);
}
/*
** Check the status of unversioned file zName. "mtime" and "zHash" are the
** time of last change and SHA1 hash of a copy of this file on a remote
** server. Return an integer status code as follows:
**
** 0: zName does not exist in the unversioned table.
** 1: zName exists and should be replaced by the mtime/zHash remote.
** 2: zName exists and is the same as zHash but has a older mtime
** 3: zName exists and is identical to mtime/zHash in all respects.
** 4: zName exists and is the same as zHash but has a newer mtime.
** 5: zName exists and should override the mtime/zHash remote.
*/
int unversioned_status(const char *zName, sqlite3_int64 mtime, const char *zHash){
int iStatus = 0;
Stmt q;
db_prepare(&q, "SELECT mtime, hash FROM unversioned WHERE name=%Q", zName);
if( db_step(&q)==SQLITE_ROW ){
const char *zLocalHash = db_column_text(&q, 1);
|
| ︙ | ︙ | |||
172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
}else{
iStatus = 5;
}
}
db_finalize(&q);
return iStatus;
}
/*
** COMMAND: unversioned
**
** Usage: %fossil unversioned SUBCOMMAND ARGS...
**
** Unversioned files (UV-files) are artifacts that are synced and are available
| > > > > > > > > > > > > > | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
}else{
iStatus = 5;
}
}
db_finalize(&q);
return iStatus;
}
/*
** Extract command-line options for the "revert" and "sync" subcommands
*/
static int unversioned_sync_flags(unsigned syncFlags){
if( find_option("verbose","v",0)!=0 ){
syncFlags |= SYNC_UV_TRACE | SYNC_VERBOSE;
}
if( find_option("dryrun","n",0)!=0 ){
syncFlags |= SYNC_UV_DRYRUN | SYNC_UV_TRACE | SYNC_VERBOSE;
}
return syncFlags;
}
/*
** COMMAND: unversioned
**
** Usage: %fossil unversioned SUBCOMMAND ARGS...
**
** Unversioned files (UV-files) are artifacts that are synced and are available
|
| ︙ | ︙ | |||
202 203 204 205 206 207 208 209 210 211 | ** ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk ** ** list | ls Show all unversioned files held in the local repository. ** ** revert ?URL? Restore the state of all unversioned files in the local ** repository to match the remote repository URL. ** ** rm FILE ... Remove an unversioned files from the local repository. ** Changes are not pushed to other repositories until | > > > | > > > | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | ** ** export FILE OUTPUT Write the content of FILE into OUTPUT on disk ** ** list | ls Show all unversioned files held in the local repository. ** ** revert ?URL? Restore the state of all unversioned files in the local ** repository to match the remote repository URL. ** Options: ** -v|--verbose Extra diagnostic output ** -n|--dryrun Show what would have happened ** ** rm FILE ... Remove an unversioned files from the local repository. ** Changes are not pushed to other repositories until ** the next sync. ** ** sync ?URL? Synchronize the state of all unversioned files with ** the remote repository URL. The most recent version of ** each file is propagate to all repositories and all ** prior versions are permanently forgotten. ** Options: ** -v|--verbose Extra diagnostic output ** -n|--dryrun Show what would have happened ** ** touch FILE ... Update the TIMESTAMP on all of the listed files ** ** Options: ** ** --mtime TIMESTAMP Use TIMESTAMP instead of "now" for "add" and "rm". */ |
| ︙ | ︙ | |||
363 364 365 366 367 368 369 370 371 |
db_column_text(&q,4),
zNoContent
);
}
}
db_finalize(&q);
}else if( memcmp(zCmd, "revert", nCmd)==0 ){
g.argv[1] = "sync";
g.argv[2] = "--uv-noop";
| > | > | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 |
db_column_text(&q,4),
zNoContent
);
}
}
db_finalize(&q);
}else if( memcmp(zCmd, "revert", nCmd)==0 ){
unsigned syncFlags = unversioned_sync_flags(SYNC_UNVERSIONED|SYNC_UV_REVERT);
g.argv[1] = "sync";
g.argv[2] = "--uv-noop";
sync_unversioned(syncFlags);
}else if( memcmp(zCmd, "rm", nCmd)==0 ){
int i;
verify_all_options();
db_begin_transaction();
for(i=3; i<g.argc; i++){
db_multi_exec(
"UPDATE unversioned"
" SET hash=NULL, content=NULL, mtime=%lld, sz=0 WHERE name=%Q",
mtime, g.argv[i]
);
}
db_unset("uv-hash", 0);
db_end_transaction(0);
}else if( memcmp(zCmd,"sync",nCmd)==0 ){
unsigned syncFlags = unversioned_sync_flags(SYNC_UNVERSIONED);
g.argv[1] = "sync";
g.argv[2] = "--uv-noop";
sync_unversioned(syncFlags);
}else if( memcmp(zCmd, "touch", nCmd)==0 ){
int i;
verify_all_options();
db_begin_transaction();
for(i=3; i<g.argc; i++){
db_multi_exec(
"UPDATE unversioned SET mtime=%lld WHERE name=%Q",
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 |
#define SYNC_CLONE 0x0004 /* clone the repository */
#define SYNC_PRIVATE 0x0008 /* Also transfer private content */
#define SYNC_VERBOSE 0x0010 /* Extra diagnostics */
#define SYNC_RESYNC 0x0020 /* --verily */
#define SYNC_UNVERSIONED 0x0040 /* Sync unversioned content */
#define SYNC_UV_REVERT 0x0080 /* Copy server unversioned to client */
#define SYNC_FROMPARENT 0x0100 /* Pull from the parent project */
#endif
/*
** Floating-point absolute value
*/
static double fossil_fabs(double x){
return x>0.0 ? x : -x;
| > > | 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 |
#define SYNC_CLONE 0x0004 /* clone the repository */
#define SYNC_PRIVATE 0x0008 /* Also transfer private content */
#define SYNC_VERBOSE 0x0010 /* Extra diagnostics */
#define SYNC_RESYNC 0x0020 /* --verily */
#define SYNC_UNVERSIONED 0x0040 /* Sync unversioned content */
#define SYNC_UV_REVERT 0x0080 /* Copy server unversioned to client */
#define SYNC_FROMPARENT 0x0100 /* Pull from the parent project */
#define SYNC_UV_TRACE 0x0200 /* Describe UV activities */
#define SYNC_UV_DRYRUN 0x0400 /* Do not actually exchange files */
#endif
/*
** Floating-point absolute value
*/
static double fossil_fabs(double x){
return x>0.0 ? x : -x;
|
| ︙ | ︙ | |||
1894 1895 1896 1897 1898 1899 1900 |
**
** This happens on the second exchange, since we do not know what files
** need to be sent until after the uvigot cards from the first exchange
** have been processed.
*/
if( uvDoPush ){
assert( (syncFlags & SYNC_UNVERSIONED)!=0 );
| | > > | 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
**
** This happens on the second exchange, since we do not know what files
** need to be sent until after the uvigot cards from the first exchange
** have been processed.
*/
if( uvDoPush ){
assert( (syncFlags & SYNC_UNVERSIONED)!=0 );
if( syncFlags & SYNC_UV_DRYRUN ){
uvDoPush = 0;
}else if( syncFlags & SYNC_UV_REVERT ){
db_multi_exec(
"DELETE FROM unversioned"
" WHERE name IN (SELECT name FROM uv_tosend);"
"DELETE FROM uv_tosend;"
);
uvDoPush = 0;
}else{
|
| ︙ | ︙ | |||
2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 |
const char *zName = blob_str(&xfer.aToken[1]);
const char *zHash = blob_str(&xfer.aToken[3]);
int iStatus;
iStatus = unversioned_status(zName, mtime, zHash);
if( (syncFlags & SYNC_UV_REVERT)!=0 ){
if( iStatus==4 ) iStatus = 2;
if( iStatus==5 ) iStatus = 1;
}
if( iStatus<=1 ){
if( zHash[0]!='-' ){
blob_appendf(xfer.pOut, "uvgimme %s\n", zName);
nCardSent++;
nUvGimmeSent++;
db_multi_exec("DELETE FROM unversioned WHERE name=%Q", zName);
| > > > > > > > > > > > > > > | 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 |
const char *zName = blob_str(&xfer.aToken[1]);
const char *zHash = blob_str(&xfer.aToken[3]);
int iStatus;
iStatus = unversioned_status(zName, mtime, zHash);
if( (syncFlags & SYNC_UV_REVERT)!=0 ){
if( iStatus==4 ) iStatus = 2;
if( iStatus==5 ) iStatus = 1;
}
if( syncFlags & (SYNC_UV_TRACE|SYNC_UV_DRYRUN) ){
const char *zMsg = 0;
switch( iStatus ){
case 0:
case 1: zMsg = "UV-PULL"; break;
case 2: zMsg = "UV-PULL-MTIME-ONLY"; break;
case 4: zMsg = "UV-PUSH-MTIME-ONLY"; break;
case 5: zMsg = "UV-PUSH"; break;
}
if( zMsg ) fossil_print("\r%s: %s\n", zMsg, zName);
if( syncFlags & SYNC_UV_DRYRUN ){
iStatus = 99; /* Prevent any changes or reply messages */
}
}
if( iStatus<=1 ){
if( zHash[0]!='-' ){
blob_appendf(xfer.pOut, "uvgimme %s\n", zName);
nCardSent++;
nUvGimmeSent++;
db_multi_exec("DELETE FROM unversioned WHERE name=%Q", zName);
|
| ︙ | ︙ |