6666 ' repack:i' => \$Git::SVN::_repack ,
6767 ' noMetadata' => \$Git::SVN::_no_metadata ,
6868 ' useSvmProps' => \$Git::SVN::_use_svm_props ,
69+ ' useSvnsyncProps' => \$Git::SVN::_use_svnsync_props ,
6970 ' log-window-size=i' => \$Git::SVN::Ra::_log_window_size ,
7071 ' no-checkout' => \$_no_checkout,
7172 ' quiet|q' => \$_q,
@@ -747,7 +748,8 @@ package Git::SVN;
747748use strict;
748749use warnings;
749750use vars qw/ $default_repo_id $default_ref_id $_no_metadata $_follow_parent
750- $_repack $_repack_flags $_use_svm_props $_head/ ;
751+ $_repack $_repack_flags $_use_svm_props $_head
752+ $_use_svnsync_props/ ;
751753use Carp qw/ croak/ ;
752754use File::Path qw/ mkpath/ ;
753755use File::Copy qw/ copy/ ;
@@ -768,7 +770,8 @@ BEGIN
768770 # per [svn-remote "..."] section. Command-line options will *NOT*
769771 # override options set in an [svn-remote "..."] section
770772 my $e ;
771- foreach (qw/ follow_parent no_metadata use_svm_props/ ) {
773+ foreach (qw/ follow_parent no_metadata use_svm_props
774+ use_svnsync_props/ ) {
772775 my $key = $_ ;
773776 $key =~ tr / _// d;
774777 $e .= " sub $_ {
@@ -1186,6 +1189,50 @@ sub _set_svm_vars {
11861189 Git::SVN::Ra-> new($self -> {url });
11871190}
11881191
1192+ sub svnsync {
1193+ my ($self ) = @_ ;
1194+ return $self -> {svnsync } if $self -> {svnsync };
1195+
1196+ if ($self -> no_metadata) {
1197+ die " Can't have both 'noMetadata' and " ,
1198+ " 'useSvnsyncProps' options set!\n " ;
1199+ }
1200+ if ($self -> rewrite_root) {
1201+ die " Can't have both 'useSvnsyncProps' and 'rewriteRoot' " ,
1202+ " options set!\n " ;
1203+ }
1204+
1205+ my $svnsync ;
1206+ # see if we have it in our config, first:
1207+ eval {
1208+ my $section = " svn-remote.$self ->{repo_id}" ;
1209+ $svnsync = {
1210+ url => tmp_config(' --get' , " $section .svnsync-url" ),
1211+ uuid => tmp_config(' --get' , " $section .svnsync-uuid" ),
1212+ }
1213+ };
1214+ if ($svnsync && $svnsync -> {url } && $svnsync -> {uuid }) {
1215+ return $self -> {svnsync } = $svnsync ;
1216+ }
1217+
1218+ my $err = " useSvnsyncProps set, but failed to read " .
1219+ " svnsync property: svn:sync-from-" ;
1220+ my $rp = $self -> ra-> rev_proplist(0);
1221+
1222+ my $url = $rp -> {' svn:sync-from-url' } or die $err . " url\n " ;
1223+ $url =~ m { ^[a-z\+ ]+://} or
1224+ die " doesn't look right - svn:sync-from-url is '$url '\n " ;
1225+
1226+ my $uuid = $rp -> {' svn:sync-from-uuid' } or die $err . " uuid\n " ;
1227+ $uuid =~ m { ^[0-9a-f\- ]{30,}$} or
1228+ die " doesn't look right - svn:sync-from-uuid is '$uuid '\n " ;
1229+
1230+ my $section = " svn-remote.$self ->{repo_id}" ;
1231+ tmp_config(' --add' , " $section .svnsync-uuid" , $uuid );
1232+ tmp_config(' --add' , " $section .svnsync-url" , $url );
1233+ return $self -> {svnsync } = { url => $url , uuid => $uuid };
1234+ }
1235+
11891236# this allows us to memoize our SVN::Ra UUID locally and avoid a
11901237# remote lookup (useful for 'git svn log').
11911238sub ra_uuid {
@@ -1211,6 +1258,9 @@ sub ra {
12111258 if ($self -> no_metadata) {
12121259 die " Can't have both 'noMetadata' and " ,
12131260 " 'useSvmProps' options set!\n " ;
1261+ } elsif ($self -> use_svnsync_props) {
1262+ die " Can't have both 'useSvnsyncProps' and " ,
1263+ " 'useSvmProps' options set!\n " ;
12141264 }
12151265 $ra = $self -> _set_svm_vars($ra );
12161266 $self -> {-want_revprops} = 1;
@@ -1739,6 +1789,12 @@ sub make_log_entry {
17391789 $log_entry {metadata } = " $full_url \@ $r $uuid " ;
17401790 $log_entry {svm_revision } = $r ;
17411791 $email ||= " $author \@ $uuid "
1792+ } elsif ($self -> use_svnsync_props) {
1793+ my $full_url = $self -> svnsync-> {url };
1794+ $full_url .= " /$self ->{path}" if length $self -> {path };
1795+ my $uuid = $self -> svnsync-> {uuid };
1796+ $log_entry {metadata } = " $full_url \@ $rev $uuid " ;
1797+ $email ||= " $author \@ $uuid "
17421798 } else {
17431799 $log_entry {metadata } = $self -> metadata_url. " \@ $rev " .
17441800 $self -> ra-> get_uuid;
0 commit comments