Remove unnecessary svn:mergeinfo properties

67,101

Solution 1

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"

Solution 2

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.

Solution 3

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. Using 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 mergeinfo, instead of leaving them at the root directory
  • there is a potential memory issue, tracked by case 3393 which will be fixed in an upcoming 1.6.2 version and back-ported in 1.5

Solution 4

As I am not confident with blind svn:merge-info property deletion, I have implemented a tool to analyze the current situation on a working copy and remove as much merge revisions as possible from non-root merge-info properties. After additional human checks and controls, the changes on the working copy can be committed.

Here it is: svn-clean-mergeinfo

Do not hesitate to report any issue about its usage to get it improved.

Subversion 1.10 introduces a new tool dedicated to that task: svn-mergeinfo-normalizer

Solution 5

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.

Share:
67,101
LeonZandman
Author by

LeonZandman

Updated on September 23, 2020

Comments

  • LeonZandman
    LeonZandman over 3 years

    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 Stack Overflow:

    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 I 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.

  • LeonZandman
    LeonZandman over 14 years
    Thanx, but as you may have known from me mentioning TortoiseSVN I'm a Windows user and don't use the Bash shell :-)
  • Chase Seibert
    Chase Seibert over 14 years
    The same thing should be possible in DOS, albeit probably not as terse.
  • Nicholas
    Nicholas over 14 years
    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.
  • Squirrel
    Squirrel almost 14 years
    Works with hyphens in files: svn propget -R svn:mergeinfo | grep -v "^/" | grep -v "^\." | cut "-d " -f1 | xargs svn propdel svn:mergeinfo
  • JeremyWeir
    JeremyWeir about 13 years
    Or, just don't do it on the root dir "svn propdel -R svn:mergeinfo ./*"
  • andrewd18
    andrewd18 over 12 years
    I was in the same situation. Worked for me. Thanks!
  • Charles Duffy
    Charles Duffy over 10 years
    This is quite buggy -- have a filename with whitespace in its name? With glob characters in its name? Bad news in either case. The approved/supported way to parse the output from svn status is using the --xml flag and an XML parser; anything else can change between versions, as forwards compatibility on the textual output format is not guaranteed.
  • Peter
    Peter over 10 years
    "svn propdel -R svn:mergeinfo ./* ./.[^.]*" if you also have "dot" / *ix hidden files, probably not a problem for a Windows user per the question.
  • bebbo
    bebbo almost 10 years
    suppressing the output speeds it up: "svn propdel svn:mergeinfo -R >nul" (or >/dev/null using Linux)
  • davenpcj
    davenpcj over 8 years
    This tool is great for consolidating merge-info properties, like the kinds that get created with partial subdirectory merges which many less than perfectly coordinated developers on a large team may create. The tool seems to have an issue with files that don't exist in every branch, I get leftover merge-info properties on files indicating revisions on branches in which the file never existed.
  • Yves Martin
    Yves Martin over 8 years
    I agree it is not perfect... that is why "human checks and controls" are still required. In your case, if you have identified non relevant revisions in merge-info properties, you can remove these revisions or the whole svn:merge-info property on that files before committing. Please use github to ask for improvements.
  • TT.
    TT. about 8 years
    @JeremyWeir What do you mean by "just don't do it on the root dir"? Where from then? You have a lot of upvotes on that comment, but I'm not seeing the alternative.
  • JeremyWeir
    JeremyWeir about 8 years
    @TT. I think the idea is to just go to the dir that has all the messed up merge info and do it from there, so you don't have to revert the root directory. You don't want to mess with the mergeinfo of the root.