You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Quinn Taylor <qu...@mac.com> on 2008/07/17 20:39:39 UTC

Newlines when setting svn:ignore from cmdline

Hello everyone, first post...

Setting the svn:ignore property on a directory node requires a newline  
between each item. While one way to do this is to use a file argument,  
creating a file is not always an elegant or compelling solution. This  
value can be set interactively on the command line by putting all the  
values within ' marks and typing a return between each. However, I  
haven't found a way to effectively script or automate this process.

Step 2 on <http://riquedafreak.blogspot.com/2007/12/spring-cleaning-with-subversion.html 
 > describes how to set the ignore property for several values on  
directories matching a certain pattern. I would like to make this into  
a bash alias, but so far my attempts to do so have been fruitless,  
since svn propset doesn't do anything intelligent with \n or \r escape  
characters. To me, this seems like a dumb restriction.

I've researched a few possibly related existing issues, both of which  
deal with auto-props which can be set in user-specific configuration.  
(On OS X, this is found in the ~/.subversion/config file.)


Bug #1989 — Make auto-props affect directories
http://subversion.tigris.org/issues/show_bug.cgi?id=1989

Kevin Ballard suggests using \n for newlines and making auto-props  
apply to directories. The latest comments on this issue say that it's  
unscheduled, but made into a branch of SVN 2 years ago. I would LOVE  
to see progress and a resolution on this, since it would also help  
solve the problem I'm facing. (In fact, such files in .xcodproj  
directories is one of the problems I'm dealing with.)


Bug #2068 — No escaping of separator characters in auto-props
http://subversion.tigris.org/issues/show_bug.cgi?id=2068

This bug relates to the inability to use semicolons within auto-prop  
values, since it's a separator. Introducing an escaped newline might  
deal with a similar issue or part of the Subversion config system.


Nothing that I've found so far has dealt with accepting escaped  
newlines in svn:ignore propset strings. Does anyone else feel that  
this is an issue that could stand to be improved?

Thanks,
   - Quinn Taylor

Re: Newlines when setting svn:ignore from cmdline

Posted by jeremy hinds <je...@gmail.com>.
On Fri, Jul 18, 2008 at 9:27 AM, Quinn Taylor <qu...@mac.com> wrote:
> Jeremy -
> Thanks for the quick turnaround. Judging by your response, I realized I
> should clarify...
>
> <no effective way to script or automate setting multiple items for a
> property>
>
> This borders upon shifting the topic from Subversion to shell
> scripting, but how about something like this Bash function
>
>  function svn_ignore {
>    local target="$1"; shift
>    svn ps svn:ignore "`echo $* | tr ' ' '\n'`" "$target"
>  }
>
> which would let you do
>
>  $ svn_ignore . \*.o \*.exe \*.tmp
>
> It breaks if your ignore patterns have spaces in them, and it only
> works against a single target at a time, but it might work for the
> common case.
>
> I admire your bash scripting kung-fu, and this is a workable solution. My
> point is that the way SVN currently handles the situation, everyone has to
> write some code like this and use a separate function just to accomplish the
> task. I would find it easier if I could do something like:
> svn propset svn:ignore "*.o *.exe *.tmp" target_dir
> or even:
> svn propset svn:ignore "*.o\n*.exe\n*.tmp" target_dir
> Currently, the svn command requires an actual newline in between each item.
> When I use the second form, the property is actually set with the \n
> characters intact.
> Since the svn:ignore property requires one item per line, it makes sense to
> me that it should be able to intelligently process such a string without
> requiring scripting wizardry. I'm a software engineer and not averse to code
> solutions, but let's just say that bash is not mu language of choice. Also,
> introducing an svn_ignore function is one more thing for me (or anyone else)
> to remember, and breaks when I move to a machine that doesn't have it set
> up.
>
> <can't create a simple alias to set multi-line svn:ignore properties on
> multiple directories>
>
> Again, you probably want a function instead of an alias.  You could
>
> supplement the previous function with something like:
>
>  function svn_ignore_multidir {
>    local dir_pattern="$1"; shift
>    # find(1) can't do -exec with a shell function, so loop manually
>    for dir in `find . -name "$dir_pattern"`; do
>      svn_ignore "$dir" $*
>    done
>  }
>
> In this case, it breaks if the subdirectories have spaces in the path,
> but since you're using Bash, I assume that isn't a big limitation.  To
> reproduce the example in the blog you mentioned, you'd do
>
>  $ svn_ignore_multidir \*.xcodeproj \*.pbxuser \*.mode1 \*.mode1v3
>
> Again, I don't really *want* a function, but you're right that this is
> what's required currently. And actually, I'm using Bash on OS X, and I often
> put spaces in directory names. (Even if I didn't, many Mac users do.)
> However, we who use Bash already know how to escape spaces. :-)  If svn were
> to intelligently handle insertion/translation of newlines, I could use a
> simpler alias for something specific like this:
> alias xcode_ignore ="find . -type d -name '*.xcodeproj' | svn propset
> svn:ignore '*.pbxuser\n*.mode1\n*.mode1v3'"
> and only call
> xcode_ignore
> I realize in the end I could define xcode_ignore to call svn_ignore_multidir
> with the same pattern, so please don't think I'm ignorant. :-) I just think
> that the functionality for translating newlines is something that, if built
> into svn itself, could make it more usable by more people without resorting
> to nearly indecipherable (although extremely clever) shell scripting.
> Further, proposed solutions such as these tend to scare away the
> non-technical crowd. Subversion may not be actively campaigning to people
> unfamiliar with version control, but like it or not, it is starting to
> attract that demographic to some degree. Expecting them to write such
> scripts themselves will be an exercise in futility. Even setting multi-line
> properties right now gets people confused.
> Adding \n escaping would make a lot of sense to programmer types like
> myself, and make Subversion easier to work with in general, which I sense is
> the goal. As it is, the current approach feels more like the ugly syntax I'm
> used to seeing in my less-than-pleasant interactions with CVS.  :-P

