alastairs
alastairs

Reputation: 6805

Why is this PowerShell script deleting svn:mergeinfo from the root directory?

We have a script to delete the svn:mergeinfo property from all folders inside a Subversion working copy, but not the working copy root directory itself. It's currently an NAnt build script invoked via a separate batch file, so I'm trying to replace it with a simpler PowerShell script. I've had three attempts at it, ranging from the naïve to the slightly more sophisticated. All three fail my criteria, outputting the line property 'svn:mergeinfo' deleted from '.'.

Checking the SVN properties of the working copy root indicates that the svn:mergeinfo property has indeed been removed from this folder which is not what I want. Each version is designed to be run from the working copy root.

Attempt 1:

# I understand why this one fails, it's a poor attempt.
Get-ChildItem -Recurse | svn propdel svn:mergeinfo -R $_

Attempt 2:

# This one correctly lists everything except the working copy root, but
# still removes the svn:mergeinfo property from the working copy root.
Get-ChildItem -Recurse -Exclude $pwd | svn propdel svn:mergeinfo -R $_

Attempt 3:

# Again, this one works fine until the svn propdel is added.
Get-ChildItem | ForEach-Object { ls -R $_ } | svn propdel svn:mergeinfo -R $_

Any thoughts on where the flaw in my logic is?

Upvotes: 3

Views: 242

Answers (1)

Roman Kuzmin
Roman Kuzmin

Reputation: 42073

svn is an external application and you cannot use PowerShell piping technique directly with it. I am not familiar with svn syntax and can be wrong about the details but all your commands presumably should use ForEach-Object (%). That is:

... | %{ svn propdel svn:mergeinfo -R $_ }

Then svn should “understand” the $_ correctly. Also, it is quite possible that you should use something like $_.FullName or $_.Name instead of $_ (again, because svn is an external application and it expects a string (e.g. $_.FullName/$_.Name), not an object $_). NB: $_ is often converted to strings as expected automatically but this is not always the case.

Upvotes: 3

Related Questions