Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Make stash_apply handle new files and put them in an ADDED state. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | stash_add |
| Files: | files | file ages | folders |
| SHA1: |
c2d748ae2cbc03dca994292c1f0965ee |
| User & Date: | andybradford 2014-03-12 04:08:46.577 |
Context
|
2014-03-12
| ||
| 04:12 | Accidentally removed a newline with vi's shift-j. No change in functionality. ... (Closed-Leaf check-in: ef27b0059a user: andybradford tags: stash_add) | |
| 04:08 | Make stash_apply handle new files and put them in an ADDED state. ... (check-in: c2d748ae2c user: andybradford tags: stash_add) | |
|
2014-03-11
| ||
| 23:34 | Always define variables at block start ... (check-in: 1c9e023382 user: jan.nijtmans tags: trunk) | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
690 691 692 693 694 695 696 |
const char *zFrom = db_column_text(&q, 0);
const char *zTo = db_column_text(&q, 1);
mv_one_file(vid, zFrom, zTo);
}
db_finalize(&q);
db_end_transaction(0);
}
| > > > > > > > > | 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
const char *zFrom = db_column_text(&q, 0);
const char *zTo = db_column_text(&q, 1);
mv_one_file(vid, zFrom, zTo);
}
db_finalize(&q);
db_end_transaction(0);
}
/*
** Function for stash_apply to be able to restore a file and indicate
** newly ADDED state.
*/
int stash_add_files_in_sfile(int vid){
return add_files_in_sfile(vid);
}
|
Changes to src/stash.c.
| ︙ | ︙ | |||
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
return stashid;
}
/*
** Apply a stash to the current check-out.
*/
static void stash_apply(int stashid, int nConflict){
Stmt q;
db_prepare(&q,
"SELECT rid, isRemoved, isExec, isLink, origname, newname, delta"
" FROM stashfile WHERE stashid=%d",
stashid
);
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
int isRemoved = db_column_int(&q, 1);
int isExec = db_column_int(&q, 2);
int isLink = db_column_int(&q, 3);
const char *zOrig = db_column_text(&q, 4);
const char *zNew = db_column_text(&q, 5);
char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
Blob delta;
undo_save(zNew);
blob_zero(&delta);
if( rid==0 ){
db_ephemeral_blob(&q, 6, &delta);
blob_write_to_file(&delta, zNPath);
file_wd_setexe(zNPath, isExec);
| > > > > > < < | | 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 |
return stashid;
}
/*
** Apply a stash to the current check-out.
*/
static void stash_apply(int stashid, int nConflict){
int vid;
Stmt q;
db_prepare(&q,
"SELECT rid, isRemoved, isExec, isLink, origname, newname, delta"
" FROM stashfile WHERE stashid=%d",
stashid
);
vid = db_lget_int("checkout",0);
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
filename_collation());
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
int isRemoved = db_column_int(&q, 1);
int isExec = db_column_int(&q, 2);
int isLink = db_column_int(&q, 3);
const char *zOrig = db_column_text(&q, 4);
const char *zNew = db_column_text(&q, 5);
char *zOPath = mprintf("%s%s", g.zLocalRoot, zOrig);
char *zNPath = mprintf("%s%s", g.zLocalRoot, zNew);
Blob delta;
undo_save(zNew);
blob_zero(&delta);
if( rid==0 ){
db_multi_exec("INSERT OR IGNORE INTO sfile(x) VALUES(%Q)", zNew);
db_ephemeral_blob(&q, 6, &delta);
blob_write_to_file(&delta, zNPath);
file_wd_setexe(zNPath, isExec);
}else if( isRemoved ){
fossil_print("DELETE %s\n", zOrig);
file_delete(zOPath);
}else{
Blob a, b, out, disk; int isNewLink = file_wd_islink(zOPath);
db_ephemeral_blob(&q, 6, &delta);
if( isNewLink ){
blob_read_link(&disk, zOPath);
}else{
blob_read_from_file(&disk, zOPath);
}
content_get(rid, &a);
|
| ︙ | ︙ | |||
274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
}
blob_reset(&delta);
if( fossil_strcmp(zOrig,zNew)!=0 ){
undo_save(zOrig);
file_delete(zOPath);
}
}
db_finalize(&q);
if( nConflict ){
fossil_print(
"WARNING: %d merge conflicts - see messages above for details.\n",
nConflict);
}
}
| > | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
}
blob_reset(&delta);
if( fossil_strcmp(zOrig,zNew)!=0 ){
undo_save(zOrig);
file_delete(zOPath);
}
}
stash_add_files_in_sfile(vid);
db_finalize(&q);
if( nConflict ){
fossil_print(
"WARNING: %d merge conflicts - see messages above for details.\n",
nConflict);
}
}
|
| ︙ | ︙ |