141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
-
+
+
|
"CREATE TEMP TABLE undo_vmerge_2 AS SELECT * FROM vmerge;"
"DELETE FROM vmerge;"
"INSERT INTO vmerge SELECT * FROM undo_vmerge;"
"DELETE FROM undo_vmerge;"
"INSERT INTO undo_vmerge SELECT * FROM undo_vmerge_2;"
"DROP TABLE undo_vmerge_2;"
);
if(db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='undo_stash'", zDb) ){
if(db_exists("SELECT 1 FROM \"%w\".sqlite_master"
" WHERE name='undo_stash'", zDb) ){
if( redoFlag ){
db_multi_exec(
"DELETE FROM stash WHERE stashid IN (SELECT stashid FROM undo_stash);"
"DELETE FROM stashfile"
" WHERE stashid NOT IN (SELECT stashid FROM stash);"
);
}else{
|
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
-
+
|
static const char zSql[] =
@ DROP TABLE IF EXISTS undo;
@ DROP TABLE IF EXISTS undo_vfile;
@ DROP TABLE IF EXISTS undo_vmerge;
@ DROP TABLE IF EXISTS undo_stash;
@ DROP TABLE IF EXISTS undo_stashfile;
;
db_multi_exec(zSql);
db_multi_exec(zSql /*works-like:""*/);
db_lset_int("undo_available", 0);
db_lset_int("undo_checkout", 0);
}
/*
** The following variable stores the original command-line of the
** command that is a candidate to be undone.
|
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
|
-
+
-
-
+
+
-
+
|
/*
** Begin capturing a snapshot that can be undone.
*/
void undo_begin(void){
int cid;
const char *zDb = db_name("localdb");
static const char zSql[] =
@ CREATE TABLE %s.undo(
@ CREATE TABLE "%w".undo(
@ pathname TEXT UNIQUE, -- Name of the file
@ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
@ existsflag BOOLEAN, -- True if the file exists
@ isExe BOOLEAN, -- True if the file is executable
@ isLink BOOLEAN, -- True if the file is symlink
@ content BLOB -- Saved content
@ );
@ CREATE TABLE %s.undo_vfile AS SELECT * FROM vfile;
@ CREATE TABLE %s.undo_vmerge AS SELECT * FROM vmerge;
@ CREATE TABLE "%w".undo_vfile AS SELECT * FROM vfile;
@ CREATE TABLE "%w".undo_vmerge AS SELECT * FROM vmerge;
;
if( undoDisable ) return;
undo_reset();
db_multi_exec(zSql, zDb, zDb, zDb);
db_multi_exec(zSql/*works-like:"%w,%w,%w"*/, zDb, zDb, zDb);
cid = db_lget_int("checkout", 0);
db_lset_int("undo_checkout", cid);
db_lset_int("undo_available", 1);
db_lset("undo_cmdline", undoCmd);
undoActive = 1;
}
|
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
-
+
-
+
|
/*
** Make the current state of stashid undoable.
*/
void undo_save_stash(int stashid){
const char *zDb = db_name("localdb");
db_multi_exec(
"CREATE TABLE IF NOT EXISTS %s.undo_stash"
"CREATE TABLE IF NOT EXISTS \"%w\".undo_stash"
" AS SELECT * FROM stash WHERE 0;"
"INSERT INTO undo_stash"
" SELECT * FROM stash WHERE stashid=%d;",
zDb, stashid
);
db_multi_exec(
"CREATE TABLE IF NOT EXISTS %s.undo_stashfile"
"CREATE TABLE IF NOT EXISTS \"%w\".undo_stashfile"
" AS SELECT * FROM stashfile WHERE 0;"
"INSERT INTO undo_stashfile"
" SELECT * FROM stashfile WHERE stashid=%d;",
zDb, stashid
);
}
|