Fossil SCM

Fix the stash so that it remembers added files and readds them when the stash is applied.

drh 2014-03-13 11:58 trunk merge
Commit db052aa4c6bc6c642c88edf714d086505945878e
2 files changed +8 +6 -1
+8
--- src/add.c
+++ src/add.c
@@ -692,5 +692,13 @@
692692
mv_one_file(vid, zFrom, zTo);
693693
}
694694
db_finalize(&q);
695695
db_end_transaction(0);
696696
}
697
+
698
+/*
699
+** Function for stash_apply to be able to restore a file and indicate
700
+** newly ADDED state.
701
+*/
702
+int stash_add_files_in_sfile(int vid){
703
+ return add_files_in_sfile(vid);
704
+}
697705
--- src/add.c
+++ src/add.c
@@ -692,5 +692,13 @@
692 mv_one_file(vid, zFrom, zTo);
693 }
694 db_finalize(&q);
695 db_end_transaction(0);
696 }
 
 
 
 
 
 
 
 
697
--- src/add.c
+++ src/add.c
@@ -692,5 +692,13 @@
692 mv_one_file(vid, zFrom, zTo);
693 }
694 db_finalize(&q);
695 db_end_transaction(0);
696 }
697
698 /*
699 ** Function for stash_apply to be able to restore a file and indicate
700 ** newly ADDED state.
701 */
702 int stash_add_files_in_sfile(int vid){
703 return add_files_in_sfile(vid);
704 }
705
+6 -1
--- src/stash.c
+++ src/stash.c
@@ -199,16 +199,20 @@
199199
200200
/*
201201
** Apply a stash to the current check-out.
202202
*/
203203
static void stash_apply(int stashid, int nConflict){
204
+ int vid;
204205
Stmt q;
205206
db_prepare(&q,
206207
"SELECT rid, isRemoved, isExec, isLink, origname, newname, delta"
207208
" FROM stashfile WHERE stashid=%d",
208209
stashid
209210
);
211
+ vid = db_lget_int("checkout",0);
212
+ db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
213
+ filename_collation());
210214
while( db_step(&q)==SQLITE_ROW ){
211215
int rid = db_column_int(&q, 0);
212216
int isRemoved = db_column_int(&q, 1);
213217
int isExec = db_column_int(&q, 2);
214218
int isLink = db_column_int(&q, 3);
@@ -218,14 +222,14 @@
218222
char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
219223
Blob delta;
220224
undo_save(zNew);
221225
blob_zero(&delta);
222226
if( rid==0 ){
227
+ db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew);
223228
db_ephemeral_blob(&q, 6, &delta);
224229
blob_write_to_file(&delta, zNPath);
225230
file_wd_setexe(zNPath, isExec);
226
- fossil_print("ADD %s\n", zNew);
227231
}else if( isRemoved ){
228232
fossil_print("DELETE %s\n", zOrig);
229233
file_delete(zOPath);
230234
}else{
231235
Blob a, b, out, disk;
@@ -276,10 +280,11 @@
276280
if( fossil_strcmp(zOrig,zNew)!=0 ){
277281
undo_save(zOrig);
278282
file_delete(zOPath);
279283
}
280284
}
285
+ stash_add_files_in_sfile(vid);
281286
db_finalize(&q);
282287
if( nConflict ){
283288
fossil_print(
284289
"WARNING: %d merge conflicts - see messages above for details.\n",
285290
nConflict);
286291
--- src/stash.c
+++ src/stash.c
@@ -199,16 +199,20 @@
199
200 /*
201 ** Apply a stash to the current check-out.
202 */
203 static void stash_apply(int stashid, int nConflict){
 
204 Stmt q;
205 db_prepare(&q,
206 "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta"
207 " FROM stashfile WHERE stashid=%d",
208 stashid
209 );
 
 
 
210 while( db_step(&q)==SQLITE_ROW ){
211 int rid = db_column_int(&q, 0);
212 int isRemoved = db_column_int(&q, 1);
213 int isExec = db_column_int(&q, 2);
214 int isLink = db_column_int(&q, 3);
@@ -218,14 +222,14 @@
218 char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
219 Blob delta;
220 undo_save(zNew);
221 blob_zero(&delta);
222 if( rid==0 ){
 
223 db_ephemeral_blob(&q, 6, &delta);
224 blob_write_to_file(&delta, zNPath);
225 file_wd_setexe(zNPath, isExec);
226 fossil_print("ADD %s\n", zNew);
227 }else if( isRemoved ){
228 fossil_print("DELETE %s\n", zOrig);
229 file_delete(zOPath);
230 }else{
231 Blob a, b, out, disk;
@@ -276,10 +280,11 @@
276 if( fossil_strcmp(zOrig,zNew)!=0 ){
277 undo_save(zOrig);
278 file_delete(zOPath);
279 }
280 }
 
281 db_finalize(&q);
282 if( nConflict ){
283 fossil_print(
284 "WARNING: %d merge conflicts - see messages above for details.\n",
285 nConflict);
286
--- src/stash.c
+++ src/stash.c
@@ -199,16 +199,20 @@
199
200 /*
201 ** Apply a stash to the current check-out.
202 */
203 static void stash_apply(int stashid, int nConflict){
204 int vid;
205 Stmt q;
206 db_prepare(&q,
207 "SELECT rid, isRemoved, isExec, isLink, origname, newname, delta"
208 " FROM stashfile WHERE stashid=%d",
209 stashid
210 );
211 vid = db_lget_int("checkout",0);
212 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
213 filename_collation());
214 while( db_step(&q)==SQLITE_ROW ){
215 int rid = db_column_int(&q, 0);
216 int isRemoved = db_column_int(&q, 1);
217 int isExec = db_column_int(&q, 2);
218 int isLink = db_column_int(&q, 3);
@@ -218,14 +222,14 @@
222 char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
223 Blob delta;
224 undo_save(zNew);
225 blob_zero(&delta);
226 if( rid==0 ){
227 db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew);
228 db_ephemeral_blob(&q, 6, &delta);
229 blob_write_to_file(&delta, zNPath);
230 file_wd_setexe(zNPath, isExec);
 
231 }else if( isRemoved ){
232 fossil_print("DELETE %s\n", zOrig);
233 file_delete(zOPath);
234 }else{
235 Blob a, b, out, disk;
@@ -276,10 +280,11 @@
280 if( fossil_strcmp(zOrig,zNew)!=0 ){
281 undo_save(zOrig);
282 file_delete(zOPath);
283 }
284 }
285 stash_add_files_in_sfile(vid);
286 db_finalize(&q);
287 if( nConflict ){
288 fossil_print(
289 "WARNING: %d merge conflicts - see messages above for details.\n",
290 nConflict);
291

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button