summaryrefslogtreecommitdiff
path: root/bin/git-gpick
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2015-11-20 21:14:27 +0100
committerOswald Buddenhagen <oswald.buddenhagen@gmx.de>2020-03-05 18:11:00 +0000
commitfbe6d232ba331f08c154465da64a2d2560774427 (patch)
treea0fbc94355cb07bb89c4c7b7e1b1bf11057b6978 /bin/git-gpick
parente093eaee1a2de9b74e19e8e7ed279d2095784479 (diff)
downloadqtrepotools-fbe6d232ba331f08c154465da64a2d2560774427.tar.gz
gpick: omit abandoned/deferred changes by default
... and add corresponding --force-closed/-fc override. Change-Id: I71c4c7f580db1f4a4009c78b19552d19a6638548 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'bin/git-gpick')
-rwxr-xr-xbin/git-gpick56
1 files changed, 54 insertions, 2 deletions
diff --git a/bin/git-gpick b/bin/git-gpick
index a4a12e0..73a8473 100755
--- a/bin/git-gpick
+++ b/bin/git-gpick
@@ -104,6 +104,13 @@ Options:
Pick Changes even if they are MERGED and were already pulled.
This makes sense when re-applying reverted commits.
+ -fc, --force-closed
+ The Changes in a series are categorized by their "degree of openness"
+ (open, deferred, abandoned). Usually, only the ones in the "most open"
+ category are picked, while all "more closed" ones are omitted.
+ Specifying this option causes the Changes in the next actually present
+ category to be picked as well. May be specified twice.
+
-i, --ignore
Ignore the new PatchSets that appeared on Gerrit since the previous
push from this clone. The local Changes will subsequently appear
@@ -218,6 +225,7 @@ my $merge = 0;
my $force = 0;
my $force_struct = 0;
my $force_merged = 0;
+my $force_closed = 0;
my $ignore = 0;
my $ignore_struct = 0;
my @commit_specs;
@@ -252,6 +260,8 @@ sub parse_arguments(@)
$force_struct = 1;
} elsif ($arg eq "-fm" || $arg eq "--force-merged") {
$force_merged = 1;
+ } elsif ($arg eq "-fc" || $arg eq "--force-closed") {
+ $force_closed++;
} elsif ($arg eq "-i" || $arg eq "--ignore") {
$ignore = 1;
} elsif ($arg eq "-is" || $arg eq "--ignore-struct") {
@@ -279,9 +289,9 @@ sub parse_arguments(@)
# Note that --{force,ignore}-struct are intentionally omitted,
# because one may want to preview the effects of (not) following
# structural changes.
- wfail("--check and --merge/--force/--force-merged/--ignore"
+ wfail("--check and --merge/--force/--force-merged/--force-closed/--ignore"
." are mutually exclusive.\n")
- if ($merge || $force || $force_merged || $ignore);
+ if ($merge || $force || $force_merged || $force_closed || $ignore);
}
fail("--merge/--force and --ignore are mutually exclusive.\n")
@@ -1357,6 +1367,7 @@ sub sort_series($$$$)
my $report = $current && !$quiet;
my %selected = map { $$_{id} => 1 } @$range;
my @merged;
+ my @levels;
foreach my $commit (map { @$_ } values %$commits) {
my $changeid = $$commit{changeid};
@@ -1382,8 +1393,18 @@ sub sort_series($$$$)
if (!defined($selected{$changeid})) {
$exclude{$changeid} = 'MERGED';
push @merged, $commit if ($report);
+ next;
}
}
+
+ # Drop Changes "more closed" than the "most open" ones in the
+ # series, unless forced.
+ # This is the preparation part.
+ if ($force_closed < 2) {
+ my $status = $$ginfo{status};
+ my $lvl = ($status eq 'ABANDONED') ? 2 : ($status eq 'DEFERRED') ? 1 : 0;
+ push @{$levels[$lvl]}, $commit;
+ }
}
print "NOT adding already pulled MERGED Change(s) from series $name:\n"
@@ -1391,6 +1412,37 @@ sub sort_series($$$$)
."Use --force-merged to add them nonetheless.\n"
if (@merged);
+ # The execution part of dropping closed Changes.
+ my $have_levels = 0;
+ for my $lvl (0..2) {
+ if (defined($levels[$lvl])) {
+ if ($have_levels > $force_closed) {
+ my $status = ($lvl == 1) ? 'DEFERRED' : 'ABANDONED';
+ my @closed;
+ foreach my $commit (@{$levels[$lvl]}) {
+ my $changeid = $$commit{changeid};
+ # If such a Change is already in the local branch, it might be
+ # so because it was forced, or because it was still open at the
+ # time of the previous push/pick. For reconstructing the previous
+ # series this does not matter, so we just keep it. For the current
+ # series, we prefer to follow recent abandonments, and the user
+ # may need to use force again.
+ if ($current || !defined($selected{$changeid})) {
+ $exclude{$changeid} = $status;
+ push @closed, $commit if ($report);
+ }
+ }
+ if (@closed) {
+ my $twice = ($have_levels > 1) ? " (twice)" : "";
+ print "NOT adding $status Change(s) from series $name:\n"
+ .format_commits(\@closed)
+ ."Use --force-closed$twice to add them nonetheless.\n";
+ }
+ }
+ $have_levels++;
+ }
+ }
+
my %order = map { $$_{id} => $$_{index} } @$range;
print "Ordering $name ...\n" if ($debug);