Fossil SCM

Further enhancements to the 'undo' subsystem integration.

mistachkin 2015-07-15 20:15 trunk
Commit a50be7b87adcd482d2c67b3b94c0e7722883e082
--- src/stash.c
+++ src/stash.c
@@ -503,10 +503,11 @@
503503
while( db_step(&q)==SQLITE_ROW ){
504504
newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0));
505505
}
506506
db_finalize(&q);
507507
newArgv[0] = g.argv[0];
508
+ newArgv[1] = 0;
508509
g.argv = newArgv;
509510
g.argc = nFile+2;
510511
if( nFile==0 ) return;
511512
}
512513
g.argv[1] = "revert";
513514
--- src/stash.c
+++ src/stash.c
@@ -503,10 +503,11 @@
503 while( db_step(&q)==SQLITE_ROW ){
504 newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0));
505 }
506 db_finalize(&q);
507 newArgv[0] = g.argv[0];
 
508 g.argv = newArgv;
509 g.argc = nFile+2;
510 if( nFile==0 ) return;
511 }
512 g.argv[1] = "revert";
513
--- src/stash.c
+++ src/stash.c
@@ -503,10 +503,11 @@
503 while( db_step(&q)==SQLITE_ROW ){
504 newArgv[i++] = mprintf("%s%s", g.zLocalRoot, db_column_text(&q, 0));
505 }
506 db_finalize(&q);
507 newArgv[0] = g.argv[0];
508 newArgv[1] = 0;
509 g.argv = newArgv;
510 g.argc = nFile+2;
511 if( nFile==0 ) return;
512 }
513 g.argv[1] = "revert";
514
+12 -4
--- src/undo.c
+++ src/undo.c
@@ -24,12 +24,13 @@
2424
/*
2525
** Possible return values from the undo_maybe_save() routine.
2626
*/
2727
#define UNDO_NONE (0) /* Placeholder only used to initialize vars. */
2828
#define UNDO_SAVED_OK (1) /* The specified file was saved succesfully. */
29
-#define UNDO_INACTIVE (2) /* File not saved, subsystem is not active. */
30
-#define UNDO_TOOBIG (3) /* File not saved, it exceeded a size limit. */
29
+#define UNDO_DISABLED (2) /* File not saved, subsystem is disabled. */
30
+#define UNDO_INACTIVE (3) /* File not saved, subsystem is not active. */
31
+#define UNDO_TOOBIG (4) /* File not saved, it exceeded a size limit. */
3132
#endif
3233
3334
/*
3435
** Undo the change to the file zPathname. zPathname is the pathname
3536
** of the file relative to the root of the repository. If redoFlag is
@@ -269,12 +270,12 @@
269270
** Save the current content of the file zPathname so that it
270271
** will be undoable. The name is relative to the root of the
271272
** tree.
272273
*/
273274
void undo_save(const char *zPathname){
274
- int rc = undo_maybe_save(zPathname, -1);
275
- if( rc!=UNDO_SAVED_OK && rc!=UNDO_INACTIVE ){
275
+ if( undoDisable ) return;
276
+ if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){
276277
fossil_panic("failed to save undo information for path: %s",
277278
zPathname);
278279
}
279280
}
280281
@@ -292,10 +293,15 @@
292293
**
293294
** The return value of this function will always be one of the
294295
** following codes:
295296
**
296297
** UNDO_SAVED_OK: The specified file was saved succesfully.
298
+**
299
+** UNDO_DISABLED: The specified file was NOT saved, because the
300
+** "undo subsystem" is disabled. This error may
301
+** indicate that a call to undo_disable() was
302
+** issued.
297303
**
298304
** UNDO_INACTIVE: The specified file was NOT saved, because the
299305
** "undo subsystem" is not active. This error
300306
** may indicate that a call to undo_begin() is
301307
** missing.
@@ -309,10 +315,11 @@
309315
int undo_maybe_save(const char *zPathname, i64 limit){
310316
char *zFullname;
311317
i64 size;
312318
int result;
313319
320
+ if( undoDisable ) return UNDO_DISABLED;
314321
if( !undoActive ) return UNDO_INACTIVE;
315322
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
316323
size = file_wd_size(zFullname);
317324
if( limit<0 || size<=limit ){
318325
int existsFlag = (size>=0);
@@ -356,10 +363,11 @@
356363
static char zRc[32];
357364
358365
switch( rc ){
359366
case UNDO_NONE: return "undo is disabled for this operation";
360367
case UNDO_SAVED_OK: return "the save operation was successful";
368
+ case UNDO_DISABLED: return "the undo subsystem is disabled";
361369
case UNDO_INACTIVE: return "the undo subsystem is inactive";
362370
case UNDO_TOOBIG: return "the file is too big";
363371
default: {
364372
sqlite3_snprintf(sizeof(zRc), zRc, "of error code %d", rc);
365373
}
366374
--- src/undo.c
+++ src/undo.c
@@ -24,12 +24,13 @@
24 /*
25 ** Possible return values from the undo_maybe_save() routine.
26 */
27 #define UNDO_NONE (0) /* Placeholder only used to initialize vars. */
28 #define UNDO_SAVED_OK (1) /* The specified file was saved succesfully. */
29 #define UNDO_INACTIVE (2) /* File not saved, subsystem is not active. */
30 #define UNDO_TOOBIG (3) /* File not saved, it exceeded a size limit. */
 
31 #endif
32
33 /*
34 ** Undo the change to the file zPathname. zPathname is the pathname
35 ** of the file relative to the root of the repository. If redoFlag is
@@ -269,12 +270,12 @@
269 ** Save the current content of the file zPathname so that it
270 ** will be undoable. The name is relative to the root of the
271 ** tree.
272 */
273 void undo_save(const char *zPathname){
274 int rc = undo_maybe_save(zPathname, -1);
275 if( rc!=UNDO_SAVED_OK && rc!=UNDO_INACTIVE ){
276 fossil_panic("failed to save undo information for path: %s",
277 zPathname);
278 }
279 }
280
@@ -292,10 +293,15 @@
292 **
293 ** The return value of this function will always be one of the
294 ** following codes:
295 **
296 ** UNDO_SAVED_OK: The specified file was saved succesfully.
 
 
 
 
 
297 **
298 ** UNDO_INACTIVE: The specified file was NOT saved, because the
299 ** "undo subsystem" is not active. This error
300 ** may indicate that a call to undo_begin() is
301 ** missing.
@@ -309,10 +315,11 @@
309 int undo_maybe_save(const char *zPathname, i64 limit){
310 char *zFullname;
311 i64 size;
312 int result;
313
 
314 if( !undoActive ) return UNDO_INACTIVE;
315 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
316 size = file_wd_size(zFullname);
317 if( limit<0 || size<=limit ){
318 int existsFlag = (size>=0);
@@ -356,10 +363,11 @@
356 static char zRc[32];
357
358 switch( rc ){
359 case UNDO_NONE: return "undo is disabled for this operation";
360 case UNDO_SAVED_OK: return "the save operation was successful";
 
361 case UNDO_INACTIVE: return "the undo subsystem is inactive";
362 case UNDO_TOOBIG: return "the file is too big";
363 default: {
364 sqlite3_snprintf(sizeof(zRc), zRc, "of error code %d", rc);
365 }
366
--- src/undo.c
+++ src/undo.c
@@ -24,12 +24,13 @@
24 /*
25 ** Possible return values from the undo_maybe_save() routine.
26 */
27 #define UNDO_NONE (0) /* Placeholder only used to initialize vars. */
28 #define UNDO_SAVED_OK (1) /* The specified file was saved succesfully. */
29 #define UNDO_DISABLED (2) /* File not saved, subsystem is disabled. */
30 #define UNDO_INACTIVE (3) /* File not saved, subsystem is not active. */
31 #define UNDO_TOOBIG (4) /* File not saved, it exceeded a size limit. */
32 #endif
33
34 /*
35 ** Undo the change to the file zPathname. zPathname is the pathname
36 ** of the file relative to the root of the repository. If redoFlag is
@@ -269,12 +270,12 @@
270 ** Save the current content of the file zPathname so that it
271 ** will be undoable. The name is relative to the root of the
272 ** tree.
273 */
274 void undo_save(const char *zPathname){
275 if( undoDisable ) return;
276 if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){
277 fossil_panic("failed to save undo information for path: %s",
278 zPathname);
279 }
280 }
281
@@ -292,10 +293,15 @@
293 **
294 ** The return value of this function will always be one of the
295 ** following codes:
296 **
297 ** UNDO_SAVED_OK: The specified file was saved succesfully.
298 **
299 ** UNDO_DISABLED: The specified file was NOT saved, because the
300 ** "undo subsystem" is disabled. This error may
301 ** indicate that a call to undo_disable() was
302 ** issued.
303 **
304 ** UNDO_INACTIVE: The specified file was NOT saved, because the
305 ** "undo subsystem" is not active. This error
306 ** may indicate that a call to undo_begin() is
307 ** missing.
@@ -309,10 +315,11 @@
315 int undo_maybe_save(const char *zPathname, i64 limit){
316 char *zFullname;
317 i64 size;
318 int result;
319
320 if( undoDisable ) return UNDO_DISABLED;
321 if( !undoActive ) return UNDO_INACTIVE;
322 zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
323 size = file_wd_size(zFullname);
324 if( limit<0 || size<=limit ){
325 int existsFlag = (size>=0);
@@ -356,10 +363,11 @@
363 static char zRc[32];
364
365 switch( rc ){
366 case UNDO_NONE: return "undo is disabled for this operation";
367 case UNDO_SAVED_OK: return "the save operation was successful";
368 case UNDO_DISABLED: return "the undo subsystem is disabled";
369 case UNDO_INACTIVE: return "the undo subsystem is inactive";
370 case UNDO_TOOBIG: return "the file is too big";
371 default: {
372 sqlite3_snprintf(sizeof(zRc), zRc, "of error code %d", rc);
373 }
374
--- src/update.c
+++ src/update.c
@@ -738,10 +738,11 @@
738738
739739
if( g.argc>2 ){
740740
for(i=2; i<g.argc; i++){
741741
Blob fname;
742742
zFile = mprintf("%/", g.argv[i]);
743
+ blob_zero(&fname);
743744
file_tree_name(zFile, &fname, 0, 1);
744745
db_multi_exec(
745746
"REPLACE INTO torevert VALUES(%B);"
746747
"INSERT OR IGNORE INTO torevert"
747748
" SELECT pathname"
748749
--- src/update.c
+++ src/update.c
@@ -738,10 +738,11 @@
738
739 if( g.argc>2 ){
740 for(i=2; i<g.argc; i++){
741 Blob fname;
742 zFile = mprintf("%/", g.argv[i]);
 
743 file_tree_name(zFile, &fname, 0, 1);
744 db_multi_exec(
745 "REPLACE INTO torevert VALUES(%B);"
746 "INSERT OR IGNORE INTO torevert"
747 " SELECT pathname"
748
--- src/update.c
+++ src/update.c
@@ -738,10 +738,11 @@
738
739 if( g.argc>2 ){
740 for(i=2; i<g.argc; i++){
741 Blob fname;
742 zFile = mprintf("%/", g.argv[i]);
743 blob_zero(&fname);
744 file_tree_name(zFile, &fname, 0, 1);
745 db_multi_exec(
746 "REPLACE INTO torevert VALUES(%B);"
747 "INSERT OR IGNORE INTO torevert"
748 " SELECT pathname"
749

Keyboard Shortcuts

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