18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
** This file implements the undo/redo functionality.
*/
#include "config.h"
#include "undo.h"
#if INTERFACE
/*
** Return values from the undo_maybe_save() routine.
*/
#define UNDO_SAVED_OK (0) /* The specified file was saved succesfully. */
#define UNDO_INACTIVE (1) /* File not saved, subsystem is not active. */
#define UNDO_TOOBIG (2) /* File not saved, it exceeded a size limit. */
#endif
/*
** Undo the change to the file zPathname. zPathname is the pathname
** of the file relative to the root of the repository. If redoFlag is
** true the redo a change. If there is nothing to undo (or redo) then
** this routine is a noop.
|
|
>
|
|
|
|
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
** This file implements the undo/redo functionality.
*/
#include "config.h"
#include "undo.h"
#if INTERFACE
/*
** Possible return values from the undo_maybe_save() routine.
*/
#define UNDO_NONE (0) /* Placeholder only used to initialize vars. */
#define UNDO_SAVED_OK (1) /* The specified file was saved succesfully. */
#define UNDO_INACTIVE (2) /* File not saved, subsystem is not active. */
#define UNDO_TOOBIG (3) /* File not saved, it exceeded a size limit. */
#endif
/*
** Undo the change to the file zPathname. zPathname is the pathname
** of the file relative to the root of the repository. If redoFlag is
** true the redo a change. If there is nothing to undo (or redo) then
** this routine is a noop.
|
340
341
342
343
344
345
346
347
348
349
350
351
352
353
|
result = UNDO_SAVED_OK;
}else{
result = UNDO_TOOBIG;
}
free(zFullname);
return result;
}
/*
** Make the current state of stashid undoable.
*/
void undo_save_stash(int stashid){
const char *zDb = db_name("localdb");
db_multi_exec(
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
341
342
343
344
345
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
|
result = UNDO_SAVED_OK;
}else{
result = UNDO_TOOBIG;
}
free(zFullname);
return result;
}
/*
** Returns an error message for the undo_maybe_save() return code.
** Currently, this function assumes that the caller is using the
** returned error message in a context prefixed with "because".
*/
const char *undo_save_message(int rc){
static char zRc[32];
switch( rc ){
case UNDO_NONE: return "undo is disabled for this operation";
case UNDO_SAVED_OK: return "the save operation was successful";
case UNDO_INACTIVE: return "the undo subsystem is inactive";
case UNDO_TOOBIG: return "the file is too big";
default: {
sqlite3_snprintf(sizeof(zRc), zRc, "of error code %d", rc);
}
}
return zRc;
}
/*
** Make the current state of stashid undoable.
*/
void undo_save_stash(int stashid){
const char *zDb = db_name("localdb");
db_multi_exec(
|