Point taken - I thought it was more a question of how to
script/customize svn behavior for personal use.  I'm not in a position
to opine on the feasibility/desirability of making those changes to
svn itself, but perhaps someone else here can.


>
> Hope this helps,
> Jeremy
>
> Definitely. Accordingly, I hope this clarifies my point.
>  - Quinn

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Newlines when setting svn:ignore from cmdline

Posted by Quinn Taylor <qu...@mac.com>.
Jeremy -

Thanks for the quick turnaround. Judging by your response, I realized  
I should clarify...

>> <no effective way to script or automate setting multiple items for  
>> a property>
>
> This borders upon shifting the topic from Subversion to shell
> scripting, but how about something like this Bash function
>
>  function svn_ignore {
>    local target="$1"; shift
>    svn ps svn:ignore "`echo $* | tr ' ' '\n'`" "$target"
>  }
>
> which would let you do
>
>  $ svn_ignore . \*.o \*.exe \*.tmp
>
> It breaks if your ignore patterns have spaces in them, and it only
> works against a single target at a time, but it might work for the
> common case.

I admire your bash scripting kung-fu, and this is a workable solution.  
My point is that the way SVN currently handles the situation, everyone  
has to write some code like this and use a separate function just to  
accomplish the task. I would find it easier if I could do something  
like:

	svn propset svn:ignore "*.o *.exe *.tmp" target_dir

or even:

	svn propset svn:ignore "*.o\n*.exe\n*.tmp" target_dir

Currently, the svn command requires an actual newline in between each  
item. When I use the second form, the property is actually set with  
the \n characters intact.

Since the svn:ignore property requires one item per line, it makes  
sense to me that it should be able to intelligently process such a  
string without requiring scripting wizardry. I'm a software engineer  
and not averse to code solutions, but let's just say that bash is not  
mu language of choice. Also, introducing an svn_ignore function is one  
more thing for me (or anyone else) to remember, and breaks when I move  
to a machine that doesn't have it set up.

>> <can't create a simple alias to set multi-line svn:ignore  
>> properties on multiple directories>

> Again, you probably want a function instead of an alias.  You could
> supplement the previous function with something like:
>
>  function svn_ignore_multidir {
>    local dir_pattern="$1"; shift
>    # find(1) can't do -exec with a shell function, so loop manually
>    for dir in `find . -name "$dir_pattern"`; do
>      svn_ignore "$dir" $*
>    done
>  }
>
> In this case, it breaks if the subdirectories have spaces in the path,
> but since you're using Bash, I assume that isn't a big limitation.  To
> reproduce the example in the blog you mentioned, you'd do
>
>  $ svn_ignore_multidir \*.xcodeproj \*.pbxuser \*.mode1 \*.mode1v3

Again, I don't really *want* a function, but you're right that this is  
what's required currently. And actually, I'm using Bash on OS X, and I  
often put spaces in directory names. (Even if I didn't, many Mac users  
do.) However, we who use Bash already know how to escape spaces. :-)   
If svn were to intelligently handle insertion/translation of newlines,  
I could use a simpler alias for something specific like this:

	alias xcode_ignore ="find . -type d -name '*.xcodeproj' | svn propset  
