Mercurial:重命名后识别文件名 [英] Mercurial: Identify file name after rename
问题描述
Mercurial在整个重命名(hg mv $OLD $NEW
)中跟踪文件的内容,因此hg annotate $NEW
还会以其原始标识显示以前对$OLD
所做的逐行更改.很好.
Mercurial tracks the contents of a file throughout renames (hg mv $OLD $NEW
), so that hg annotate $NEW
also shows up the line-wise changes formerly made to $OLD
with their original identification. That works fine.
但是,似乎没有直接的方法来找到$OLD
文件的名称,在给定的行中$NEW
的祖先所属的文件属于该文件. hg annot $NEW -r$REV
仅适用于rename
变更集.
BUT there seems no straightforward way to find out the name of the $OLD
file, to which some given line has belonged within the ancestry of $NEW
. hg annot $NEW -r$REV
only works down to the rename
changeset.
当然可以通过某种方式访问该信息,例如G.通过爬行hg log
(没有--follow
)并使用某些hg log -r$RENAMEREV -g -p
标识重命名(或通过单击hg serve
的Web界面).
但是,这种工作流程"不仅烦人且容易出错,而且(最重要的是)它不是非交互式/可编写脚本的.
Of course the information is somehow accessible, e. g. by crawling through hg log
(without --follow
) and identifying the renames with some hg log -r$RENAMEREV -g -p
(or by clicking through hg serve
's web interface).
But this "workflow" is not only annoying and error-prone, but [most importantly] it isn't non-interactive/scriptable.
我的问题:有没有一种方法来获取/构建
My question: Is there a way to get/construct either
-
$NEW
的文件名历史记录的一些列表(最好是具有各自的修订范围),或者 - 提交了
$LINE
行的文件的名称(hg annot
的某种文件名选项)?
- some list of the file name history of
$NEW
(best with respective revision ranges), or - the name of the file in which line
$LINE
was commited (some kind of filename option forhg annot
)?
在hg
CLI或Python/hglib中的想法受到赞赏.
Ideas in either the hg
CLI or Python/hglib appreciated.
推荐答案
在您的hg log
模板中包括{file_copies}
关键字:
Either include the {file_copies}
keyword in your hg log
template:
$ hg init demo
$ cd demo
$ touch a
$ hg ci -Am 'file a'
adding a
$ hg mv a b
$ hg ci -Am 'moved to file b'
$ hg log -r . -T"{file_copies}\n"
b (a)
当您设置--copies
标志时,内置模板status
将包含文件复制信息:
The built-in template status
will include file copy info when you set the --copies
flag:
$ hg log -r 1 -Tstatus --copies
changeset: 1:b37952faaddc
tag: tip
user: Martijn Pieters <mjpieters@fb.com>
date: Sun Jul 31 16:07:04 2016 +0100
summary: moved to file b
files:
A b
a
R a
因此,文件b
是从a
中提取的.
So file b
was taken from a
.
有关可在日志输出中包括的更多内容,请参见hg help template
.
See hg help template
for more things you can include in log output.
这篇关于Mercurial:重命名后识别文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!