| ︙ | | |
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
|
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
|
-
+
-
-
+
-
+
+
+
+
+
+
|
" AND ox.rid=ix.rid)",
TAG_BRANCH, zBrName, TAG_CLOSED
);
}
/*
** Implementation of (branch close) subcommand. nStartAtArg is the
** g.argv index to start reading branch names. If fDryRun is true then
** g.argv index to start reading branch names. Fails fatally on error.
** the change is run in dry-run mode. Fails fatally on error.
*/
static void branch_cmd_close(int nStartAtArg, int fVerbose,
static void branch_cmd_close(int nStartAtArg){
int fDryRun){
int argPos = nStartAtArg; /* g.argv pos with first branch name */
Blob manifest = empty_blob; /* Control artifact */
Stmt q = empty_Stmt;
int nQueued = 0; /* # of branches queued for closing */
char * zUuid = 0; /* Resolved branch UUID. */
const int fVerbose = find_option("verbose","v",0)!=0;
const int fDryRun = find_option("dry-run","n",0)!=0;
const char *zDateOvrd = find_option("date-override",0,1);
const char *zUserOvrd = find_option("user-override",0,1);
int doRollback = fDryRun!=0; /* Roll back transaction if true */
verify_all_options();
db_begin_transaction();
db_multi_exec("CREATE TEMP TABLE brclose("
"rid INTEGER UNIQUE ON CONFLICT IGNORE"
")");
db_prepare(&q, "INSERT INTO brclose(rid) VALUES(:rid)");
for( ; argPos < g.argc; fossil_free(zUuid), ++argPos ){
const char * zBranch = g.argv[argPos];
|
| ︙ | | |
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
|
-
+
+
-
+
+
|
}
db_finalize(&q);
if(!nQueued){
fossil_warning("No branches queued for closing. Nothing to do.");
doRollback = 1;
goto br_close_end;
}
blob_appendf(&manifest, "D %z\n", date_in_standard_format("now"));
blob_appendf(&manifest, "D %z\n",
date_in_standard_format( zDateOvrd ? zDateOvrd : "now"));
db_prepare(&q, "SELECT uuid FROM blob WHERE rid IN brclose");
while(SQLITE_ROW==db_step(&q)){
const char * zHash = db_column_text(&q, 0);
blob_appendf(&manifest, "T +closed %s\n", zHash);
}
db_finalize(&q);
user_select();
blob_appendf(&manifest, "U %F\n", login_name());
blob_appendf(&manifest, "U %F\n",
zUserOvrd ? zUserOvrd : login_name());
{ /* Z-card and save artifact */
int newRid;
Blob cksum = empty_blob;
md5sum_blob(&manifest, &cksum);
blob_appendf(&manifest, "Z %b\n", &cksum);
blob_reset(&cksum);
if(fDryRun && fVerbose){
|
| ︙ | | |
485
486
487
488
489
490
491
492
493
494
495
496
497
498
|
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
|
+
+
|
** Close one or more branches by adding the "closed" tag
** to them. It accepts arbitrary unambiguous symbolic names but
** will only resolve checkin names and skips any which resolve
** to non-leaf or closed checkins. Options:
** -n|--dry-run do not commit changes and dump artifact
** to stdout
** -v|--verbose output more information
** --date-override DATE DATE to use instead of 'now'
** --user-override USER USER to use instead of the current default
**
** Options valid for all subcommands:
**
** -R|--repository REPO Run commands on repository REPO
*/
void branch_cmd(void){
int n;
|
| ︙ | | |
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
|
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
|
-
-
-
-
+
|
int isCur = zCurrent!=0 && fossil_strcmp(zCurrent,zBr)==0;
fossil_print("%s%s\n", (isCur ? "* " : " "), zBr);
}
db_finalize(&q);
}else if( strncmp(zCmd,"new",n)==0 ){
branch_new();
}else if( strncmp(zCmd,"close",5)==0 ){
const int fDryRun = find_option("dry-run","n",0)!=0;
const int fVerbose = find_option("verbose","v",0)!=0;
verify_all_options();
if(g.argc<4){
usage("branch close branch-name(s)...");
}
branch_cmd_close(3, fVerbose, fDryRun);
branch_cmd_close(3);
}else{
fossil_fatal("branch subcommand should be one of: "
"close current info list ls new");
}
}
/*
|
| ︙ | | |