diff options
author | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2023-04-30 09:06:04 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2024-01-09 16:41:53 +0000 |
commit | bc8b7be05248a84ea6b62261e40ef614dd3f68ae (patch) | |
tree | ae60199f413356eefef195ee724adacc0b50c43f /bin | |
parent | f2ee5446266d4d4c03994de401d5ebc5921ea46c (diff) |
gpush/gpick: enable specifying 'all' with --move/--copy/--hide
Change-Id: Id6c00ac74b8892f498e70a23e65a143ca79753c7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/git-gpush | 18 | ||||
-rw-r--r-- | bin/git_gpush.pm | 37 |
2 files changed, 40 insertions, 15 deletions
diff --git a/bin/git-gpush b/bin/git-gpush index 2e99f57..c4aa762 100755 --- a/bin/git-gpush +++ b/bin/git-gpush @@ -205,7 +205,7 @@ Options: The base-modifying options may be used with --list-rebase and --list-online, but their effect is not persisted in this case. - --move {new|<range>}[/<from>] + --move {new|all|<range>}[/<from>] After cherry-picking Changes to the current branch, mark the picks as the _only_ source for subsequent pushes of these Changes. The Changes on the current branch inherit all persistent properties, @@ -215,7 +215,7 @@ Options: This option is necessary only when a move cannot be unambiguously inferred. - --copy {new|<range>} + --copy {new|all|<range>} After cherry-picking Changes to the current branch, mark the picks as an _additional_ source for subsequent pushes of these Changes. The Changes on the source branch are left alone, while those on the @@ -223,7 +223,7 @@ Options: different default target branch). When a range is specified, the Changes are also --group'd. - --hide {new|<range>} + --hide {new|all|<range>} After cherry-picking Changes to the current branch, mark the picks as an _unacceptable_ source for subsequent pushes of these Changes. When a range is specified, the Changes are also --group'd. @@ -231,12 +231,12 @@ Options: The range can be specified as <base>..<tip> (either end can be left off) or <tip>:<count>. When using 'new' instead of a range, all Changes which were previously not seen on the current branch are - selected, while actual ranges select Changes regardless of whether - they were already seen, which makes it possible to revise previous - decisions about the authoritative source for pushes. - --move, --copy, and --hide can be specified multiple times. The - ranges may not overlap, but will override a single also specified - operation which uses 'new'. + selected, while 'all' and actual ranges select Changes regardless + of whether they were already seen, which makes it possible to revise + previous decisions about the authoritative source for pushes. + --move, --copy, and --hide can be specified multiple times, except + with 'all'. The ranges may not overlap, but will override a single + also specified operation which uses 'new'. Note that the ranges supplied to these options do NOT imply these Changes getting pushed; to do so, specify them a second time as a regular <from> argument. diff --git a/bin/git_gpush.pm b/bin/git_gpush.pm index 244f82c..62cb362 100644 --- a/bin/git_gpush.pm +++ b/bin/git_gpush.pm @@ -1889,6 +1889,7 @@ sub parse_source_option($$\@) my $orig = shift @$args; my $tip = $orig; my ($base, $count); + my $all = 0; my $branch = $1 if ($tip =~ s,/(.*)$,,); my $rmt_id; if ($rmt_ok && $tip =~ /^\+(\w+)/) { @@ -1897,11 +1898,17 @@ sub parse_source_option($$\@) } else { $base = $1 if ($tip =~ s,^(.*)\.\.,,); $count = $1 if ($tip =~ s,:(.*)$,,); - $tip = undef if ($tip eq "new"); + if ($tip eq "new") { + $tip = undef; + } elsif ($tip eq "all") { + $all = 1; + $tip = undef; + } fail("Specifying a commit count and a range base are mutually exclusive.\n") if (defined($base) && defined($count)); if (defined($base) || defined($count)) { - wfail("Specifying a commit count or range base is incompatible with range 'new'.\n") + wfail("Specifying a commit count or range base is incompatible with " + ."ranges 'new' and 'all'.\n") if (!defined($tip)); } else { wfail("Automatic ranges are not supported with $arg." @@ -1918,6 +1925,7 @@ sub parse_source_option($$\@) base => defined($base) ? length($base) ? $base : '@{u}' : undef, tip => defined($tip) ? length($tip) ? $tip : 'HEAD' : undef, count => $count, + all => $all, branch => $branch }; return 1; @@ -1941,6 +1949,8 @@ sub source_map_validate() my $raw_tip = $$option{tip}; next if (defined($raw_tip)); + wfail("--move, --copy, or --hide with 'all' must be the only such option.\n") + if ($$option{all} && @sm_options != 1); wfail("Only one of --move, --copy, and --hide may be specified with 'new'.\n") if (defined($sm_option_new)); $sm_option_new = $option; @@ -2130,7 +2140,8 @@ sub source_map_assign($$) my $new = !$change; my $option = $sm_option_by_id{$reference // $$commit{id}} // $sm_option_new; - my $new_only = $option && !defined($$option{tip}); + my $want_all = $option && $$option{all}; + my $new_only = $option && !defined($$option{tip}) && !$want_all; my $action = $option ? $$option{action} : _SRC_NOOP; if ($action == _SRC_COPY || $action == _SRC_HIDE) { # Note: We don't bother finding Changes which could be recycled - @@ -2156,11 +2167,22 @@ sub source_map_assign($$) if (defined($sbr)) { $schange = $change_by_branch{$sbr}; if (!$schange) { + if ($want_all) { + # We don't take 'all' too literally, as that would be annoying. + print "$changeid isn't on specified source branch $sbr; ignoring.\n" + if ($debug); + goto MAYBENEW; + } push @sm_errors, "Change $changeid does not exist on '$sbr'; cannot move.\n"; goto FAIL; } if ($$schange{hide}) { + if ($want_all) { + print "$changeid is hidden on specified source branch $sbr; ignoring.\n" + if ($debug); + goto MAYBENEW; + } push @sm_errors, "Change $changeid is hidden on '$sbr'; cannot move.\n"; goto FAIL; @@ -2191,9 +2213,7 @@ sub source_map_assign($$) } if (!@persisting) { # This is the common case: an entirely new Change. - $change = {}; - _init_change($change, $changeid); - goto CHANGED; + goto ISNEW; } if ($action != _SRC_MOVE) { _push_failure( @@ -2259,6 +2279,11 @@ sub source_map_assign($$) if ($debug); goto FOUND; + MAYBENEW: + goto CHANGED if (!$new); + ISNEW: + $change = {}; + _init_change($change, $changeid); CHANGED: $$change{src} = $lbr; $sm_changed = 1; |