@matheusbsbs / matheus-bagliano / commits / 22ff00fc8b
Fork 0

Disambiguate the term 'branch' in Arch vs git

Disambiguate the term 'branch' in Arch vs git, and start using fully-qualified names. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>

Eric Wong committed Nov 12, 2005 at 01:29 UTC 22ff00fc8bde65414653ed139fd13d90f00fe662
1 file changed +54 -11
git-archimport.perl
+54 -11
@@ -30,6 +30,24 @@ See man (1) git-archimport for more details.
30
31 Add print in front of the shell commands invoked via backticks.
32
33 +=head1 Devel Notes
34 +
35 +There are several places where Arch and git terminology are intermixed
36 +and potentially confused.
37 +
38 +The notion of a "branch" in git is approximately equivalent to
39 +a "archive/category--branch--version" in Arch. Also, it should be noted
40 +that the "--branch" portion of "archive/category--branch--version" is really
41 +optional in Arch although not many people (nor tools!) seem to know this.
42 +This means that "archive/category--version" is also a valid "branch"
43 +in git terms.
44 +
45 +We always refer to Arch names by their fully qualified variant (which
46 +means the "archive" name is prefixed.
47 +
48 +For people unfamiliar with Arch, an "archive" is the term for "repository",
49 +and can contain multiple, unrelated branches.
50 +
51 =cut
52
53 use strict;
@@ -215,9 +233,41 @@ unless (-d $git_dir) { # initial import
233 }
234
235 # process patchsets
218 -foreach my $ps (@psets) {
236 +# extract the Arch repository name (Arch "archive" in Arch-speak)
237 +sub extract_reponame {
238 + my $fq_cvbr = shift; # archivename/[[[[category]branch]version]revision]
239 + return (split(/\//, $fq_cvbr))[0];
240 +}
241 +
242 +sub extract_versionname {
243 + my $name = shift;
244 + $name =~ s/--(?:patch|version(?:fix)?|base)-\d+$//;
245 + return $name;
246 +}
247
220 - $ps->{branch} = branchname($ps->{id});
248 +# convert a fully-qualified revision or version to a unique dirname:
249 +# normalperson@yhbt.net-05/mpd--uclinux--1--patch-2
250 +# becomes: normalperson@yhbt.net-05,mpd--uclinux--1
251 +#
252 +# the git notion of a branch is closer to
253 +# archive/category--branch--version than archive/category--branch, so we
254 +# use this to convert to git branch names.
255 +# Also, keep archive names but replace '/' with ',' since it won't require
256 +# subdirectories, and is safer than swapping '--' which could confuse
257 +# reverse-mapping when dealing with bastard branches that
258 +# are just archive/category--version (no --branch)
259 +sub tree_dirname {
260 + my $revision = shift;
261 + my $name = extract_versionname($revision);
262 + $name =~ s#/#,#;
263 + return $name;
264 +}
265 +
266 +*git_branchname = *tree_dirname;
267 +
268 +# process patchsets
269 +foreach my $ps (@psets) {
270 + $ps->{branch} = git_branchname($ps->{id});
271
272 #
273 # ensure we have a clean state
@@ -428,16 +478,9 @@ foreach my $ps (@psets) {
478 $opt_v && print " + parents: $par \n";
479 }
480
431 -sub branchname {
432 - my $id = shift;
433 - $id =~ s#^.+?/##;
434 - my @parts = split(m/--/, $id);
435 - return join('--', @parts[0..1]);
436 -}
437 -
481 sub apply_import {
482 my $ps = shift;
440 - my $bname = branchname($ps->{id});
483 + my $bname = git_branchname($ps->{id});
484
485 `mkdir -p $tmp`;
486
@@ -668,7 +711,7 @@ sub find_parents {
711 # simple loop to split the merges
712 # per branch
713 foreach my $merge (@{$ps->{merges}}) {
671 - my $branch = branchname($merge);
714 + my $branch = git_branchname($merge);
715 unless (defined $branches{$branch} ){
716 $branches{$branch} = [];
717 }