开发者

How can I find parent file of one single file after copying?

As title, If I do copy from o开发者_Python百科ne file to destination file, then I commit the change. Afterwards I want to find parent file of copied file, How can I do? for example...

hg copy file1 file2

hg ci -m "copy file1 to file2"

how to find parent of file2? If I use hg parents command, only find parent of changeset not file2.

thanks....


hg log provides the facility

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

Use the verbose mode and also --copies to find if the file has been used using hg copy command


Use --template for format log:

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

Filter empty strings (first line - in Unix, second - in Windows):

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


Well, one way is that you can do a diff of the file:

hg log file2 -r 0:

If you know the changeset where it was introduced you should specify that after the colon:

hg log file2 -r 0:1

The output:

[C:\Temp\repo] :hg diff test2.txt -r 0:1
diff --git a/test1.txt b/test2.txt
copy from test1.txt
copy to test2.txt

But there could be better ways.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