Remove unnecessary svn:mergeinfo properties

2019-01-07 02:16发布

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.

8条回答
爷的心禁止访问
2楼-- · 2019-01-07 02:26

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
查看更多
三岁会撩人
3楼-- · 2019-01-07 02:34

Rather than just blindly deleting the mergeinfo properties, it's also possible to complete the "missing" merges.

Copy the mergeinfo property from the root folder, and then perform a merge on the child folder for the appropriate relative path and the exact same revision list. (You can, but do not need to, only list the differences between this list and the one already on the child folder.)

Normally this merge should end up only changing the mergeinfo properties, not any actual files. (If it does end up changing files, then one of the previous merges must have only been a partial merge, which may have been causing you problems anyway.)

Doing this should end up deleting the mergeinfo property for you, once you've gotten them both to match exactly. You may also need to do the reverse: merge into the root any merge revisions only present on the child folder (again, you can just paste the full list and let SVN sort out finding the differences for you).

查看更多
SAY GOODBYE
4楼-- · 2019-01-07 02:41

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

查看更多
疯言疯语
5楼-- · 2019-01-07 02:44

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.

查看更多
Juvenile、少年°
6楼-- · 2019-01-07 02:50

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"
查看更多
手持菜刀,她持情操
7楼-- · 2019-01-07 02:50

To do changes in a directory structure, this would be (non-DOS 'find' only):

find . -path "*/.svn" -prune -or -exec svn propdel svn:mergeinfo '{}' \;

Running an 1.6.12 client connected to an 1.5 server, I have a similar problem; there is a subdirectory in the project which needs its own svn:mergeinfo, but having 121 such entries (including 5 directories below ./var with "svn:ignore *") seems somewhat inappropriate. Thus, it would be nice to have a (e.g. Python) script which is able to remove the obviously superfluous merge info and tell about other differences ...

查看更多
登录 后发表回答