Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Enchance the "revert" command so that it reverts all changes when no arguments are given. It also prints a message saying that "undo" is available to undo the revert. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
eaef1a77cc2f1145215c410cb984d0ed |
| User & Date: | drh 2010-01-14 16:17:48.000 |
Context
|
2010-01-18
| ||
| 21:46 | Remove some weird control character that somehow snuck into the [/doc/tip/www/theory1.wiki] document. check-in: d8aa59fc17 user: drh tags: trunk | |
|
2010-01-14
| ||
| 16:17 | Enchance the "revert" command so that it reverts all changes when no arguments are given. It also prints a message saying that "undo" is available to undo the revert. check-in: eaef1a77cc user: drh tags: trunk | |
| 15:37 | Fix a typo in the [/doc/tip/www/theory1.wiki] documentation page. Ticket [e77e876caf316cc5]. check-in: 81b0597fcd user: drh tags: trunk | |
Changes
Changes to src/update.c.
| ︙ | ︙ | |||
346 347 348 349 350 351 352 |
** the version associated with baseline REVISION if the -r flag
** appears.
**
** If a file is reverted accidently, it can be restored using
** the "fossil undo" command.
*/
void revert_cmd(void){
| | < > | | > > > > < > | > | | > > | > > > > > > > > > > > > > > > | < | > | | | > < < > > | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 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 419 420 421 422 423 424 425 |
** the version associated with baseline REVISION if the -r flag
** appears.
**
** If a file is reverted accidently, it can be restored using
** the "fossil undo" command.
*/
void revert_cmd(void){
const char *zFile;
const char *zRevision;
Blob record;
int i;
int errCode;
int rid = 0;
Stmt q;
zRevision = find_option("revision", "r", 1);
verify_all_options();
if( g.argc<2 ){
usage("?OPTIONS? [FILE] ...");
}
if( zRevision && g.argc<3 ){
fossil_fatal("the --revision option does not work for the entire tree");
}
db_must_be_within_tree();
db_begin_transaction();
undo_begin();
db_multi_exec("CREATE TEMP TABLE torevert(name UNIQUE);");
if( g.argc>2 ){
for(i=2; i<g.argc; i++){
Blob fname;
zFile = mprintf("%/", g.argv[i]);
file_tree_name(zFile, &fname, 1);
db_multi_exec("REPLACE INTO torevert VALUES(%B)", &fname);
blob_reset(&fname);
}
}else{
int vid;
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, 0);
db_multi_exec(
"INSERT INTO torevert "
"SELECT pathname"
" FROM vfile "
" WHERE chnged OR deleted OR rid=0 OR pathname!=origname"
);
}
blob_zero(&record);
db_prepare(&q, "SELECT name FROM torevert");
while( db_step(&q)==SQLITE_ROW ){
zFile = db_column_text(&q, 0);
if( zRevision!=0 ){
errCode = historical_version_of_file(zRevision, zFile, &record, 2);
}else{
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%Q", zFile);
if( rid==0 ){
errCode = 2;
}else{
content_get(rid, &record);
errCode = 0;
}
}
if( errCode==2 ){
fossil_warning("file not in repository: %s", zFile);
}else{
char *zFull = mprintf("%//%/", g.zLocalRoot, zFile);
undo_save(zFile);
blob_write_to_file(&record, zFull);
printf("REVERTED: %s\n", zFile);
free(zFull);
}
blob_reset(&record);
}
db_finalize(&q);
undo_finish();
db_end_transaction(0);
printf("\"fossil undo\" is available to undo the changes shown above.\n");
}
|