[英]Generate Hg diff (or patch) that Only includes content for files modified by a revision/revset
Given a large codebase and two revisions or revsets (say, a local 'source' and a target) which may or may not share a recent parent and usually contain a large number of non-relevant file deltas; 给定一个较大的代码库和两个修订或修订版(例如,本地“源”和目标),它们可能共享也可能不共享最近的父目录,并且通常包含大量不相关的文件增量;
How can diff output be generated to compare the changes only for files that are modified in the source revset itself? 如何生成差异输出以仅比较在源revset本身中修改的文件的更改?
(This should be the delta between the ancestry; but only for the files contained within the revset.) (这应该是祖先之间的差异;但仅适用于修订集中包含的文件。)
Using hg diff -r target -r source
shows all the changes in the ancestry, even for files not modified by the source sevision. 使用
hg diff -r target -r source
显示祖先中的所有更改,即使对于未由source sevision修改的文件也是如此。
In addition, this should be done without any knowledge of the directory structure. 此外,这应该在不了解目录结构的情况下进行。
If I understand correctly, you want a diff between revs source
and target
, but you want to restrict it to the files that were modified in changeset source
. 如果我理解正确,那么您希望在revs
source
和target
之间有所区别,但您希望将其限制为在changesset source
中修改的文件。 You can do it in two steps (easily assembled into one with an alias or shell script): 您可以分两步来完成此操作(使用别名或shell脚本轻松地将其组装成一个步骤):
List the files modified in source
: 列出在
source
修改的文件:
hg log -r source --template '{files}'
This just outputs a list of filenames. 这只是输出文件名列表。
Request a diff for these files: 请求这些文件的差异:
hg diff -r target -r source $(hg log -r source --template '{files}')
Step 2 is a bash command with "command substitution" $(...)
, which inserts the output of step one. 步骤2是带有“命令替换”
$(...)
的bash命令,它将插入步骤1的输出。 Other methods are possible. 其他方法也是可能的。
From hg help diff
从
hg help diff
If only one revision is specified then that revision is compared to the working directory
如果仅指定一个修订,则将该修订与工作目录进行比较
ie you can try hg up $SOURCE; hg diff -r $TARGET
即您可以尝试
hg up $SOURCE; hg diff -r $TARGET
hg up $SOURCE; hg diff -r $TARGET
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.