Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | branch close: added --user/date-override options, per forum feedback. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | branch-close-subcommand |
| Files: | files | file ages | folders |
| SHA3-256: |
94764e962c098ee4a61e55ceed1fc029 |
| User & Date: | stephan 2021-07-22 07:47:31.698 |
Context
|
2021-07-22
| ||
| 23:21 | Internal refactoring of (branch close) subcommand in prep for pending addition of similar (branch hide/unhide) feature. ... (check-in: 9baa9768f6 user: stephan tags: branch-close-subcommand) | |
| 07:47 | branch close: added --user/date-override options, per forum feedback. ... (check-in: 94764e962c user: stephan tags: branch-close-subcommand) | |
| 06:25 | branch close: minor doc and style cleanups. Delay output of control artifact in dry-run mode until after Z-card is calculated. Only show new dry-run artifact in --verbose mode. ... (check-in: 25197505b1 user: stephan tags: branch-close-subcommand) | |
Changes
Changes to src/branch.c.
| ︙ | ︙ | |||
344 345 346 347 348 349 350 |
" AND ox.rid=ix.rid)",
TAG_BRANCH, zBrName, TAG_CLOSED
);
}
/*
** Implementation of (branch close) subcommand. nStartAtArg is the
| | < | < > > > > > > | 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. Fails fatally on error.
*/
static void branch_cmd_close(int nStartAtArg){
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 |
}
db_finalize(&q);
if(!nQueued){
fossil_warning("No branches queued for closing. Nothing to do.");
doRollback = 1;
goto br_close_end;
}
| | > | > | 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( 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",
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 |
** 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
**
** Options valid for all subcommands:
**
** -R|--repository REPO Run commands on repository REPO
*/
void branch_cmd(void){
int n;
| > > | 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 |
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 ){
| < < < | | 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 ){
if(g.argc<4){
usage("branch close branch-name(s)...");
}
branch_cmd_close(3);
}else{
fossil_fatal("branch subcommand should be one of: "
"close current info list ls new");
}
}
/*
|
| ︙ | ︙ |