views:

4463

answers:

6

When I merge stuff in my repository Subversion wants to add/change a lot of svn:mergeinfo properties to files that are totally unrelated to the things that I want to merge. Questions about this behaviour have been asked before here on Stackoverflow.com, as you can read here and here.

From what I understand from the topics mentioned above it looks like a lot of files in my repository have explicit svn:mergeinfo properties on them, when they shouldn't. The advice is to reduce the amount and only put those properties on relevant files/folders.

So now my question: how can I easily remove those unneeded properties? I'm using TortoiseSVN, but am reluctant to manually check/fix hundreds of files. Is there an easier way to remove those unnecessary svn:mergeinfo properties?

P.S. I'm not looking for C++ SVN API code.

+1  A: 

I'm using TortoiseSVN, but am reluctant to manually check/fix hundreds of files. Is there an easier way to remove those unnesscery svn:mergeinfo properties?

If the number of properties you want to keep is very small relative to the ones you want to delete, I'd just use the command line to remove them all and add them back to the ones you want:

svn propdel svn:mergeinfo *
svn propadd ... [files to add to]
John Feminella
This will of course remove all mergeinfo properties, not just the ones that he doesn't want. I assume that he's seeing the same as I do, lots of empty mergeinfo properties.
Lasse V. Karlsen
@John: As Lassevk said that would also remove valid mergeinfo properties, which is something I do not want to happen.
LeonZandman
If you don't expect to merge things back to this branch (which could be the case on trunk if all development happens there), removing all mergeinfo from trunk can certainly help with merging to future branches.
Bert Huijben
+6  A: 

As mentioned in this thread:

  • Most empty mergeinfo ("blank") can be caused by working copy to working copy copies/moves where the source item has no explicit mergeinfo. a propdel can be the solution unless you are using a 1.6 SVN: since 1.5.5 these WC-to-WC copies no longer create empty mergeinfo on the destination
  • an earlier svn move (rename) restructuring operation can also propagate those mergeinfo (instead of leaving them at the root directory)
  • there is a potential memory issue, tracked by the case 3393 and which will be fixed in an upcoming 1.6.2 version (and back-ported in 1.5)
VonC
+1  A: 

If you're sure you want to mass-remove mergeinfo properties, you can use the following BASH script.

FILES=`svn status |grep "^ M      " |sed s/" M      "// |tr '\n', ' '`
svn revert $FILES

It gets a list of changed files, filters it to just mergeinfo only changes, strips everything but the actual file path, converts the one-per-line paths into a space delimited list, and the calls revert on that list.

Chase Seibert
Thanx, but as you may have known from me mentioning TortoiseSVN I'm a Windows user and don't use the Bash shell :-)
LeonZandman
The same thing should be possible in DOS, albeit probably not as terse.
Chase Seibert
Doesn't this only revert files with modified mergeinfo on the current working directory? If so, it doesn't address the problem: the existing explicit mergeinfo. For that, you'd need to propdel.
Domster
+1  A: 

Here is a way to delete all subtree svn:mergeinfo properties. Run it inside the root of your repository:

svn propget svn:mergeinfo --depth=infinity 
    | grep -v "^/"
    | grep -v "^\."   
    | cut -d- -f1 
    | xargs svn propdel svn:mergeinfo

All in one line for easy copy/pasting:

svn propget svn:mergeinfo --depth=infinity | grep -v "^/" | grep -v "^\." | cut -d- -f1 | xargs svn propdel svn:mergeinfo

To preview which files this will effect before you run it, change the last "propdel" to "propget" or remove the last xargs pipe altogether.

Kelvin
Works with hyphens in files:svn propget -R svn:mergeinfo | grep -v "^/" | grep -v "^\." | cut "-d " -f1 | xargs svn propdel svn:mergeinfo
Squirrel
A: 

I know it's been a while, but I ran into a similar problem. I'm using TortoiseSVN 1.6.7. It just so happened that the property was on the root of my working copy. When I viewed the properties on the root and clicked Remove on svn:mergeinfo, it asked me if I want to remove it recursively. This got rid of all of my svn:mergeinfo cockups.

HackedByChinese
+11  A: 

Here is another way to delete all sub tree svn:mergeinfo properties but not at the root folder (this is needed for branching to work properly).

From the root of the project do:

svn propdel svn:mergeinfo -R
svn revert .
svn ci -m "Removed mergeinfo"
Vincent