svn:ignore '*.pbxuser\n*.mode1\n*.mode1v3'"

and only call

	xcode_ignore

I realize in the end I could define xcode_ignore to call  
svn_ignore_multidir with the same pattern, so please don't think I'm  
ignorant. :-) I just think that the functionality for translating  
newlines is something that, if built into svn itself, could make it  
more usable by more people without resorting to nearly indecipherable  
(although extremely clever) shell scripting.

Further, proposed solutions such as these tend to scare away the non- 
technical crowd. Subversion may not be actively campaigning to people  
unfamiliar with version control, but like it or not, it is starting to  
attract that demographic to some degree. Expecting them to write such  
scripts themselves will be an exercise in futility. Even setting multi- 
line properties right now gets people confused.

Adding \n escaping would make a lot of sense to programmer types like  
myself, and make Subversion easier to work with in general, which I  
sense is the goal. As it is, the current approach feels more like the  
ugly syntax I'm used to seeing in my less-than-pleasant interactions  
with CVS.  :-P

> Hope this helps,
> Jeremy

Definitely. Accordingly, I hope this clarifies my point.
  - Quinn

Re: Newlines when setting svn:ignore from cmdline

Posted by jeremy hinds <je...@gmail.com>.
On Thu, Jul 17, 2008 at 2:39 PM, Quinn Taylor <qu...@mac.com> wrote:
> Hello everyone, first post...
>
> Setting the svn:ignore property on a directory node requires a newline
> between each item. While one way to do this is to use a file argument,
> creating a file is not always an elegant or compelling solution. This value
> can be set interactively on the command line by putting all the values
> within ' marks and typing a return between each. However, I haven't found a
> way to effectively script or automate this process.

This borders upon shifting the topic from Subversion to shell
scripting, but how about something like this Bash function

  function svn_ignore {
    local target="$1"; shift
    svn ps svn:ignore "`echo $* | tr ' ' '\n'`" "$target"
  }

which would let you do

  $ svn_ignore . \*.o \*.exe \*.tmp
  property 'svn:ignore' set on '.'
  $ svn pg svn:ignore .
  *.o
  *.exe
  *.tmp

It breaks if your ignore patterns have spaces in them, and it only
works against a single target at a time, but it might work for the
common case.


> Step 2 on
> <http://riquedafreak.blogspot.com/2007/12/spring-cleaning-with-subversion.html>
> describes how to set the ignore property for several values on directories
> matching a certain pattern. I would like to make this into a bash alias, but
> so far my attempts to do so have been fruitless, since svn propset doesn't
> do anything intelligent with \n or \r escape characters. To me, this seems
> like a dumb restriction.

Again, you probably want a function instead of an alias.  You could
supplement the previous function with something like

  function svn_ignore_multidir {
    local dir_pattern="$1"; shift
    # find(1) can't do -exec with a shell function, so loop manually
    for dir in `find . -name "$dir_pattern"`; do
      svn_ignore "$dir" $*
    done
  }

In this case, it breaks if the subdirectories have spaces in the path,
but since you're using Bash, I assume that isn't a big limitation.  To
reproduce the example in the blog you mentioned, you'd do

  $ svn_ignore_multidir \*.xcodeproj \*.pbxuser \*.mode1 \*.mode1v3


Hope this helps,
Jeremy


>
> I've researched a few possibly related existing issues, both of which deal
> with auto-props which can be set in user-specific configuration. (On OS X,
> this is found in the ~/.subversion/config file.)
>
>
> Bug #1989 — Make auto-props affect directories
> http://subversion.tigris.org/issues/show_bug.cgi?id=1989
>
> Kevin Ballard suggests using \n for newlines and making auto-props apply to
> directories. The latest comments on this issue say that it's unscheduled,
> but made into a branch of SVN 2 years ago. I would LOVE to see progress and
> a resolution on this, since it would also help solve the problem I'm facing.
> (In fact, such files in .xcodproj directories is one of the problems I'm
> dealing with.)
>
>
> Bug #2068 — No escaping of separator characters in auto-props
> http://subversion.tigris.org/issues/show_bug.cgi?id=2068
>
> This bug relates to the inability to use semicolons within auto-prop values,
> since it's a separator. Introducing an escaped newline might deal with a
> similar issue or part of the Subversion config system.
>
>
> Nothing that I've found so far has dealt with accepting escaped newlines in
> svn:ignore propset strings. Does anyone else feel that this is an issue that
> could stand to be improved?
>
> Thanks,
>  - Quinn Taylor

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org