Mercurial:重命名后识别文件名 [英] Mercurial: Identify file name after rename

查看:114
本文介绍了Mercurial:重命名后识别文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 for hg 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