{"thread":{"id":"13700","subject":"[BRAINFART PATCH] git-svn: support SVN 1.5+ merge attributes","startedAt":"2008-05-28T09:00:59Z","lastAt":"2008-05-28T09:00:59Z","messageCount":1,"participants":["Sam Vilain"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"77926","messageId":"483D1F4B.3060701@vilain.net","threadId":"13700","inReplyTo":null,"subject":"[BRAINFART PATCH] git-svn: support SVN 1.5+ merge attributes","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2008-05-28T09:00:59Z","receivedAt":"2008-05-28T09:00:59Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Alexey,\n\nI had a look at how svnmerge.py merge tickets / SVN 1.5+ merge tickets\nmight be supported in current git-svn.  I think something along these\nlines might work, but it needs completion - much of the code there is\npsuedocode.  It doesn't address the issue of pushing git-land merges\nback to SVN, but I think this is also a sorely missing feature, as it\ncould mean people could start pushing their nice git merges back to\nSVN.\n\nSubject: [PATCH] git-svn: sketch out support for SVN 1.5+ merge properties\n\nThey may not exist in the wild much yet, but it is probably about time\ngit-svn supported SVN 1.5+ merge tickets.  Sketch out where they might\ngo, for discussion's sake only.\n\nSigned-off-but-disowned-by: Sam Vilain <sam@vilain.net>\n---\n git-svn.perl |   45 +++++++++++++++++++++++++++++++++++++++++++--\n 1 files changed, 43 insertions(+), 2 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 37976f2..acd9784 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1907,11 +1907,12 @@ sub prop_walk {\n \tforeach (keys %{$props}) {\n \t\t# If it doesn't start with `svn:', it must be a\n \t\t# user-defined property.\n-\t\t++$interesting_props and next if $_ !~ /^svn:/;\n+\t\t++$interesting_props and next if $_ !~ /^(svn:|svk:merge)/;\n \t\t# FIXME: Fragile, if SVN adds new public properties,\n \t\t# this needs to be updated.\n \t\t++$interesting_props if /^svn:(?:ignore|keywords|executable\n \t\t                                 |eol-style|mime-type\n+\t\t\t\t\t\t |mergeinfo\n \t\t\t\t\t\t |externals|needs-lock)$/x;\n \t}\n \t&$sub($self, $p, $props) if $interesting_props;\n@@ -2353,7 +2354,9 @@ sub get_untracked {\n \t\tforeach my $path (sort keys %$h) {\n \t\t\tmy $ppath = $path eq '' ? '.' : $path;\n \t\t\tforeach my $prop (sort keys %{$h->{$path}}) {\n-\t\t\t\tnext if $SKIP_PROP{$prop};\n+\t\t\t\tnext if $SKIP_PROP{$prop}\n+\t\t\t\t\tor ($t eq \"dir_prop\" and !$path\n+\t\t\t\t\t    and $prop eq \"svn:mergeinfo\");\n \t\t\t\tmy $v = $h->{$path}->{$prop};\n \t\t\t\tmy $t_ppath_prop = \"$t: \" .\n \t\t\t\t                    uri_encode($ppath) . ' ' .\n@@ -2403,6 +2406,44 @@ sub make_log_entry {\n \tmy ($self, $rev, $parents, $ed) = @_;\n \tmy $untracked = $self->get_untracked($ed);\n \n+\tif ( my $mergeinfo = $ed->{dir_prop}{\"\"}{\"svn:mergeinfo\"} ) {\n+\t\tmy %mergeinfo = map { m{^([^:]*):\\s*([\\d,\\-]+)} }\n+\t\t\tsplit \"\\n\", $mergeinfo;\n+\n+\t\t# check if any new line introduces a new complete merge\n+\t\tforeach my $path ( sort keys %mergeinfo ) {\n+\t\t\tmy @merged = split \",\", $mergeinfo{$path};\n+\n+\t\t\tmy @untracked;\n+\t\t\tfor my $merge ( @merged ) {\n+\t\t\t\tmy ($first, $last) = ($merge =~ m{\\d+(-\\d+)?$});\n+\t\t\t\t$last ||= $first;\n+\n+\t\t\t\t# this function doesn't exist yet\n+\t\t\t\tmy $svn_rev = $self->find_rev_on_path($path, $rev);\n+\t\t\t\t# it is a complete new cross-merge if;\n+\n+\t\t\t\t#  a) the first revision specified is NOT in\n+\t\t\t\t#  the history of the commit we are making\n+\t\t\t\tmy @commits = `git rev-list -1 $svn_rev --not @$parents`;\n+\t\t\t\tnext if @commits;\n+\n+\t\t\t\t#  b) the parents of that revision are also in\n+\t\t\t\t#  our history.\n+\t\t\t\t@commits = `git rev-list -1 $svn_rev^ --not @$parents`;\n+\t\t\t\tif ( @commits ) {\n+\t\t\t\t\tpush @untracked, $merge;\n+\t\t\t\t\tnext;\n+\t\t\t\t}\n+\n+\t\t\t\t# ok - go ahead and make it a parent\n+\t\t\t\tpush @$parents, $svn_rev;\n+\t\t\t}\n+\t\t\tpush @$untracked, \"svn:mergeinfo ticket for $path: \"\n+\t\t\t\t.join(\",\", @untracked);\n+\t\t}\n+\t}\n+\n \topen my $un, '>>', \"$self->{dir}/unhandled.log\" or croak $!;\n \tprint $un \"r$rev\\n\" or croak $!;\n \tprint $un $_, \"\\n\" foreach @$untracked;\n-- \n1.5.4.rc2.85.g7c8f5\n"}]}