Fossil

Check-in [05b42e6aa6]
Login

Check-in [05b42e6aa6]

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

Overview
Comment:Added (branch hide/unhide) subcommands.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | branch-close-subcommand
Files: files | file ages | folders
SHA3-256: 05b42e6aa680bf48851a936a524d66562f66a2d52bfe15807defde3edc98dee5
User & Date: stephan 2021-07-23 02:22:58.622
Context
2021-07-23
02:44
branch hide/unhide subcommands now skip over checkins which have resp. don't have the hidden tag. ... (check-in: 768f30ffb7 user: stephan tags: branch-close-subcommand)
02:22
Added (branch hide/unhide) subcommands. ... (check-in: 05b42e6aa6 user: stephan tags: branch-close-subcommand)
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)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/branch.c.
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
491
492
493












494
495
496






497
498
499
500
501
502
503
    }
  }
  db_multi_exec("DROP TABLE brcmdtag");
  blob_reset(&manifest);
  db_end_transaction(doRollback);
  return 0;
}

/*
















































** 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 */
  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);

  verify_all_options();
  db_begin_transaction();
  for( ; argPos < g.argc; fossil_free(zUuid), ++argPos ){
    const char * zBranch = g.argv[argPos];
    const int rid = name_to_uuid2(zBranch, "ci", &zUuid);
    if(0==rid){
      fossil_fatal("Cannot resolve branch name: %s", zBranch);
    }else if(rid<0){
      fossil_fatal("Ambiguous branch name: %s", zBranch);
    }else if(!is_a_leaf(rid)){




      fossil_warning("Skipping non-leaf [%s] %s", zBranch, zUuid);
      continue;
    }else if(leaf_is_closed(rid)){
      fossil_warning("Skipping closed [%s] %s", zBranch, zUuid);
      continue;
    }
    branch_cmd_tag_add(rid, "+closed");
    if(fVerbose!=0){
      fossil_print("Closing branch [%s] %s\n", zBranch, zUuid);
    }
  }
  branch_cmd_tag_finalize(fDryRun, fVerbose, zDateOvrd, zUserOvrd);
}

/*
** COMMAND: branch
**
** Usage: %fossil branch SUBCOMMAND ... ?OPTIONS?
**
** Run various subcommands to manage branches of the open repository or
** of the repository identified by the -R or --repository option.
**












** >  fossil branch current
**
**        Print the name of the branch for the current check-out






**
** >  fossil branch info BRANCH-NAME
**
**        Print information about a branch
**
** >  fossil branch list|ls ?OPTIONS? ?GLOB?
**









>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|
>












|
|
<
<
<
<
|
>
>
>
>
|


|




|













>
>
>
>
>
>
>
>
>
>
>
>



>
>
>
>
>
>







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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515




516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
    }
  }
  db_multi_exec("DROP TABLE brcmdtag");
  blob_reset(&manifest);
  db_end_transaction(doRollback);
  return 0;
}

/*
** Internal helper for branch_cmd_close() and friends. zName is a
** symbolic checkin name. Returns the blob.rid of the checkin or fails
** fatally if the name does not resolve unambiguously.  If zUuid is
** not NULL, *zUuid is set to the resolved blob.uuid and must be freed
** by the caller via fossil_free().
*/
static int branch_resolve_name(char const *zName, char **zUuid){
  const int rid = name_to_uuid2(zName, "ci", zUuid);
  if(0==rid){
    fossil_fatal("Cannot resolve name: %s", zName);
  }else if(rid<0){
    fossil_fatal("Ambiguous name: %s", zName);
  }
  return rid;
}

/*
** Implementation of (branch hide/unhide) subcommands. nStartAtArg is
** the g.argv index to start reading branch/checkin names. fHide is
** true for hiding, false for unhiding. Fails fatally on error.
*/
static void branch_cmd_hide(int nStartAtArg, int fHide){
  int argPos = nStartAtArg;    /* g.argv pos with first branch/ci name */
  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);

  verify_all_options();
  db_begin_transaction();
  for( ; argPos < g.argc; fossil_free(zUuid), ++argPos ){
    const char * zName = g.argv[argPos];
    const int rid = branch_resolve_name(zName, &zUuid);
    /* Potential TODO: check for existing 'hidden' flag and skip this
    ** entry if it already has (if fHide) or does not have (if !fHide)
    ** that tag. FWIW, /ci_edit does not do so. */
    branch_cmd_tag_add(rid, fHide ? "*hidden" : "-hidden");
    if(fVerbose!=0){
      fossil_print("%s checkin [%s] %s\n",
                   fHide ? "Hiding" : "Unhiding",
                   zName, zUuid);
    }
  }
  branch_cmd_tag_finalize(fDryRun, fVerbose, zDateOvrd, zUserOvrd);
}

