Fossil with Commonmark

Changes On Branch stash_add
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Changes In Branch stash_add Excluding Merge-Ins

This is equivalent to a diff from 1c9e023382 to ef27b0059a

2014-03-13
11:58
Fix the stash so that it remembers added files and readds them when the stash is applied. check-in: db052aa4c6 user: drh tags: trunk
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
23:23
For initial non-empty check-ins (without parent but with F-cards), add "Changes" section to "ci" page, except for the "patch" button (which is the only thing that doesn't work anyway) check-in: 79c90ac4a4 user: jan.nijtmans tags: trunk

Changes to src/add.c.

690
691
692
693
694
695
696








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
226
227
228
229
230
231
232
233
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







+






+
+
+













+



-







  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);
      fossil_print("ADD %s\n", zNew);
    }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);
274
275
276
277
278
279
280

281
282
283
284
285
286
287
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292







+







    }
    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);
  }
}