复制后如何找到单个文件的父文件?

问题描述 投票:0回答:3

如标题所示,如果我确实从一个文件复制到目标文件,那么我会提交更改。之后我想找到复制文件的父文件,我该怎么办?例如...

hg copy file1 file2
hg ci -m "copy file1 to file2"

如何找到file2的父文件?如果我使用 hgparents 命令,则只能查找变更集的父级而不是 file2。

谢谢....

mercurial
3个回答
7
投票

hg log 提供了便利

hgt $ hg log --copies -v b.py 
changeset:   1:a9c003a9bddb
tag:         tip
user:        "xxxxx"
date:        Mon Dec 06 01:40:01 2010 -0800
files:       b.py
copies:      b.py (a.py)
description:
copied file

使用

verbose mode
--copies
查找文件是否已使用
hg copy
命令

使用

2
投票

使用 --template 格式化日志:

hg log --template "{file_copies}\n" file2.txt

过滤空字符串(第一行 - 在 Unix 中,第二行 - 在 Windows 中):

hg log --template "{file_copies}\n" file2.txt | grep .
hg log --template "{file_copies}\n" file2.txt | findstr /R "."

0
投票

嗯,一种方法是您可以对文件进行比较:

hg 日志文件2 -r 0:

如果您知道引入它的变更集,您应该在冒号后指定:

hg 日志文件2 -r 0:1

输出:

[C:\温度
epo] :hg diff test2.txt -r 0:1
diff --git a/test1.txt b/test2.txt
从 test1.txt 复制
复制到test2.txt

但是可能有更好的方法。

© www.soinside.com 2019 - 2024. All rights reserved.