/*
** Implementation of (branch close) subcommand. nStartAtArg is the
** g.argv index to start reading branch/checkin names. Fails fatally
** on error.
*/
static void branch_cmd_close(int nStartAtArg){
  int argPos = nStartAtArg;    /* g.argv pos with first branch name */
  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);

  verify_all_options();
  db_begin_transaction();
  for( ; argPos < g.argc; fossil_free(zUuid), ++argPos ){
    const char * zName = g.argv[argPos];
    const int rid = branch_resolve_name(zName, &zUuid);




    if(!is_a_leaf(rid)){
      /* This behaviour is different from /ci_edit closing, where
      ** is_a_leaf() adds a "+" tag and !is_a_leaf() adds a "*"
      ** tag. We might want to change this to match for consistency's
      ** sake. */
      fossil_warning("Skipping non-leaf [%s] %s", zName, zUuid);
      continue;
    }else if(leaf_is_closed(rid)){
      fossil_warning("Skipping closed [%s] %s", zName, zUuid);
      continue;
    }
    branch_cmd_tag_add(rid, "+closed");
    if(fVerbose!=0){
      fossil_print("Closing branch [%s] %s\n", zName, zUuid);
    }
  }
  branch_cmd_tag_finalize(fDryRun, fVerbose, zDateOvrd, zUserOvrd);
}

/*
** COMMAND: branch
**
** Usage: %fossil branch SUBCOMMAND ... ?OPTIONS?
**
** Run various subcommands to manage branches of the open repository or
** of the repository identified by the -R or --repository option.
**
** >  fossil branch close ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
**
**       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
**
** >  fossil branch current
**
**        Print the name of the branch for the current check-out
**
** >  fossil branch hide|unhide ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
**
**       Adds or cancels the "hidden" tag for the specified branches or
**       or checkin IDs. Accepts the same options as the close
**       subcommand.
**
** >  fossil branch info BRANCH-NAME
**
**        Print information about a branch
**
** >  fossil branch list|ls ?OPTIONS? ?GLOB?
**
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
**
**        DATE may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
**        year-month-day form, it may be truncated, the "T" may be
**        replaced by a space, and it may also name a timezone offset
**        from UTC as "-HH:MM" (westward) or "+HH:MM" (eastward).
**        Either no timezone suffix or "Z" means UTC.
**
** >  fossil branch close ?OPTIONS? BRANCH-NAME ?...BRANCH-NAMES?
**
**       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;
  const char *zCmd = "list";







<
<
<
<
<
<
<
<
<
<
<
<







592
593
594
595
596
597
598












599
600
601
602
603
604
605
**
**        DATE may be "now" or "YYYY-MM-DDTHH:MM:SS.SSS". If in
**        year-month-day form, it may be truncated, the "T" may be
**        replaced by a space, and it may also name a timezone offset
**        from UTC as "-HH:MM" (westward) or "+HH:MM" (eastward).
**        Either no timezone suffix or "Z" means UTC.
**












** Options valid for all subcommands:
**
**    -R|--repository REPO       Run commands on repository REPO
*/
void branch_cmd(void){
  int n;
  const char *zCmd = "list";
603
604
605
606
607
608
609










610
611
612
613
614
615
616
  }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");
  }
}

/*







>
>
>
>
>
>
>
>
>
>







658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
  }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 if( strncmp(zCmd,"hide",4)==0 ){
    if(g.argc<4){
      usage("branch hide branch-name(s)...");
    }
    branch_cmd_hide(3,1);
  }else if( strncmp(zCmd,"unhide",6)==0 ){
    if(g.argc<4){
      usage("branch unhide branch-name(s)...");
    }
    branch_cmd_hide(3,0);
  }else{
    fossil_fatal("branch subcommand should be one of: "
                 "close current info list ls new");
  }
}

/*
Changes to www/changes.wiki.
16
17
18
19
20
21
22


23
24
25
26
27
28
29
     that it works better on a wider variety of platforms.
  *  In [/help?cmd=/wikiedit|/wikiedit], show the list of attachments for 
     the current page and list URLs suitable for pasting them into the page.
  *  Add the --no-http-compression option to [/help?cmd=sync|fossil sync]
     and similar.
  *  Print total payload bytes on a [/help?cmd=sync|fossil sync] when using
     the --verbose option.



<a name='v2_16'></a>
<h2>Changes for Version 2.16 (2021-07-02)</h2>
  *  <b>Security:</b> Fix the client-side TLS so that it verifies that the
     server hostname matches its certificate.
  *  The default "ssh" command on Windows is changed to "ssh" instead of the
     legacy "plink", as ssh is now generally available on Windows systems.







>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     that it works better on a wider variety of platforms.
  *  In [/help?cmd=/wikiedit|/wikiedit], show the list of attachments for 
     the current page and list URLs suitable for pasting them into the page.
  *  Add the --no-http-compression option to [/help?cmd=sync|fossil sync]
     and similar.
  *  Print total payload bytes on a [/help?cmd=sync|fossil sync] when using
     the --verbose option.
  *  Add the <tt>close</tt>, <tt>hide</tt>, and </tt>unhide</tt> subcommands
     to [/help?cmd=branch|the branch command].

<a name='v2_16'></a>
<h2>Changes for Version 2.16 (2021-07-02)</h2>
  *  <b>Security:</b> Fix the client-side TLS so that it verifies that the
     server hostname matches its certificate.
  *  The default "ssh" command on Windows is changed to "ssh" instead of the
     legacy "plink", as ssh is now generally available on Windows systems.