@@ -115,7 +115,7 @@ sub _req_svn {
115115 $_before, $_after,
116116 $_merge, $_strategy, $_preserve_merges, $_dry_run, $_parents, $_local,
117117 $_prefix, $_no_checkout, $_url, $_verbose,
118- $_commit_url, $_tag, $_merge_info, $_interactive);
118+ $_commit_url, $_tag, $_merge_info, $_interactive, $_set_svn_props );
119119
120120# This is a refactoring artifact so Git::SVN can get at this git-svn switch.
121121sub opt_prefix { return $_prefix || ' ' }
@@ -193,6 +193,7 @@ sub _req_svn {
193193 ' dry-run|n' => \$_dry_run,
194194 ' fetch-all|all' => \$_fetch_all,
195195 ' commit-url=s' => \$_commit_url,
196+ ' set-svn-props=s' => \$_set_svn_props,
196197 ' revision|r=i' => \$_revision,
197198 ' no-rebase' => \$_no_rebase,
198199 ' mergeinfo=s' => \$_merge_info,
@@ -228,6 +229,9 @@ sub _req_svn {
228229 ' propget' => [ \&cmd_propget,
229230 ' Print the value of a property on a file or directory' ,
230231 { ' revision|r=i' => \$_revision } ],
232+ ' propset' => [ \&cmd_propset,
233+ ' Set the value of a property on a file or directory - will be set on commit' ,
234+ {} ],
231235 ' proplist' => [ \&cmd_proplist,
232236 ' List all properties of a file or directory' ,
233237 { ' revision|r=i' => \$_revision } ],
@@ -1376,6 +1380,49 @@ sub cmd_propget {
13761380 print $props -> {$prop } . " \n " ;
13771381}
13781382
1383+ # cmd_propset (PROPNAME, PROPVAL, PATH)
1384+ # ------------------------
1385+ # Adjust the SVN property PROPNAME to PROPVAL for PATH.
1386+ sub cmd_propset {
1387+ my ($propname , $propval , $path ) = @_ ;
1388+ $path = ' .' if not defined $path ;
1389+ $path = $cmd_dir_prefix . $path ;
1390+ usage(1) if not defined $propname ;
1391+ usage(1) if not defined $propval ;
1392+ my $file = basename($path );
1393+ my $dn = dirname($path );
1394+ my $cur_props = Git::SVN::Editor::check_attr( " svn-properties" , $path );
1395+ my @new_props ;
1396+ if (!$cur_props || $cur_props eq " unset" || $cur_props eq " " || $cur_props eq " set" ) {
1397+ push @new_props , " $propname =$propval " ;
1398+ } else {
1399+ # TODO: handle combining properties better
1400+ my @props = split (/ ;/ , $cur_props );
1401+ my $replaced_prop ;
1402+ foreach my $prop (@props ) {
1403+ # Parse 'name=value' syntax and set the property.
1404+ if ($prop =~ / ([^=]+)=(.*)/ ) {
1405+ my ($n ,$v ) = ($1 ,$2 );
1406+ if ($n eq $propname ) {
1407+ $v = $propval ;
1408+ $replaced_prop = 1;
1409+ }
1410+ push @new_props , " $n =$v " ;
1411+ }
1412+ }
1413+ if (!$replaced_prop ) {
1414+ push @new_props , " $propname =$propval " ;
1415+ }
1416+ }
1417+ my $attrfile = " $dn /.gitattributes" ;
1418+ open my $attrfh , ' >>' , $attrfile or die " Can't open $attrfile : $! \n " ;
1419+ # TODO: don't simply append here if $file already has svn-properties
1420+ my $new_props = join (' ;' , @new_props );
1421+ print $attrfh " $file svn-properties=$new_props \n " or
1422+ die " write to $attrfile : $! \n " ;
1423+ close $attrfh or die " close $attrfile : $! \n " ;
1424+ }
1425+
13791426# cmd_proplist (PATH)
13801427# -------------------
13811428# Print the list of SVN properties for PATH.
0 commit comments