209
210
211
212
213
214
215
|
** Clean up the mid and pid VFILE entries. Then commit the changes.
*/
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
manifest_to_disk(tid);
db_lset_int("checkout", tid);
db_end_transaction(0);
}
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
** Clean up the mid and pid VFILE entries. Then commit the changes.
*/
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
manifest_to_disk(tid);
db_lset_int("checkout", tid);
db_end_transaction(0);
}
/*
** COMMAND: revert
**
** Usage: %fossil revert ?-yes FILE
**
** Revert to the current repository version of FILE. This
** command will confirm your operation, unless you do so
** at the command line via the -yes option.
**/
void revert_cmd(void){
const char *zFile;
Blob fname;
Blob record;
Blob ans;
int rid, yesRevert;
yesRevert = find_option("yes","y", 0)!=0;
verify_all_options();
if( g.argc<3 ){
usage("?OPTIONS FILE");
}
db_must_be_within_tree();
zFile = g.argv[g.argc-1];
if( !file_tree_name(zFile, &fname) ){
fossil_panic("unknown file: %s", zFile);
}
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B", &fname);
if( rid==0 ){
fossil_panic("no history for file: %b", &fname);
}
if( yesRevert==0 ){
char *prompt = mprintf("revert file %B? this will destroy local changes [y/N]? ",
&fname);
blob_zero(&ans);
prompt_user(prompt, &ans);
if( blob_str(&ans)[0]=='y' ){
yesRevert = 1;
}
}
if( yesRevert==1 ){
content_get(rid, &record);
blob_write_to_file(&record, blob_str(&fname));
printf("%s reverted\n", blob_str(&fname));
blob_reset(&record);
blob_reset(&fname);
}else{
printf("revert canceled\n");
}
}
|