9

开发人员修复了从主干创建的分支中的错误。然后我测试分支并重新集成回主干。

最近我也在进行属性更改。我一遍又一遍地将三个文件提交回主干。我使用 svn 比较了两个版本之间的文件内容,它们是相同的。只有一些属性发生了变化。

Q1:有什么办法可以让我只从命令行提交M只有在我这样做时才在第一列中的文件svn st

Q2:有什么办法可以清理trunk或者如何摆脱一遍又一遍地提交这三个文件?

---- 编辑 svn st 给我

 M      .
 M      controllers/database/udfs/searchForNameContSrch.sql
 M      controllers/eduMoodleInterface
 M      controllers/main
 M      controllers/teaching
 M      lib/utils/EduMail.php
 M      lib/views/learning/progress/reverse_template_converter.php
M       pages/carer/carer_basepage.php
M       pages/common/contact_list_detail_basepage.php
M       pages/contact/contact_basepage.php
M       pages/staff/staff_basepage.php
M       pages/student/student_basepage.php

当前的解决方案是在提交之前还原第二列中包含 M 的文件。它有效,但很耗时。还有什么想法吗?

4

2 回答 2

7

I'd be more inclined to figure out what's going on with the properties and solve that problem than try to just ignore them. That said, at the end of this answer, there's a one-liner that will speed up your revert process if you're on linux.

For the sake of this answer, I've set a property on one file ( window.c ) and modified another ( window.h ).

svn status
 M      window.c
M       window.h

The main commands svn use for properties are:

svn propset answer 42 window.c
property 'answer' set on 'window.c'

Sets a propety 'answer' on file window.c to value 42. You're probably not wanting to use this.

svn proplist window.c
Properties on 'window.c':
  svn:keywords
  svn:eol-style
  answer

Lists all of the properties (without values) on the file.

svn propget answer window.c
42

Gets the value of a specific property.

svn propedit answer window.c
Set new value for property 'answer' on 'window.c'

Opens up an editor (on my machine it's nano of all things) and lets you edit the property, then sets it on the given file.

svn propdel answer window.c
property 'answer' deleted from 'window.c'.

Deletes the specified property (this probably won't resolve your problem, my guess).

You can also do the svn diff to find out which property is different:

svn diff window.c
Index: window.c
===================================================================
--- window.c    (revision 35712)
+++ window.c    (working copy)

Property changes on: window.c
___________________________________________________________________
Added: answer
## -0,0 +1 ##
+42
\ No newline at end of property

This basically says that the only change here is a property 'answer' has been added, with value 42 (and no newline).

So what I'd do Start with svn diff and find out what's changed:

svn diff controllers/database/udfs/searchForNameContSrch.sql
svn diff controllers/main

Have a google for the property that is changing and see if you can figure out what tool is setting it and turn it off.

You could try using svn propdelete to ditch the properties, but I don't think that's going to help.

Failing that -- a quick revert script

Otherwise, if you're using linux, this one liner will revert the files that have property modifications, but not content modifications.

PLEASE TEST THIS ON NON-CRITICAL UPDATES THE FIRST TIME, YES?!?!?

svn status | grep "^ M" | sed "s/^.\{8\}//" | while read rv; do svn revert $rv; done

That is:

  • svn status

  • pipe it through grep and filter for ONLY lines that start with ' M' (so it will ignore 'MM' - important).

  • pipe it through sed and delete the first 8 characters (which are all the status columns before the file name).

  • pipe that into a loop and revert the given file name.

Here it is in action:

svn status
 M      window.c
M       window.h
svn status | grep "^ M" | sed "s/^.\{8\}//" | while read rv; do svn revert $rv; done
Reverted 'window.c'
svn status
M       window.h
于 2013-06-08T02:18:39.057 回答
1

您写道,当您重新集成回 trunk时,这些属性会发生变化,所以我猜更改的属性是svn:mergeinfo,但您需要验证这一点。

假设上述情况,请查看以下来源以了解mergeinfo您确实想要提交这些更改以及为什么要提交这些更改此外,如果您坚持更严格的合并过程,则可以清理这些属性并且不会让它们再次出现 - 即始终在主干/分支根目录上运行合并。这种方式mergeinfo只会记录在那些目录上,而不是单个文件上。这样做的好处是不会因为散落在各处而污染您的存储库mergeinfo,并且还可以使您的提交差异更清晰。

资料来源:

于 2013-06-13T06:25:38.633 回答