113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
+
+
+
|
if( vid==0 ){
fossil_fatal("cannot find current version");
}
if( !nochangeFlag && db_exists("SELECT 1 FROM vmerge") ){
fossil_fatal("cannot update an uncommitted merge");
}
if( !nochangeFlag && !internalUpdate ) autosync(AUTOSYNC_PULL);
/* Create any empty directories now, as well as after the update, so changes in settings are reflected now */
ensure_empty_dirs_created();
if( internalUpdate ){
tid = internalUpdate;
}else if( g.argc>=3 ){
if( strcmp(g.argv[2], "current")==0 ){
/* If VERSION is "current", then use the same algorithm to find the
** target as if VERSION were omitted. */
|
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
|
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
** Clean up the mid and pid VFILE entries. Then commit the changes.
*/
if( nochangeFlag ){
db_end_transaction(1); /* With --nochange, rollback changes */
}else{
ensure_empty_dirs_created();
if( g.argc<=3 ){
/* All files updated. Shift the current checkout to the target. */
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
checkout_set_all_exe(vid);
manifest_to_disk(tid);
db_lset_int("checkout", tid);
}else{
/* A subset of files have been checked out. Keep the current
** checkout unchanged. */
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
}
if( !internalUpdate ) undo_finish();
db_end_transaction(0);
}
}
/*
** Make sure empty directories are created
*/
void ensure_empty_dirs_created()
{
/* Make empty directories? */
char *zEmptyDirs = db_get_versionable_setting("empty-dirs", 0);
if( zEmptyDirs!=0 ){
Blob dirsList, line;
blob_zero(&dirsList);
blob_init(&dirsList, zEmptyDirs, strlen(zEmptyDirs));
while( blob_line(&dirsList, &line) ){
if( blob_buffer(&line)[0]=='#' ) continue;
Blob dirName;
int l = blob_token(&line, &dirName);
if(l > 0) {
/* Try and create the directory */
if( file_mkdir(blob_str(&dirName), 0)!=0 ) {
fossil_warning("couldn't create empty-dir %s", blob_str(&dirName));
}
}
}
}
}
/*
** Get the contents of a file within the checking "revision". If
** revision==NULL then get the file content for the current checkout.
*/
int historical_version_of_file(
|