| | @@ -24,12 +24,13 @@ |
| 24 | 24 | /* |
| 25 | 25 | ** Possible return values from the undo_maybe_save() routine. |
| 26 | 26 | */ |
| 27 | 27 | #define UNDO_NONE (0) /* Placeholder only used to initialize vars. */ |
| 28 | 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. */ |
| 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. */ |
| 31 | 32 | #endif |
| 32 | 33 | |
| 33 | 34 | /* |
| 34 | 35 | ** Undo the change to the file zPathname. zPathname is the pathname |
| 35 | 36 | ** of the file relative to the root of the repository. If redoFlag is |
| | @@ -269,12 +270,12 @@ |
| 269 | 270 | ** Save the current content of the file zPathname so that it |
| 270 | 271 | ** will be undoable. The name is relative to the root of the |
| 271 | 272 | ** tree. |
| 272 | 273 | */ |
| 273 | 274 | 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 ){ |
| 276 | 277 | fossil_panic("failed to save undo information for path: %s", |
| 277 | 278 | zPathname); |
| 278 | 279 | } |
| 279 | 280 | } |
| 280 | 281 | |
| | @@ -292,10 +293,15 @@ |
| 292 | 293 | ** |
| 293 | 294 | ** The return value of this function will always be one of the |
| 294 | 295 | ** following codes: |
| 295 | 296 | ** |
| 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. |
| 297 | 303 | ** |
| 298 | 304 | ** UNDO_INACTIVE: The specified file was NOT saved, because the |
| 299 | 305 | ** "undo subsystem" is not active. This error |
| 300 | 306 | ** may indicate that a call to undo_begin() is |
| 301 | 307 | ** missing. |
| | @@ -309,10 +315,11 @@ |
| 309 | 315 | int undo_maybe_save(const char *zPathname, i64 limit){ |
| 310 | 316 | char *zFullname; |
| 311 | 317 | i64 size; |
| 312 | 318 | int result; |
| 313 | 319 | |
| 320 | + if( undoDisable ) return UNDO_DISABLED; |
| 314 | 321 | if( !undoActive ) return UNDO_INACTIVE; |
| 315 | 322 | zFullname = mprintf("%s%s", g.zLocalRoot, zPathname); |
| 316 | 323 | size = file_wd_size(zFullname); |
| 317 | 324 | if( limit<0 || size<=limit ){ |
| 318 | 325 | int existsFlag = (size>=0); |
| | @@ -356,10 +363,11 @@ |
| 356 | 363 | static char zRc[32]; |
| 357 | 364 | |
| 358 | 365 | switch( rc ){ |
| 359 | 366 | case UNDO_NONE: return "undo is disabled for this operation"; |
| 360 | 367 | case UNDO_SAVED_OK: return "the save operation was successful"; |
| 368 | + case UNDO_DISABLED: return "the undo subsystem is disabled"; |
| 361 | 369 | case UNDO_INACTIVE: return "the undo subsystem is inactive"; |
| 362 | 370 | case UNDO_TOOBIG: return "the file is too big"; |
| 363 | 371 | default: { |
| 364 | 372 | sqlite3_snprintf(sizeof(zRc), zRc, "of error code %d", rc); |
| 365 | 373 | } |
| 366 | 374 | |