git-svn: remove graft-branches command
It's becoming a maintenance burden. I've never found it particularly useful myself, nor have I heard much feedback about it; so I'm assuming it's just as useless to everyone else. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Jan 15, 2007 at 22:59 UTC
d05d72e07e49869fe988d4d99e6ac60711570db5
2 files changed
+3
-593
git-svn.perl
+3
-526
@@ -60,16 +60,13 @@ $sha1_short = qr/[a-f\d]{4,40}/;
60
my ($_stdin, $_help, $_edit,
61
$_repack, $_repack_nr, $_repack_flags,
62
$_message, $_file, $_no_metadata,
63
- $_template, $_shared, $_no_default_regex, $_no_graft_copy,
64
- $_version, $_upgrade, $_branch_all_refs, @_opt_m,
63
+ $_template, $_shared,
64
+ $_version, $_upgrade,
65
$_merge, $_strategy, $_dry_run,
66
$_prefix);
67
-my (@_branch_from, %tree_map);
67
my @repo_path_split_cache;
68
70
-my %fc_opts = ( 'branch|b=s' => \@_branch_from,
71
- 'follow-parent|follow' => \$_follow_parent,
72
- 'branch-all-refs|B' => \$_branch_all_refs,
69
+my %fc_opts = ( 'follow-parent|follow' => \$_follow_parent,
70
'authors-file|A=s' => \$_authors,
71
'repack:i' => \$_repack,
72
'no-metadata' => \$_no_metadata,
@@ -111,13 +108,6 @@ my %cmd = (
108
rebuild => [ \&cmd_rebuild, "Rebuild git-svn metadata (after git clone)",
109
{ 'copy-remote|remote=s' => \$_cp_remote,
110
'upgrade' => \$_upgrade } ],
114
- 'graft-branches' => [ \&graft_branches,
115
- 'Detect merges/branches from already imported history',
116
- { 'merge-rx|m' => \@_opt_m,
117
- 'branch|b=s' => \@_branch_from,
118
- 'branch-all-refs|B' => \$_branch_all_refs,
119
- 'no-default-regex' => \$_no_default_regex,
120
- 'no-graft-copy' => \$_no_graft_copy } ],
111
'multi-init' => [ \&cmd_multi_init,
112
'Initialize multiple trees (like git-svnimport)',
113
{ %multi_opts, %init_opts,
@@ -167,13 +157,11 @@ my $rv = GetOptions(%opts, 'help|H|h' => \$_help,
157
'id|i=s' => \$GIT_SVN);
158
exit 1 if (!$rv && $cmd ne 'log');
159
170
-set_default_vals();
160
usage(0) if $_help;
161
version() if $_version;
162
usage(1) unless defined $cmd;
163
init_vars();
164
load_authors() if $_authors;
176
-load_all_refs() if $_branch_all_refs;
165
migration_check() unless $cmd =~ /^(?:init|rebuild|multi-init|commit-diff)$/;
166
$cmd{$cmd}->[0]->(@ARGV);
167
exit 0;
@@ -394,40 +382,6 @@ sub cmd_show_ignore {
382
$gs->traverse_ignore(\*STDOUT, '', $r);
383
}
384
397
-sub graft_branches {
398
- my $gr_file = "$GIT_DIR/info/grafts";
399
- my ($grafts, $comments) = read_grafts($gr_file);
400
- my $gr_sha1;
401
-
402
- if (%$grafts) {
403
- # temporarily disable our grafts file to make this idempotent
404
- chomp($gr_sha1 = command(qw/hash-object -w/,$gr_file));
405
- rename $gr_file, "$gr_file~$gr_sha1" or croak $!;
406
- }
407
-
408
- my $l_map = read_url_paths();
409
- my @re = map { qr/$_/is } @_opt_m if @_opt_m;
410
- unless ($_no_default_regex) {
411
- push @re, (qr/\b(?:merge|merging|merged)\s+with\s+([\w\.\-]+)/i,
412
- qr/\b(?:merge|merging|merged)\s+([\w\.\-]+)/i,
413
- qr/\b(?:from|of)\s+([\w\.\-]+)/i );
414
- }
415
- foreach my $u (keys %$l_map) {
416
- if (@re) {
417
- foreach my $p (keys %{$l_map->{$u}}) {
418
- graft_merge_msg($grafts,$l_map,$u,$p,@re);
419
- }
420
- }
421
- unless ($_no_graft_copy) {
422
- graft_file_copy_lib($grafts,$l_map,$u);
423
- }
424
- }
425
- graft_tree_joins($grafts);
426
-
427
- write_grafts($grafts, $comments, $gr_file);
428
- unlink "$gr_file~$gr_sha1" if $gr_sha1;
429
-}
430
-
385
sub cmd_multi_init {
386
my $url = shift;
387
unless (defined $_trunk || defined $_branches || defined $_tags) {
@@ -601,157 +555,6 @@ sub common_prefix {
555
return '';
556
}
557
604
-# grafts set here are 'stronger' in that they're based on actual tree
605
-# matches, and won't be deleted from merge-base checking in write_grafts()
606
-sub graft_tree_joins {
607
- my $grafts = shift;
608
- map_tree_joins() if (@_branch_from && !%tree_map);
609
- return unless %tree_map;
610
-
611
- git_svn_each(sub {
612
- my $i = shift;
613
- my @args = (qw/rev-list --pretty=raw/, "refs/remotes/$i");
614
- my ($fh, $ctx) = command_output_pipe(@args);
615
- while (<$fh>) {
616
- next unless /^commit ($sha1)$/o;
617
- my $c = $1;
618
- my ($t) = (<$fh> =~ /^tree ($sha1)$/o);
619
- next unless $tree_map{$t};
620
-
621
- my $l;
622
- do {
623
- $l = readline $fh;
624
- } until ($l =~ /^committer (?:.+) (\d+) ([\-\+]?\d+)$/);
625
-
626
- my ($s, $tz) = ($1, $2);
627
- if ($tz =~ s/^\+//) {
628
- $s += tz_to_s_offset($tz);
629
- } elsif ($tz =~ s/^\-//) {
630
- $s -= tz_to_s_offset($tz);
631
- }
632
-
633
- my ($url_a, $r_a, $uuid_a) = cmt_metadata($c);
634
-
635
- foreach my $p (@{$tree_map{$t}}) {
636
- next if $p eq $c;
637
- my $mb = eval { command('merge-base', $c, $p) };
638
- next unless ($@ || $?);
639
- if (defined $r_a) {
640
- # see if SVN says it's a relative
641
- my ($url_b, $r_b, $uuid_b) =
642
- cmt_metadata($p);
643
- next if (defined $url_b &&
644
- defined $url_a &&
645
- ($url_a eq $url_b) &&
646
- ($uuid_a eq $uuid_b));
647
- if ($uuid_a eq $uuid_b) {
648
- if ($r_b < $r_a) {
649
- $grafts->{$c}->{$p} = 2;
650
- next;
651
- } elsif ($r_b > $r_a) {
652
- $grafts->{$p}->{$c} = 2;
653
- next;
654
- }
655
- }
656
- }
657
- my $ct = get_commit_time($p);
658
- if ($ct < $s) {
659
- $grafts->{$c}->{$p} = 2;
660
- } elsif ($ct > $s) {
661
- $grafts->{$p}->{$c} = 2;
662
- }
663
- # what should we do when $ct == $s ?
664
- }
665
- }
666
- command_close_pipe($fh, $ctx);
667
- });
668
-}
669
-
670
-sub graft_file_copy_lib {
671
- my ($grafts, $l_map, $u) = @_;
672
- my $tree_paths = $l_map->{$u};
673
- my $pfx = common_prefix([keys %$tree_paths]);
674
- my ($repo, $path) = repo_path_split($u.$pfx);
675
- $SVN = Git::SVN::Ra->new($repo);
676
-
677
- my ($base, $head) = libsvn_parse_revision();
678
- my $inc = 1000;
679
- my ($min, $max) = ($base, $head < $base+$inc ? $head : $base+$inc);
680
- my $eh = $SVN::Error::handler;
681
- $SVN::Error::handler = \&libsvn_skip_unknown_revs;
682
- while (1) {
683
- $SVN->dup->get_log([$path], $min, $max, 0, 2, 1,
684
- sub {
685
- libsvn_graft_file_copies($grafts, $tree_paths,
686
- $path, @_);
687
- });
688
- last if ($max >= $head);
689
- $min = $max + 1;
690
- $max += $inc;
691
- $max = $head if ($max > $head);
692
- }
693
- $SVN::Error::handler = $eh;
694
-}
695
-
696
-sub process_merge_msg_matches {
697
- my ($grafts, $l_map, $u, $p, $c, @matches) = @_;
698
- my (@strong, @weak);
699
- foreach (@matches) {
700
- # merging with ourselves is not interesting
701
- next if $_ eq $p;
702
- if ($l_map->{$u}->{$_}) {
703
- push @strong, $_;
704
- } else {
705
- push @weak, $_;
706
- }
707
- }
708
- foreach my $w (@weak) {
709
- last if @strong;
710
- # no exact match, use branch name as regexp.
711
- my $re = qr/\Q$w\E/i;
712
- foreach (keys %{$l_map->{$u}}) {
713
- if (/$re/) {
714
- push @strong, $l_map->{$u}->{$_};
715
- last;
716
- }
717
- }
718
- last if @strong;
719
- $w = basename($w);
720
- $re = qr/\Q$w\E/i;
721
- foreach (keys %{$l_map->{$u}}) {
722
- if (/$re/) {
723
- push @strong, $l_map->{$u}->{$_};
724
- last;
725
- }
726
- }
727
- }
728
- my ($rev) = ($c->{m} =~ /^git-svn-id:\s(?:\S+?)\@(\d+)
729
- \s(?:[a-f\d\-]+)$/xsm);
730
- unless (defined $rev) {
731
- ($rev) = ($c->{m} =~/^git-svn-id:\s(\d+)
732
- \@(?:[a-f\d\-]+)/xsm);
733
- return unless defined $rev;
734
- }
735
- foreach my $m (@strong) {
736
- my ($r0, $s0) = find_rev_before($rev, $m, 1);
737
- $grafts->{$c->{c}}->{$s0} = 1 if defined $s0;
738
- }
739
-}
740
-
741
-sub graft_merge_msg {
742
- my ($grafts, $l_map, $u, $p, @re) = @_;
743
-
744
- my $x = $l_map->{$u}->{$p};
745
- my $rl = rev_list_raw("refs/remotes/$x");
746
- while (my $c = next_rev_list_entry($rl)) {
747
- foreach my $re (@re) {
748
- my (@br) = ($c->{m} =~ /$re/g);
749
- next unless @br;
750
- process_merge_msg_matches($grafts,$l_map,$u,$p,$c,@br);
751
- }
752
- }
753
-}
754
-
558
sub verify_ref {
559
my ($ref) = @_;
560
eval { command_oneline([ 'rev-parse', '--verify', $ref ],
@@ -807,58 +610,6 @@ sub get_tree_from_treeish {
610
return $expected;
611
}
612
810
-sub get_diff {
811
- my ($from, $treeish) = @_;
812
- print "diff-tree $from $treeish\n";
813
- my @diff_tree = qw(diff-tree -z -r);
814
- if ($_cp_similarity) {
815
- push @diff_tree, "-C$_cp_similarity";
816
- } else {
817
- push @diff_tree, '-C';
818
- }
819
- push @diff_tree, '--find-copies-harder' if $_find_copies_harder;
820
- push @diff_tree, "-l$_l" if defined $_l;
821
- push @diff_tree, $from, $treeish;
822
- my ($diff_fh, $ctx) = command_output_pipe(@diff_tree);
823
- local $/ = "\0";
824
- my $state = 'meta';
825
- my @mods;
826
- while (<$diff_fh>) {
827
- chomp $_; # this gets rid of the trailing "\0"
828
- if ($state eq 'meta' && /^:(\d{6})\s(\d{6})\s
829
- $sha1\s($sha1)\s([MTCRAD])\d*$/xo) {
830
- push @mods, { mode_a => $1, mode_b => $2,
831
- sha1_b => $3, chg => $4 };
832
- if ($4 =~ /^(?:C|R)$/) {
833
- $state = 'file_a';
834
- } else {
835
- $state = 'file_b';
836
- }
837
- } elsif ($state eq 'file_a') {
838
- my $x = $mods[$#mods] or croak "Empty array\n";
839
- if ($x->{chg} !~ /^(?:C|R)$/) {
840
- croak "Error parsing $_, $x->{chg}\n";
841
- }
842
- $x->{file_a} = $_;
843
- $state = 'file_b';
844
- } elsif ($state eq 'file_b') {
845
- my $x = $mods[$#mods] or croak "Empty array\n";
846
- if (exists $x->{file_a} && $x->{chg} !~ /^(?:C|R)$/) {
847
- croak "Error parsing $_, $x->{chg}\n";
848
- }
849
- if (!exists $x->{file_a} && $x->{chg} =~ /^(?:C|R)$/) {
850
- croak "Error parsing $_, $x->{chg}\n";
851
- }
852
- $x->{file_b} = $_;
853
- $state = 'meta';
854
- } else {
855
- croak "Error parsing $_\n";
856
- }
857
- }
858
- command_close_pipe($diff_fh, $ctx);
859
- return \@mods;
860
-}
861
-
613
sub get_commit_entry {
614
my ($treeish) = shift;
615
my %log_entry = ( log => '', tree => get_tree_from_treeish($treeish) );
@@ -899,34 +650,6 @@ sub get_commit_entry {
650
\%log_entry;
651
}
652
902
-sub rev_list_raw {
903
- my ($fh, $c) = command_output_pipe(qw/rev-list --pretty=raw/, @_);
904
- return { fh => $fh, ctx => $c, t => { } };
905
-}
906
-
907
-sub next_rev_list_entry {
908
- my $rl = shift;
909
- my $fh = $rl->{fh};
910
- my $x = $rl->{t};
911
- while (<$fh>) {
912
- if (/^commit ($sha1)$/o) {
913
- if ($x->{c}) {
914
- $rl->{t} = { c => $1 };
915
- return $x;
916
- } else {
917
- $x->{c} = $1;
918
- }
919
- } elsif (/^parent ($sha1)$/o) {
920
- $x->{p}->{$1} = 1;
921
- } elsif (s/^ //) {
922
- $x->{m} ||= '';
923
- $x->{m} .= $_;
924
- }
925
- }
926
- command_close_pipe($fh, $rl->{ctx});
927
- return ($x != $rl->{t}) ? $x : undef;
928
-}
929
-
653
sub s_to_file {
654
my ($str, $file, $mode) = @_;
655
open my $fd,'>',$file or croak $!;
@@ -962,43 +685,6 @@ sub check_upgrade_needed {
685
}
686
}
687
965
-# fills %tree_map with a reverse mapping of trees to commits. Useful
966
-# for finding parents to commit on.
967
-sub map_tree_joins {
968
- my %seen;
969
- foreach my $br (@_branch_from) {
970
- my $pipe = command_output_pipe(qw/rev-list
971
- --topo-order --pretty=raw/, $br);
972
- while (<$pipe>) {
973
- if (/^commit ($sha1)$/o) {
974
- my $commit = $1;
975
-
976
- # if we've seen a commit,
977
- # we've seen its parents
978
- last if $seen{$commit};
979
- my ($tree) = (<$pipe> =~ /^tree ($sha1)$/o);
980
- unless (defined $tree) {
981
- die "Failed to parse commit $commit\n";
982
- }
983
- push @{$tree_map{$tree}}, $commit;
984
- $seen{$commit} = 1;
985
- }
986
- }
987
- close $pipe;
988
- }
989
-}
990
-
991
-sub load_all_refs {
992
- if (@_branch_from) {
993
- print STDERR '--branch|-b parameters are ignored when ',
994
- "--branch-all-refs|-B is passed\n";
995
- }
996
-
997
- # don't worry about rev-list on non-commit objects/tags,
998
- # it shouldn't blow up if a ref is a blob or tree...
999
- @_branch_from = command(qw/rev-parse --symbolic --all/);
1000
-}
1001
-
688
# '<svn username> = real-name <email address>' mapping based on git-svnimport:
689
sub load_authors {
690
open my $authors, '<', $_authors or die "Can't open $_authors $!\n";
@@ -1073,20 +759,6 @@ sub migration_check {
759
print "Done upgrading.\n";
760
}
761
1076
-sub find_rev_before {
1077
- my ($r, $id, $eq_ok) = @_;
1078
- my $f = "$GIT_DIR/svn/$id/.rev_db";
1079
- return (undef,undef) unless -r $f;
1080
- --$r unless $eq_ok;
1081
- while ($r > 0) {
1082
- if (my $c = revdb_get($f, $r)) {
1083
- return ($r, $c);
1084
- }
1085
- --$r;
1086
- }
1087
- return (undef, undef);
1088
-}
1089
-
762
sub init_vars {
763
$GIT_SVN ||= $ENV{GIT_SVN_ID} || 'git-svn';
764
$Git::SVN::default = $GIT_SVN;
@@ -1094,7 +766,6 @@ sub init_vars {
766
$REVDB = "$GIT_SVN_DIR/.rev_db";
767
$GIT_SVN_INDEX = "$GIT_SVN_DIR/index";
768
$SVN_URL = undef;
1097
- %tree_map = ();
769
}
770
771
# convert GetOpt::Long specs for use by git-config
@@ -1120,95 +791,6 @@ sub read_repo_config {
791
}
792
}
793
1123
-sub set_default_vals {
1124
- if (defined $_repack) {
1125
- $_repack = 1000 if ($_repack <= 0);
1126
- $_repack_nr = $_repack;
1127
- $_repack_flags ||= '-d';
1128
- }
1129
-}
1130
-
1131
-sub read_grafts {
1132
- my $gr_file = shift;
1133
- my ($grafts, $comments) = ({}, {});
1134
- if (open my $fh, '<', $gr_file) {
1135
- my @tmp;
1136
- while (<$fh>) {
1137
- if (/^($sha1)\s+/) {
1138
- my $c = $1;
1139
- if (@tmp) {
1140
- @{$comments->{$c}} = @tmp;
1141
- @tmp = ();
1142
- }
1143
- foreach my $p (split /\s+/, $_) {
1144
- $grafts->{$c}->{$p} = 1;
1145
- }
1146
- } else {
1147
- push @tmp, $_;
1148
- }
1149
- }
1150
- close $fh or croak $!;
1151
- @{$comments->{'END'}} = @tmp if @tmp;
1152
- }
1153
- return ($grafts, $comments);
1154
-}
1155
-
1156
-sub write_grafts {
1157
- my ($grafts, $comments, $gr_file) = @_;
1158
-
1159
- open my $fh, '>', $gr_file or croak $!;
1160
- foreach my $c (sort keys %$grafts) {
1161
- if ($comments->{$c}) {
1162
- print $fh $_ foreach @{$comments->{$c}};
1163
- }
1164
- my $p = $grafts->{$c};
1165
- my %x; # real parents
1166
- delete $p->{$c}; # commits are not self-reproducing...
1167
- my $ch = command_output_pipe(qw/cat-file commit/, $c);
1168
- while (<$ch>) {
1169
- if (/^parent ($sha1)/) {
1170
- $x{$1} = $p->{$1} = 1;
1171
- } else {
1172
- last unless /^\S/;
1173
- }
1174
- }
1175
- close $ch; # breaking the pipe
1176
-
1177
- # if real parents are the only ones in the grafts, drop it
1178
- next if join(' ',sort keys %$p) eq join(' ',sort keys %x);
1179
-
1180
- my (@ip, @jp, $mb);
1181
- my %del = %x;
1182
- @ip = @jp = keys %$p;
1183
- foreach my $i (@ip) {
1184
- next if $del{$i} || $p->{$i} == 2;
1185
- foreach my $j (@jp) {
1186
- next if $i eq $j || $del{$j} || $p->{$j} == 2;
1187
- $mb = eval { command('merge-base', $i, $j) };
1188
- next unless $mb;
1189
- chomp $mb;
1190
- next if $x{$mb};
1191
- if ($mb eq $j) {
1192
- delete $p->{$i};
1193
- $del{$i} = 1;
1194
- } elsif ($mb eq $i) {
1195
- delete $p->{$j};
1196
- $del{$j} = 1;
1197
- }
1198
- }
1199
- }
1200
-
1201
- # if real parents are the only ones in the grafts, drop it
1202
- next if join(' ',sort keys %$p) eq join(' ',sort keys %x);
1203
-
1204
- print $fh $c, ' ', join(' ', sort keys %$p),"\n";
1205
- }
1206
- if ($comments->{'END'}) {
1207
- print $fh $_ foreach @{$comments->{'END'}};
1208
- }
1209
- close $fh or croak $!;
1210
-}
1211
-
794
sub read_url_paths_all {
795
my ($l_map, $pfx, $p) = @_;
796
my @dir;
@@ -1936,48 +1518,6 @@ sub uri_decode {
1518
$f
1519
}
1520
1939
-sub libsvn_parse_revision {
1940
- my $base = shift;
1941
- my $head = $SVN->get_latest_revnum();
1942
- if (!defined $_revision || $_revision eq 'BASE:HEAD') {
1943
- return ($base + 1, $head) if (defined $base);
1944
- return (0, $head);
1945
- }
1946
- return ($1, $2) if ($_revision =~ /^(\d+):(\d+)$/);
1947
- return ($_revision, $_revision) if ($_revision =~ /^\d+$/);
1948
- if ($_revision =~ /^BASE:(\d+)$/) {
1949
- return ($base + 1, $1) if (defined $base);
1950
- return (0, $head);
1951
- }
1952
- return ($1, $head) if ($_revision =~ /^(\d+):HEAD$/);
1953
- die "revision argument: $_revision not understood by git-svn\n",
1954
- "Try using the command-line svn client instead\n";
1955
-}
1956
-
1957
-sub libsvn_traverse_ignore {
1958
- my ($fh, $path, $r) = @_;
1959
- $path =~ s#^/+##g;
1960
- my ($dirent, undef, $props) = $SVN->get_dir($path, $r);
1961
- my $p = $path;
1962
- $p =~ s#^\Q$SVN->{svn_path}\E/##;
1963
- print $fh length $p ? "\n# $p\n" : "\n# /\n";
1964
- if (my $s = $props->{'svn:ignore'}) {
1965
- $s =~ s/[\r\n]+/\n/g;
1966
- chomp $s;
1967
- if (length $p == 0) {
1968
- $s =~ s#\n#\n/$p#g;
1969
- print $fh "/$s\n";
1970
- } else {
1971
- $s =~ s#\n#\n/$p/#g;
1972
- print $fh "/$p/$s\n";
1973
- }
1974
- }
1975
- foreach (sort keys %$dirent) {
1976
- next if $dirent->{$_}->kind != $SVN::Node::dir;
1977
- libsvn_traverse_ignore($fh, "$path/$_", $r);
1978
- }
1979
-}
1980
-
1521
sub revisions_eq {
1522
my ($path, $r0, $r1) = @_;
1523
return 1 if $r0 == $r1;
@@ -2065,69 +1605,6 @@ sub _libsvn_new_tree {
1605
libsvn_log_entry($rev, $author, $date, $log, $parents, $ed);
1606
}
1607
2068
-sub find_graft_path_commit {
2069
- my ($tree_paths, $p1, $r1) = @_;
2070
- foreach my $x (keys %$tree_paths) {
2071
- next unless ($p1 =~ /^\Q$x\E/);
2072
- my $i = $tree_paths->{$x};
2073
- my ($r0, $parent) = find_rev_before($r1,$i,1);
2074
- return $parent if (defined $r0 && $r0 == $r1);
2075
- print STDERR "r$r1 of $i not imported\n";
2076
- next;
2077
- }
2078
- return undef;
2079
-}
2080
-
2081
-sub find_graft_path_parents {
2082
- my ($grafts, $tree_paths, $c, $p0, $r0) = @_;
2083
- foreach my $x (keys %$tree_paths) {
2084
- next unless ($p0 =~ /^\Q$x\E/);
2085
- my $i = $tree_paths->{$x};
2086
- my ($r, $parent) = find_rev_before($r0, $i, 1);
2087
- if (defined $r && defined $parent && revisions_eq($x,$r,$r0)) {
2088
- my ($url_b, undef, $uuid_b) = cmt_metadata($c);
2089
- my ($url_a, undef, $uuid_a) = cmt_metadata($parent);
2090
- next if ($url_a && $url_b && $url_a eq $url_b &&
2091
- $uuid_b eq $uuid_a);
2092
- $grafts->{$c}->{$parent} = 1;
2093
- }
2094
- }
2095
-}
2096
-
2097
-sub libsvn_graft_file_copies {
2098
- my ($grafts, $tree_paths, $path, $paths, $rev) = @_;
2099
- foreach (keys %$paths) {
2100
- my $i = $paths->{$_};
2101
- my ($m, $p0, $r0) = ($i->action, $i->copyfrom_path,
2102
- $i->copyfrom_rev);
2103
- next unless (defined $p0 && defined $r0);
2104
-
2105
- my $p1 = $_;
2106
- $p1 =~ s#^/##;
2107
- $p0 =~ s#^/##;
2108
- my $c = find_graft_path_commit($tree_paths, $p1, $rev);
2109
- next unless $c;
2110
- find_graft_path_parents($grafts, $tree_paths, $c, $p0, $r0);
2111
- }
2112
-}
2113
-
2114
-sub revdb_get {
2115
- my ($file, $rev) = @_;
2116
- my $ret;
2117
- my $offset = $rev * 41;
2118
- open my $fh, '<', $file or croak $!;
2119
- seek $fh, $offset, 0;
2120
- if (tell $fh == $offset) {
2121
- $ret = readline $fh;
2122
- if (defined $ret) {
2123
- chomp $ret;
2124
- $ret = undef if ($ret =~ /^0{40}$/);
2125
- }
2126
- }
2127
- close $fh or croak $!;
2128
- return $ret;
2129
-}
2130
-
1608
{
1609
my $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.
1610
$SVN::Node::dir.$SVN::Node::unknown.
t/t9103-git-svn-graft-branches.sh
deleted
-67
@@ -1,67 +0,0 @@
1
-#!/bin/sh
2
-test_description='git-svn graft-branches'
3
-. ./lib-git-svn.sh
4
-
5
-svnrepo="$svnrepo/test-git-svn"
6
-
7
-test_expect_success 'initialize repo' "
8
- mkdir import &&
9
- cd import &&
10
- mkdir -p trunk branches tags &&
11
- echo hello > trunk/readme &&
12
- svn import -m 'import for git-svn' . $svnrepo &&
13
- cd .. &&
14
- svn cp -m 'tag a' $svnrepo/trunk $svnrepo/tags/a &&
15
- svn cp -m 'branch a' $svnrepo/trunk $svnrepo/branches/a &&
16
- svn co $svnrepo wc &&
17
- cd wc &&
18
- echo feedme >> branches/a/readme &&
19
- poke branches/a/readme &&
20
- svn commit -m hungry &&
21
- cd trunk &&
22
- svn merge -r3:4 $svnrepo/branches/a &&
23
- svn commit -m 'merge with a' &&
24
- cd ../.. &&
25
- git-svn multi-init $svnrepo -T trunk -b branches -t tags &&
26
- git-svn multi-fetch
27
- "
28
-
29
-test_expect_success 'multi-init set .git/config correctly' "
30
- test '$svnrepo/trunk' = '`git repo-config --get svn.trunk`' &&
31
- test '$svnrepo/branches' = '`git repo-config --get svn.branches`' &&
32
- test '$svnrepo/tags' = '`git repo-config --get svn.tags`'
33
- "
34
-
35
-r1=`git-rev-list remotes/trunk | tail -n1`
36
-r2=`git-rev-list remotes/tags/a | tail -n1`
37
-r3=`git-rev-list remotes/a | tail -n1`
38
-r4=`git-rev-parse remotes/a`
39
-r5=`git-rev-parse remotes/trunk`
40
-
41
-test_expect_success 'test graft-branches regexes and copies' "
42
- test -n "$r1" &&
43
- test -n "$r2" &&
44
- test -n "$r3" &&
45
- test -n "$r4" &&
46
- test -n "$r5" &&
47
- git-svn graft-branches &&
48
- grep '^$r2 $r1' $GIT_DIR/info/grafts &&
49
- grep '^$r3 $r1' $GIT_DIR/info/grafts &&
50
- grep '^$r5 ' $GIT_DIR/info/grafts | grep '$r4' | grep '$r1'
51
- "
52
-
53
-test_debug 'gitk --all & sleep 1'
54
-
55
-test_expect_success 'test graft-branches with tree-joins' "
56
- rm $GIT_DIR/info/grafts &&
57
- git-svn graft-branches --no-default-regex --no-graft-copy -B &&
58
- grep '^$r3 ' $GIT_DIR/info/grafts | grep '$r1' | grep '$r2' &&
59
- grep '^$r2 $r1' $GIT_DIR/info/grafts &&
60
- grep '^$r5 ' $GIT_DIR/info/grafts | grep '$r1' | grep '$r4'
61
- "
62
-
63
-# the result of this is kinda funky, we have a strange history and
64
-# this is just a test :)
65
-test_debug 'gitk --all &'
66
-
67
-test_done