diff options
author | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2023-03-29 12:05:43 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2024-01-09 16:36:29 +0000 |
commit | 919dcc280bc55fb619f4a6a23abda9a3a5d617e4 (patch) | |
tree | 4bf2aa6fd171e6b0aefc6028639c525d1047a077 /bin/git-gpush | |
parent | 054193f3355a4441a15647968cc45357c5490d41 (diff) |
gpush/gpick: introduce infra for indirect properties
rather than having the same (potentially big) value in each Change it
was assigned to, duplicate only a small id.
an arguably cleaner way to approach this would be saving actual group
properties rather than aggregating them on the fly from Change
properties. but when i implemented this, it turned out that we'd have to
be able to resolve conflicts resulting from merging groups in rather
inopportune places: gpick calls assign_series() from deduce_series()
(though a conflict occurring due to this is a rather academical case)
and from _source_map_finish_initial() via analyze_local_branch(). this
means that we'd have to add the property-overriding command line options
to gpick (which is ugly) or we'd have to croak in gpick and tell the
user to use gpush first instead (which is also ugly).
more broadly, group properties aren't a very good fit for gerrit, where
groups aren't even a thing. this is why we don't use them in the first
place.
Change-Id: I555360de0fc08b698213e56045ca408c1ee47851
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'bin/git-gpush')
-rwxr-xr-x | bin/git-gpush | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/git-gpush b/bin/git-gpush index 7230c5f..56bc5db 100755 --- a/bin/git-gpush +++ b/bin/git-gpush @@ -769,6 +769,26 @@ sub aggregate_bool_property($$$$$) fail_formatted(\@reports); } +sub aggregate_indirect_property($$$) +{ + my ($group, $get_key, $get_err) = @_; + + my $changes = $$group{changes}; + my %key_map = map { $_ => 1 } grep { defined($_) } map { $get_key->() } @$changes; + my @pkeys = sort keys %key_map; + return if (!@pkeys); + # Again a hash, as different keys could still lead to the same value. + my %prop_map = map { ($prop_by_key{$_} // "") => 1 } @pkeys; + my @props = sort keys %prop_map; + return $pkeys[0] if (@props == 1); + + my @reports; + report_fixed(\@reports, "Series of ".int(@$changes)." Changes:\n"); + report_local_changes(\@reports, $changes); + report_fixed(\@reports, $get_err->(@props)); + fail_formatted(\@reports); +} + # Find _the_ branch the specified commit lives on. This can be the current # branch (and other branches are ignored), or _one_ other branch. sub branch_for_commit($) |