︙ | | | ︙ | |
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#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.
|
>
|
|
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#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_DISABLED (2) /* File not saved, subsystem is disabled. */
#define UNDO_INACTIVE (3) /* File not saved, subsystem is not active. */
#define UNDO_TOOBIG (4) /* 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.
|
︙ | | | ︙ | |
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
/*
** Save the current content of the file zPathname so that it
** will be undoable. The name is relative to the root of the
** tree.
*/
void undo_save(const char *zPathname){
int rc = undo_maybe_save(zPathname, -1);
if( rc!=UNDO_SAVED_OK && rc!=UNDO_INACTIVE ){
fossil_panic("failed to save undo information for path: %s",
zPathname);
}
}
/*
** Possibly save the current content of the file zPathname so
|
>
|
<
|
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
/*
** Save the current content of the file zPathname so that it
** will be undoable. The name is relative to the root of the
** tree.
*/
void undo_save(const char *zPathname){
if( undoDisable ) return;
if( undo_maybe_save(zPathname, -1)!=UNDO_SAVED_OK ){
fossil_panic("failed to save undo information for path: %s",
zPathname);
}
}
/*
** Possibly save the current content of the file zPathname so
|
︙ | | | ︙ | |
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
** value less than zero, call the undo_save()
** function instead.
**
** The return value of this function will always be one of the
** following codes:
**
** UNDO_SAVED_OK: The specified file was saved succesfully.
**
** UNDO_INACTIVE: The specified file was NOT saved, because the
** "undo subsystem" is not active. This error
** may indicate that a call to undo_begin() is
** missing.
**
** UNDO_TOOBIG: The specified file was NOT saved, because it
** exceeded the specified size limit. It is
** impossible for this value to be returned if
** the specified size limit is less than zero
** (i.e. unlimited).
*/
int undo_maybe_save(const char *zPathname, i64 limit){
char *zFullname;
i64 size;
int result;
if( !undoActive ) return UNDO_INACTIVE;
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
size = file_wd_size(zFullname);
if( limit<0 || size<=limit ){
int existsFlag = (size>=0);
int isLink = file_wd_islink(zFullname);
Stmt q;
|
>
>
>
>
>
>
|
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
|
** value less than zero, call the undo_save()
** function instead.
**
** The return value of this function will always be one of the
** following codes:
**
** UNDO_SAVED_OK: The specified file was saved succesfully.
**
** UNDO_DISABLED: The specified file was NOT saved, because the
** "undo subsystem" is disabled. This error may
** indicate that a call to undo_disable() was
** issued.
**
** UNDO_INACTIVE: The specified file was NOT saved, because the
** "undo subsystem" is not active. This error
** may indicate that a call to undo_begin() is
** missing.
**
** UNDO_TOOBIG: The specified file was NOT saved, because it
** exceeded the specified size limit. It is
** impossible for this value to be returned if
** the specified size limit is less than zero
** (i.e. unlimited).
*/
int undo_maybe_save(const char *zPathname, i64 limit){
char *zFullname;
i64 size;
int result;
if( undoDisable ) return UNDO_DISABLED;
if( !undoActive ) return UNDO_INACTIVE;
zFullname = mprintf("%s%s", g.zLocalRoot, zPathname);
size = file_wd_size(zFullname);
if( limit<0 || size<=limit ){
int existsFlag = (size>=0);
int isLink = file_wd_islink(zFullname);
Stmt q;
|
︙ | | | ︙ | |
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
*/
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;
|
>
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
*/
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_DISABLED: return "the undo subsystem is disabled";
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;
|
︙ | | | ︙ | |