summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/git-gpick1
-rwxr-xr-xbin/git-gpush1
-rw-r--r--bin/git_gpush.pm64
3 files changed, 38 insertions, 28 deletions
diff --git a/bin/git-gpick b/bin/git-gpick
index b964820..9f66565 100755
--- a/bin/git-gpick
+++ b/bin/git-gpick
@@ -367,6 +367,7 @@ sub determine_local_branch()
setup_remotes($local_branch // 'HEAD');
set_gerrit_config($remote);
+ source_map_validate();
}
# Get the list of local commits (which can be replaced).
diff --git a/bin/git-gpush b/bin/git-gpush
index 8fd7d67..667011c 100755
--- a/bin/git-gpush
+++ b/bin/git-gpush
@@ -711,6 +711,7 @@ sub determine_local_branch($)
}
setup_remotes($source);
set_gerrit_config($remote);
+ source_map_validate();
}
# Determine the target branch for the given series.
diff --git a/bin/git_gpush.pm b/bin/git_gpush.pm
index 9a8ff9b..bc0d708 100644
--- a/bin/git_gpush.pm
+++ b/bin/git_gpush.pm
@@ -1226,7 +1226,8 @@ our $local_tip;
# Mapping of Change-Ids to commits on the local branch.
our %changeid2local; # { change-id => SHA1 }
-sub _source_map_prepare();
+sub source_map_validate();
+sub _source_map_prepare_local();
sub source_map_assign($$);
sub source_map_traverse();
sub _source_map_finish_initial();
@@ -1267,11 +1268,11 @@ sub analyze_local_branch($)
$local_base = $$commits[0]{parents}[0];
# This needs to happen early, for parse_local_rev(), which
- # _source_map_prepare() calls.
+ # _source_map_prepare_local() calls.
$changeid2local{$$_{changeid}} = $$_{id} foreach (@$commits);
# ... then map them to Change objects ...
- _source_map_prepare();
+ _source_map_prepare_local();
while (1) {
foreach my $commit (@$commits) {
source_map_assign($commit, undef);
@@ -1731,10 +1732,8 @@ sub parse_source_option($$\@)
return 1;
}
-# Do final sanity checking on the source branch tracking related commands,
-# expand the supplied ranges into series of commits, and create a reverse
-# mapping of commits to command objects.
-sub _source_map_prepare()
+# Do final sanity checking on the source branch tracking related commands.
+sub source_map_validate()
{
my $br = $local_branch // "-";
foreach my $option (@sm_options) {
@@ -1749,27 +1748,7 @@ sub _source_map_prepare()
}
my $raw_tip = $$option{tip};
- if (defined($raw_tip)) {
- my $commits;
- my $tip = parse_local_rev($raw_tip, SPEC_TIP);
- my $raw_base = $$option{base};
- if (defined($raw_base)) {
- my $base = parse_local_rev($raw_base, SPEC_BASE);
- $commits = get_commits_base($base, $tip, $raw_base, $raw_tip);
- } else {
- my $count = $$option{count};
- $commits = get_commits_count($tip, $count, $raw_tip);
- }
- foreach my $commit (@$commits) {
- my $sha1 = $$commit{id};
- my $old_option = $sm_option_by_id{$sha1};
- wfail("Range $$option{orig} intersects $$old_option{orig} (at $sha1).\n")
- if ($old_option);
- $sm_option_by_id{$sha1} = $option;
- }
- $$option{commits} = $commits;
- next;
- }
+ next if (defined($raw_tip));
wfail("Only one of --move, --copy, and --hide may be specified with 'new'.\n")
if (defined($sm_option_new));
@@ -1777,6 +1756,35 @@ sub _source_map_prepare()
}
}
+# Expand the supplied ranges into series of commits, and create a reverse
+# mapping of commits to command objects.
+sub _source_map_prepare_local()
+{
+ foreach my $option (@sm_options) {
+ my $raw_tip = $$option{tip};
+ next if (!defined($raw_tip));
+
+ my $commits;
+ my $tip = parse_local_rev($raw_tip, SPEC_TIP);
+ my $raw_base = $$option{base};
+ if (defined($raw_base)) {
+ my $base = parse_local_rev($raw_base, SPEC_BASE);
+ $commits = get_commits_base($base, $tip, $raw_base, $raw_tip);
+ } else {
+ my $count = $$option{count};
+ $commits = get_commits_count($tip, $count, $raw_tip);
+ }
+ foreach my $commit (@$commits) {
+ my $sha1 = $$commit{id};
+ my $old_option = $sm_option_by_id{$sha1};
+ wfail("Range $$option{orig} intersects $$old_option{orig} (at $sha1).\n")
+ if ($old_option);
+ $sm_option_by_id{$sha1} = $option;
+ }
+ $$option{commits} = $commits;
+ }
+}
+
# Schedule the removal a single Change object from the state database.
sub _obliterate_change($$)
{