Recursive svn propset
I'm trying to recursively add properties to all files with a wildcard.
File structure as below
D:>dir *.bob /s/b
D:\Source\key-test\test.bob
D:\Source\key-test\test2.bob
D:\Source\key-test\sub\test3.bob
properties so far (none)
D:>svn propget svn:keywords -R *.bob
try a recursive set (note test3.bob is missing)
D:>svn propset svn:keywords "Author HeadURL Id开发者_如何学运维 Revision" -R *.bob
property 'svn:keywords' set on 'test.bob'
property 'svn:keywords' set on 'test2.bob'
change to sub and make sure we can set the prop (ok)
D:>cd sub
D:>svn propset svn:keywords "Author HeadURL Id Revision" -R *.bob
property 'svn:keywords' set on 'test3.bob'
Anyone know what's up with -R, I've also tried --recursive?
Cheers,
adam
D:>svn --version
svn, version 1.6.6 (SlikSvn:tag/1.6.6@40358) WIN32
compiled Nov 3 2009, 15:31:43
Actually -R is recursive. For example:
svn propset svn:eol-style 'LF' -R *
This will work on all subfolders as well. However:
svn propset svn:eol-style 'LF' -R *.php
...will only work on php files within the current folder, regardless of the -R. Adding:
svn propset svn:eol-style 'LF' -R */*.php
Will work on subfolders one level down. Adding extra /-s will go another level and so on...
I'm really not sure how to specify (or if it is even possible to do so) that it should be filtered based on file name AND recursive. Regardless, experimenting can't hurt, since the modifications are local and can always be thrown away by reverting...
From svn help propset
:
The svn:keywords, svn:executable, svn:eol-style, svn:mime-type and
svn:needs-lock properties cannot be set on a directory. A non-recursive
attempt will fail, and a recursive attempt will set the property only on the file children of the directory.
Given that there is ambiguity over the docs for what -R does (or doesn't do) as pointed out by Gonzalo I've used this batch file instead of trying to get svn to do what I want
D:>type applyProps.cmd
@echo off
for /r . %%X in (*.bob) do (
svn propset svn:keywords "Author Id HeadURL Revision" "%%X"
)
If your working directory is under UNIX, you can also try this command. It works for me:
svn propset svn:keywords "Id" `du -a | cut -f 2 | grep -v "\.svn" | grep "\.bob$" | sed "s/ /[[:space:]]/g"`
Just recursively changed properties on .xml files from application/xml to text/xml and was trying to see if there was a better way to do it. I couldn't find one, but stumbled across this question. Though it's old, this is the most succinct way I found:
find /<root_dir> -print | grep '.<extension>' | xargin svn propset svn:<property> <new_ property_value> $@
find -print
recursively lists all files in all sub directories of <root_dir>
with their full path starting with <root_dir>
grep '.<extension>'
receives the piped output from find
as input and filters it based on the extension you're looking for
xargin
allows you to execute a command that may not work smoothly with piped input in stdin, which can be referenced with $@
For example, my exact command was
find /config -print | grep '.xml' | xargin svn propset svn:mime-type text/xml $@
Note <root_dir>
must be an immediate sub-directory of your present working directory
精彩评论