How to use subversion's propset against a URL?
Asked Answered
J

4

10

Is it possible to manipulate a subversion property such as svn:externals via a URL only? (i.e. without having a working copy.)

I'd like a script that pins svn:externals to a particular revision given a subversion URL, but this seems to be impossible:

$ svn propset foo bar https://example.com/svn/myproject/trunk
svn: Setting property on non-local target 'https://example.com/svn/myproject/trunk' needs a base revision

$ svn propset foo bar -r HEAD https://example.com/svn/myproject/trunk
svn: Try 'svn help' for more info
svn: Cannot specify revision for setting versioned property 'foo'

$ svn propset foo bar --revprop -r HEAD https://example.com/svn/myproject/trunk
svn: DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent
svn: At least one property change failed; repository is unchanged
svn: Error setting property 'foo': 
could not remove a property

(I get the same results if I use an actual revision number instead of HEAD as well.)

Juliennejuliet answered 11/1, 2012 at 12:57 Comment(0)
H
4

No. Changing a property on a file is like changing the file itself -- you need a working directory. There are a few Subversion commands that change the commit without requiring a working copy: svn cp, svn mkdir, and svn delete. Everything else needs a working directory in order to make changes.

By the way, you can make changes on revision properties without a working copy. Revision properties are things like the commit comment (svn:log), the committer's ID (svn:author), and the time of the commit (svn:date).

Headspring answered 11/1, 2012 at 17:49 Comment(3)
A workaround seems to be to svn checkout --depth=empty into a temporary directory with mktemp or similar (this is fairly fast), use svn propset to make the change, commit, and then remove the temporary directory.Juliennejuliet
There is another option: svnmucc, which is included with SVN sources but not built or installed by default. You can read about it at svnbook.red-bean.com/en/1.8/svn.ref.svnmucc.re.html.Pompey
Adding to note by @trent, TortoiseSVN is now bundling svnmucc with installer as of version 1.8.1 and newer sourceforge.net/p/tortoisesvn/tickets/496Bathtub
W
9

Yes, although it's a bit of a hack; svn propedit can change URL targets:

svn propedit foo --editor-cmd "echo bar>" http://example.com/svn/myproject/trunk -m "Property changed"

Weather answered 30/7, 2013 at 18:12 Comment(1)
that's a great trick but it's better to specify the message in commandline via -m flag otherwise the editor will be invoked for the message too.Kendall
S
7

You can use the svnmucc command to non-interactively set properties of an URL such as svn:externals.

Example:

$ svnmucc --root-url https://example.com/svn -m 'reference other/yap' \
   propset svn:externals "^/otherproject/tag/xyz other
^/yetanother/tag/123 yap" myproject/trunk

Note that svnmucc also supports other commands besides propset and it is possible to chain multiple commands in one call (hence the name). The result is just one changeset.

The svnmucc command is part of the subversion source package and usually available via the distribution's package manager. For example, Fedora 25 includes it in the subversion-tools package. OpenCSW even includes it in the main subversion package.

Saporous answered 4/3, 2017 at 14:30 Comment(2)
Multi-line in windows is not allowed. command breaks after the first property. and if I write it in continues single line it treats it as single property. whats the solution to run this command on windows?Hustings
@SahilDoshi I'm not a Windows user - but when I use Windows I install Cygwin and do such stuff in a Cygwin terminal. Since then you are in a standard shell (such as bash) you should be able to work with line continuations and multi line quoted strings like in a Linux/UNIX environment.Saporous
H
4

No. Changing a property on a file is like changing the file itself -- you need a working directory. There are a few Subversion commands that change the commit without requiring a working copy: svn cp, svn mkdir, and svn delete. Everything else needs a working directory in order to make changes.

By the way, you can make changes on revision properties without a working copy. Revision properties are things like the commit comment (svn:log), the committer's ID (svn:author), and the time of the commit (svn:date).

Headspring answered 11/1, 2012 at 17:49 Comment(3)
A workaround seems to be to svn checkout --depth=empty into a temporary directory with mktemp or similar (this is fairly fast), use svn propset to make the change, commit, and then remove the temporary directory.Juliennejuliet
There is another option: svnmucc, which is included with SVN sources but not built or installed by default. You can read about it at svnbook.red-bean.com/en/1.8/svn.ref.svnmucc.re.html.Pompey
Adding to note by @trent, TortoiseSVN is now bundling svnmucc with installer as of version 1.8.1 and newer sourceforge.net/p/tortoisesvn/tickets/496Bathtub
G
0

Building upon Willem's excellent answer, here's an example showing how to set SVN auto-props for needs-lock for all files and mime-type for particular extensions using a URL:

svn propedit svn:auto-props --editor-cmd "echo \"* = svn:needs-lock=*
*.os = svn:mime-type=application/octet-stream
*.osproj = svn:mime-type=application/octet-stream\" >" http://example.com/svn/myproject/trunk -m "Setting auto-props."
Gaol answered 18/9, 2015 at 17:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.