|
Added
Link Here
|
| 1 |
--- git-svn.perl.orig 2014-11-13 08:43:00 UTC |
| 2 |
+++ git-svn.perl |
| 3 |
@@ -115,7 +115,7 @@ my ($_stdin, $_help, $_edit, |
| 4 |
$_before, $_after, |
| 5 |
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_parents, $_local, |
| 6 |
$_prefix, $_no_checkout, $_url, $_verbose, |
| 7 |
- $_commit_url, $_tag, $_merge_info, $_interactive); |
| 8 |
+ $_commit_url, $_tag, $_merge_info, $_interactive, $_set_svn_props); |
| 9 |
|
| 10 |
# This is a refactoring artifact so Git::SVN can get at this git-svn switch. |
| 11 |
sub opt_prefix { return $_prefix || '' } |
| 12 |
@@ -193,6 +193,7 @@ my %cmd = ( |
| 13 |
'dry-run|n' => \$_dry_run, |
| 14 |
'fetch-all|all' => \$_fetch_all, |
| 15 |
'commit-url=s' => \$_commit_url, |
| 16 |
+ 'set-svn-props=s' => \$_set_svn_props, |
| 17 |
'revision|r=i' => \$_revision, |
| 18 |
'no-rebase' => \$_no_rebase, |
| 19 |
'mergeinfo=s' => \$_merge_info, |
| 20 |
@@ -228,6 +229,9 @@ my %cmd = ( |
| 21 |
'propget' => [ \&cmd_propget, |
| 22 |
'Print the value of a property on a file or directory', |
| 23 |
{ 'revision|r=i' => \$_revision } ], |
| 24 |
+ 'propset' => [ \&cmd_propset, |
| 25 |
+ 'Set the value of a property on a file or directory - will be set on commit', |
| 26 |
+ {} ], |
| 27 |
'proplist' => [ \&cmd_proplist, |
| 28 |
'List all properties of a file or directory', |
| 29 |
{ 'revision|r=i' => \$_revision } ], |
| 30 |
@@ -1370,6 +1374,50 @@ sub cmd_propget { |
| 31 |
print $props->{$prop} . "\n"; |
| 32 |
} |
| 33 |
|
| 34 |
+# cmd_propset (PROPNAME, PROPVAL, PATH) |
| 35 |
+# ------------------------ |
| 36 |
+# Adjust the SVN property PROPNAME to PROPVAL for PATH. |
| 37 |
+sub cmd_propset { |
| 38 |
+ my ($propname, $propval, $path) = @_; |
| 39 |
+ $path = '.' if not defined $path; |
| 40 |
+ $path = $cmd_dir_prefix . $path; |
| 41 |
+ usage(1) if not defined $propname; |
| 42 |
+ usage(1) if not defined $propval; |
| 43 |
+ my $file = basename($path); |
| 44 |
+ my $dn = dirname($path); |
| 45 |
+ # diff has check_attr locally, so just call direct |
| 46 |
+ #my $current_properties = check_attr( "svn-properties", $path ); |
| 47 |
+ my $current_properties = Git::SVN::Editor::check_attr( "svn-properties", $path ); |
| 48 |
+ my $new_properties = ""; |
| 49 |
+ if ($current_properties eq "unset" || $current_properties eq "" || $current_properties eq "set") { |
| 50 |
+ $new_properties = "$propname=$propval"; |
| 51 |
+ } else { |
| 52 |
+ # TODO: handle combining properties better |
| 53 |
+ my @props = split(/;/, $current_properties); |
| 54 |
+ my $replaced_prop = 0; |
| 55 |
+ foreach my $prop (@props) { |
| 56 |
+ # Parse 'name=value' syntax and set the property. |
| 57 |
+ if ($prop =~ /([^=]+)=(.*)/) { |
| 58 |
+ my ($n,$v) = ($1,$2); |
| 59 |
+ if ($n eq $propname) |
| 60 |
+ { |
| 61 |
+ $v = $propval; |
| 62 |
+ $replaced_prop = 1; |
| 63 |
+ } |
| 64 |
+ if ($new_properties eq "") { $new_properties="$n=$v"; } |
| 65 |
+ else { $new_properties="$new_properties;$n=$v"; } |
| 66 |
+ } |
| 67 |
+ } |
| 68 |
+ if ($replaced_prop eq 0) { |
| 69 |
+ $new_properties = "$new_properties;$propname=$propval"; |
| 70 |
+ } |
| 71 |
+ } |
| 72 |
+ my $attrfile = "$dn/.gitattributes"; |
| 73 |
+ open my $attrfh, '>>', $attrfile or die "Can't open $attrfile: $!\n"; |
| 74 |
+ # TODO: don't simply append here if $file already has svn-properties |
| 75 |
+ print $attrfh "$file svn-properties=$new_properties\n"; |
| 76 |
+} |
| 77 |
+ |
| 78 |
# cmd_proplist (PATH) |
| 79 |
# ------------------- |
| 80 |
# Print the list of SVN properties for PATH. |