简体   繁体   English

删除不必要的 svn:mergeinfo 属性

[英]Remove unnecessary svn:mergeinfo properties

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.当我在我的存储库中合并东西时,Subversion 想要添加/更改很多svn:mergeinfo属性到与我想要合并的东西完全无关的文件中。

Questions about this behaviour have been asked before here on Stack Overflow:之前在 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.根据我对上述主题的理解,我的存储库中的很多文件似乎都有明确的svn:mergeinfo属性,而实际上它们不应该。 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.我正在使用 TortoiseSVN,但我不愿意手动检查/修复数百个文件。 Is there an easier way to remove those unnecessary svn:mergeinfo properties?有没有更简单的方法来删除那些不必要的svn:mergeinfo属性?

PS I'm not looking for C++ SVN API code. PS 我不是在寻找 C++ SVN API 代码。

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).这是删除所有子树 svn:mergeinfo 属性但不在根文件夹中的另一种方法(这是分支正常工作所必需的)。

From the root of the project do:从项目的根目录执行:

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

Here is a way to delete all subtree svn:mergeinfo properties.这是一种删除所有子树 svn:mergeinfo 属性的方法。 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.要在运行之前预览这将影响哪些文件,请将最后一个“propdel”更改为“propget”或完全删除最后一个 xargs 管道。

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除非您使用 1.6 SVN,否则使用 propdel 可能是解决方案:从 1.5.5 开始,这些 WC-to-WC 副本不再在目标上创建空的 mergeinfo
  • an earlier svn move (rename) restructuring operation can also propagate mergeinfo, instead of leaving them at the root directory较早的 svn move (rename) 重组操作也可以传播 mergeinfo,而不是将它们留在根目录中
  • 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有一个潜在的内存问题,由案例 3393跟踪,将在即将发布的 1.6.2 版本中修复并在 1.5 中向后移植

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.由于我对盲目svn:merge-info属性删除没有信心,我已经实现了一个工具来分析工作副本的当前情况,并从非根合并信息属性中删除尽可能多的合并修订。 After additional human checks and controls, the changes on the working copy can be committed.在额外的人工检查和控制之后,可以提交对工作副本的更改。

Here it is: svn-clean-mergeinfo这里是: 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 Subversion 1.10 引入了一个专用于该任务的新工具: svn-mergeinfo-normalizer

I know it's been a while, but I ran into a similar problem.我知道已经有一段时间了,但我遇到了类似的问题。 I'm using TortoiseSVN 1.6.7.我正在使用 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.当我查看根目录上的属性并单击 svn:mergeinfo 上的删除时,它询问我是否要递归删除它。 This got rid of all of my svn:mergeinfo cockups.这摆脱了我所有的 svn:mergeinfo cockups。

If you're sure you want to mass-remove mergeinfo properties, you can use the following BASH script.如果您确定要批量删除 mergeinfo 属性,可以使用以下 BASH 脚本。

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.它获取已更改文件的列表,将其过滤为仅合并信息更改,删除除实际文件路径之外的所有内容,将每行路径转换为空格分隔列表,然后在该列表上恢复调用。

Rather than just blindly deleting the mergeinfo properties, it's also possible to complete the "missing" merges.除了盲目地删除 mergeinfo 属性,还可以完成“丢失”的合并。

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.从根文件夹复制 mergeinfo 属性,然后对子文件夹执行合并以获取适当的相对路径和完全相同的修订列表。 (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.通常,此合并最终应该只更改 mergeinfo 属性,而不是任何实际文件。 (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.一旦你让它们完全匹配,这样做应该最终会为你删除 mergeinfo 属性。 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).您可能还需要执行相反的操作:将仅存在于子文件夹中的任何合并修订合并到根目录中(同样,您可以粘贴完整列表并让 SVN 为您找出差异)。

To do changes in a directory structure, this would be (non-DOS 'find' only):要在目录结构中进行更改,这将是(仅非 DOS 'find'):

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;运行连接到 1.5 服务器的 1.6.12 客户端,我有类似的问题; 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.项目中一个子目录需要它自己的 svn:mergeinfo,但是有 121 个这样的条目(包括 ./var 下面的 5 个目录,带有“svn:ignore *”)似乎有点不合适。 Thus, it would be nice to have a (eg Python) script which is able to remove the obviously superfluous merge info and tell about other differences ...因此,最好有一个(例如 Python)脚本,它能够删除明显多余的合并信息并讲述其他差异......

Run from the root of your repository to delete svn:mergeinfo properties:从存储库的根目录运行以删除 svn:mergeinfo 属性:

  • Command for Bash: svn propdel -R -q svn:mergeinfo `svn ls` Bash 命令: svn propdel -R -q svn:mergeinfo `svn ls`
  • Command for PowerShell: svn propdel -R -q svn:mergeinfo (svn ls) PowerShell 命令: svn propdel -R -q svn:mergeinfo (svn ls)

Benefits of this command:此命令的好处:

  1. It processes subtree, but not the root directory;它处理子树,但不处理根目录;
  2. It processes hidden ("dot") files;它处理隐藏(“点”)文件;
  3. It ignores files, that aren't under version control.它会忽略不受版本控制的文件。

PS. PS。 Command may fail if you have committed files with spaces (or other unusual symbols?) in their names in the root directory.如果您在根目录中提交了名称中包含空格(或其他不寻常符号?)的文件,命令可能会失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM