From: Sam Vilain <sam.vilain@catalyst.net.nz>
To: git@vger.kernel.org
Cc: Sam Vilain <sam.vilain@catalyst.net.nz>
Subject: [PATCH 3/5] git-svn: convert SVK merge tickets to extra parents
Date: Tue, 20 Oct 2009 15:42:01 +1300 [thread overview]
Message-ID: <1256006523-5493-4-git-send-email-sam.vilain@catalyst.net.nz> (raw)
In-Reply-To: <1256006523-5493-3-git-send-email-sam.vilain@catalyst.net.nz>
SVK is a simple case to start with, as its idea of merge parents
matches git's one. When a svk:merge ticket is encountered, check each
of the listed merged revisions to see if they are in the history of
this commit; if not, then we have encountered a merge - record it.
Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
---
I'm not sure if 'other_gs' is the right method to call here;
ideally we should lookup a revmap by UUID and path, that would
in principle allow people to import from a bunch of SVK depots all
being tracked. Perhaps however this is sufficient.
git-svn.perl | 50 ++++++++++++++++++++++++++++++++++++++++++-
t/t9150-svk-mergetickets.sh | 23 +++++++++++++++++++
2 files changed, 72 insertions(+), 1 deletions(-)
create mode 100644 t/t9150-svk-mergetickets.sh
diff --git a/git-svn.perl b/git-svn.perl
index eb4b75a..3c2534c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2878,14 +2878,62 @@ sub check_author {
$author;
}
+sub find_extra_svk_parents {
+ my ($self, $ed, $tickets, $parents) = @_;
+ # aha! svk:merge property changed...
+ my @tickets = split "\n", $tickets;
+ my @known_parents;
+ for my $ticket ( @tickets ) {
+ my ($uuid, $path, $rev) = split /:/, $ticket;
+ if ( $uuid eq $self->ra_uuid ) {
+ my $url = $self->rewrite_root || $self->{url};
+ my $repos_root = $url;
+ my $branch_from = $path;
+ $branch_from =~ s{^/}{};
+ my $gs = $self->other_gs($repos_root."/".$branch_from, $url,
+ $branch_from, $rev, $self->{ref_id});
+ #my $gs = other_gs ( $url, $repos_root, $branch_from,
+ #$self->{ref_id} );
+ if ( my $commit = $gs->rev_map_get($rev, $uuid) ) {
+ # wahey! we found it, but it might be
+ # an old one (!)
+ push @known_parents, $commit;
+ }
+ }
+ }
+ for my $parent ( @known_parents ) {
+ my @cmd = ('rev-list', $parent, map { "^$_" } @$parents );
+ my ($msg_fh, $ctx) = command_output_pipe(@cmd);
+ my $new;
+ while ( <$msg_fh> ) {
+ $new=1;last;
+ }
+ command_close_pipe($msg_fh, $ctx);
+ if ( $new ) {
+ print STDERR "Found merge parent (svk:merge ticket): $parent\n";
+ push @$parents, $parent;
+ }
+ }
+}
+
sub make_log_entry {
my ($self, $rev, $parents, $ed) = @_;
my $untracked = $self->get_untracked($ed);
+ my @parents = @$parents;
+ my $ps = $ed->{path_strip} || "";
+ for my $path ( grep { m/$ps/ } %{$ed->{dir_prop}} ) {
+ my $props = $ed->{dir_prop}{$path};
+ if ( $props->{"svk:merge"} ) {
+ $self->find_extra_svk_parents
+ ($ed, $props->{"svk:merge"}, \@parents);
+ }
+ }
+
open my $un, '>>', "$self->{dir}/unhandled.log" or croak $!;
print $un "r$rev\n" or croak $!;
print $un $_, "\n" foreach @$untracked;
- my %log_entry = ( parents => $parents || [], revision => $rev,
+ my %log_entry = ( parents => \@parents, revision => $rev,
log => '');
my $headrev;
diff --git a/t/t9150-svk-mergetickets.sh b/t/t9150-svk-mergetickets.sh
new file mode 100644
index 0000000..8000c34
--- /dev/null
+++ b/t/t9150-svk-mergetickets.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Sam Vilain
+#
+
+test_description='git-svn svk merge tickets'
+
+. ./lib-git-svn.sh
+
+test_expect_success 'load svk depot' "
+ svnadmin load -q '$rawsvnrepo' < '../t9150/svk-merge.dump' &&
+ git svn init --minimize-url -R svkmerge \
+ -T trunk -b branches '$svnrepo' &&
+ git svn fetch --all
+ "
+
+uuid=b48289b2-9c08-4d72-af37-0358a40b9c15
+
+test_expect_success 'svk merges were represented coming in' "
+ [ `git-cat-file commit HEAD | grep parent | wc -l` -eq 2 ]
+ "
+
+test_done
--
1.6.3.3
next prev parent reply other threads:[~2009-10-20 2:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-20 2:41 git-svn: add support for merges during 'git svn fetch' Sam Vilain
2009-10-20 2:41 ` [PATCH 1/5] git-svn: add test data for SVK merge, with script Sam Vilain
2009-10-20 2:42 ` [PATCH 2/5] git-svn: allow test setup script to support PERL env. var Sam Vilain
2009-10-20 2:42 ` Sam Vilain [this message]
2009-10-20 2:42 ` [PATCH 4/5] git-svn: add test data for SVN 1.5+ merge, with script Sam Vilain
2009-10-20 2:42 ` [PATCH 5/5] git-svn: convert SVN 1.5+ / svnmerge.py svn:mergeinfo props to parents Sam Vilain
2009-10-20 2:46 ` git-svn: add support for merges during 'git svn fetch' Sam Vilain
2009-10-20 6:32 ` Junio C Hamano
2009-10-20 21:16 ` Eric Wong
2009-10-27 3:40 ` Nanako Shiraishi
2009-10-27 7:14 ` Eric Wong
2009-10-28 7:17 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1256006523-5493-4-git-send-email-sam.vilain@catalyst.net.nz \
--to=sam.vilain@catalyst.net.nz \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).