21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <assert.h>
/*
** SQL code to implement the tables needed by the stash.
*/
static const char zStashInit[] =
@ CREATE TABLE IF NOT EXISTS %s.stash(
@ stashid INTEGER PRIMARY KEY, -- Unique stash identifier
@ vid INTEGER, -- The baseline check-out for this stash
@ comment TEXT, -- Comment for this stash. Or NULL
@ ctime TIMESTAMP -- When the stash was created
@ );
@ CREATE TABLE IF NOT EXISTS %s.stashfile(
@ stashid INTEGER REFERENCES stash, -- Stash that contains this file
@ rid INTEGER, -- Baseline content in BLOB table or 0.
@ isAdded BOOLEAN, -- True if this is an added file
@ isRemoved BOOLEAN, -- True if this file is deleted
@ isExec BOOLEAN, -- True if file is executable
@ isLink BOOLEAN, -- True if file is a symlink
@ origname TEXT, -- Original filename
|
|
|
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <assert.h>
/*
** SQL code to implement the tables needed by the stash.
*/
static const char zStashInit[] =
@ CREATE TABLE IF NOT EXISTS "%w".stash(
@ stashid INTEGER PRIMARY KEY, -- Unique stash identifier
@ vid INTEGER, -- The baseline check-out for this stash
@ comment TEXT, -- Comment for this stash. Or NULL
@ ctime TIMESTAMP -- When the stash was created
@ );
@ CREATE TABLE IF NOT EXISTS "%w".stashfile(
@ stashid INTEGER REFERENCES stash, -- Stash that contains this file
@ rid INTEGER, -- Baseline content in BLOB table or 0.
@ isAdded BOOLEAN, -- True if this is an added file
@ isRemoved BOOLEAN, -- True if this file is deleted
@ isExec BOOLEAN, -- True if file is executable
@ isLink BOOLEAN, -- True if file is a symlink
@ origname TEXT, -- Original filename
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
Stmt q; /* Query against the vfile table */
Stmt ins; /* Insert statement */
zFile = mprintf("%/", zFName);
file_tree_name(zFile, &fname, 1);
zTreename = blob_str(&fname);
blob_zero(&sql);
blob_appendf(&sql,
"SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)"
" FROM vfile"
" WHERE vid=%d AND (chnged OR deleted OR origname NOT NULL OR mrid==0)",
vid
);
if( fossil_strcmp(zTreename,".")!=0 ){
blob_appendf(&sql,
" AND (pathname GLOB '%q/*' OR origname GLOB '%q/*'"
" OR pathname=%Q OR origname=%Q)",
zTreename, zTreename, zTreename, zTreename
);
}
db_prepare(&q, blob_str(&sql));
blob_reset(&sql);
db_prepare(&ins,
"INSERT INTO stashfile(stashid, rid, isAdded, isRemoved, isExec, isLink,"
"origname, newname, delta)"
"VALUES(%d,:rid,:isadd,:isrm,:isexe,:islink,:orig,:new,:content)",
stashid
);
|
|
|
|
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
Stmt q; /* Query against the vfile table */
Stmt ins; /* Insert statement */
zFile = mprintf("%/", zFName);
file_tree_name(zFile, &fname, 1);
zTreename = blob_str(&fname);
blob_zero(&sql);
blob_append_sql(&sql,
"SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)"
" FROM vfile"
" WHERE vid=%d AND (chnged OR deleted OR origname NOT NULL OR mrid==0)",
vid
);
if( fossil_strcmp(zTreename,".")!=0 ){
blob_append_sql(&sql,
" AND (pathname GLOB '%q/*' OR origname GLOB '%q/*'"
" OR pathname=%Q OR origname=%Q)",
zTreename, zTreename, zTreename, zTreename
);
}
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
db_prepare(&ins,
"INSERT INTO stashfile(stashid, rid, isAdded, isRemoved, isExec, isLink,"
"origname, newname, delta)"
"VALUES(%d,:rid,:isadd,:isrm,:isexe,:islink,:orig,:new,:content)",
stashid
);
|
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
int nCmd;
int stashid = 0;
undo_capture_command_line();
db_must_be_within_tree();
db_open_config(0);
db_begin_transaction();
zDb = db_name("localdb");
db_multi_exec(zStashInit, zDb, zDb);
if( g.argc<=2 ){
zCmd = "save";
}else{
zCmd = g.argv[2];
}
nCmd = strlen(zCmd);
if( memcmp(zCmd, "save", nCmd)==0 ){
|
|
|
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
|
int nCmd;
int stashid = 0;
undo_capture_command_line();
db_must_be_within_tree();
db_open_config(0);
db_begin_transaction();
zDb = db_name("localdb");
db_multi_exec(zStashInit /*works-like:"%w,%w"*/, zDb, zDb);
if( g.argc<=2 ){
zCmd = "save";
}else{
zCmd = g.argv[2];
}
nCmd = strlen(zCmd);
if( memcmp(zCmd, "save", nCmd)==0 ){
|