当使用 svn cp 或 svn mv 时,如何使 svn diff 生成补丁将应用的文件?

发布于 2024-07-10 01:08:01 字数 332 浏览 6 评论 0原文

场景是:

  1. svn cp 或 mv 某个文件
  2. 修改该文件
  3. svn diff > > mypatch

在其他机器上(相同的工作副本,但没有更改):

  1. 尝试应用 mypatch。
  2. 失败-> 尝试修改不存在的文件。

在这种情况下,如何使 svn diff 生成适用于补丁的补丁,或者干净地应用 svn diff 生成的补丁? 我无法承诺。 我想保留合并信息(因为明显的解决方法是将文件添加为全新的文件,而不连接到前一个文件)。

The scenario is:

  1. svn cp or mv some file
  2. modify that file
  3. svn diff > mypatch

On other machine (same working copy, but no changes):

  1. Try to apply mypatch.
  2. Fail -> tries to modify unexistant file.

How can I make svn diff produce patch-appliable patch, or cleanly apply patch produced by svn diff in this case? I can't commit. I would like to preserve mergeinfo (because the obvious workaround is to add the file as totally new, without connection to the previous one).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

撩人痒 2024-07-17 01:08:01

使用 subversion,您可以指定要使用的 diff 二进制文件以及要传递给它的参数。 请参阅关于 svn diff 的手册

您希望从 svn diff 生成常规补丁文件,因此您希望 svn diff 看起来像普通 diff。 试试这个:

svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
...
patch -p0 < mypatch

概念证明:

echo "newline" >> README.txt
svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
cp README.txt README.txt.patched
svn revert README.txt
patch -p0 < mypatch
diff README.txt README.txt.patched

修补后两个文件没有区别。

With subversion, you can specify which diff binary to use, and parameters to pass to it. See the manual on svn diff.

You'd want to produce a regular patch file from a svn diff, so you'd want the svn diff to look like a normal diff. Try this:

svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
...
patch -p0 < mypatch

Proof of concept:

echo "newline" >> README.txt
svn diff --diff-cmd /usr/bin/diff -x "-i -b" > mypatch
cp README.txt README.txt.patched
svn revert README.txt
patch -p0 < mypatch
diff README.txt README.txt.patched

No difference in the two files after patching.

唯憾梦倾城 2024-07-17 01:08:01

如果你想在补丁中删除 svn 属性,有一个选项:

svn diff --patch-compatible > mypatch.diff

svn help diff 说:

  --patch-compatible   : generate diff suitable for generic third-party
                         patch tools; currently the same as
                         --show-copies-as-adds --ignore-properties

以这种方式创建的补丁应该与旧的普通 兼容。代码>补丁实用程序。

If you want to get rid of the svn properties as well in your patches, there is an option for that:

svn diff --patch-compatible > mypatch.diff

svn help diff says:

  --patch-compatible   : generate diff suitable for generic third-party
                         patch tools; currently the same as
                         --show-copies-as-adds --ignore-properties

Patches created this way are supposed to be compatible with the good old plain patch utility.

人间不值得 2024-07-17 01:08:01

您是否尝试过 svn diff 网页并在 svn 选项页面?

Have you tried the --show-copies-as-adds option mentioned on the svn diff web page and described on the svn options page?.

咆哮 2024-07-17 01:08:01

如果不了解您正在尝试处理的具体场景,就很难确定您想要这样做的原因。 我感觉您正在尝试在隔离的环境中进行受控更改,以避免影响其他用户/应用程序。

你能通过以下方式解决这个问题吗?

  • 为您的代码更改创建一个分支
  • 在分支上执行复制/移动和更改
  • 让另一方切换到这个新的代码分支并继续共享此分支

当你们都同意将更改合并回主干时,使用 - - 重新整合论点并 rm 分支?

这个会
* 维护合并信息
* 识别版本控制中的复制/移动和更改
* 仍然隔离其他用户的更改
* 将防止第 2 步期间出现不完整的更改,因为您只需添加更多更改并更新即可

Without understanding the specific scenario you're trying to work upon its hard to identify why you'd want to do this. I get the feeling you're trying to make controlled changes in an isolated environment so to avoid impacting other users/applications.

Could you solve this problem by;

  • Create a branch for your code change
  • Perform your copy/move and changes on the branch
  • Get the other party to switch to this new code branch and carry on sharing this branch

When you've both agreed with the changes merge back into trunk using the --reintegrate argument and rm the branch?

This would
* Maintain merge-info
* Identify the copy/move and changes in version control
* Still isolate changes from other users
* Would prevent incomplete changes during step 2 being an issue as you could just add more changes and update

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文