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

发布于 2024-10-06 09:12:15 字数 218 浏览 1 评论 0原文

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

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

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

谢谢....

As title, If I do copy from one 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....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

吖咩 2024-10-13 09:12:15

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

使用详细模式 以及--copies 来查找文件是否已使用hg copy< 使用/代码> 命令

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

白日梦 2024-10-13 09:12:15

使用 --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 "."

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 "."
无声静候 2024-10-13 09:12:15

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

hg log file2 -r 0:

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

hg log file2 -r 0:1

输出:

[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

但可能有更好的方法。

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.

怪异←思 2024-10-13 09:12:15

一种直接的方法似乎是使用 hg status

相关选项:

-C --copies 显示复制文件的来源
   --change REV 列出修订版的已更改文件

例如,在将 file 复制到 file2 假设修订版 12345 的问题中的示例之后:

hg status -C --change 12345

将产生如下内容:

M path\to\modified1.txt
M path\to\modified2.txt
A path\to\file2
  path\to\file1

最后两行反映了添加的文件和它的起源。

前两个文件可能是在同一提交中修改的其他文件。

如果要排除不是副本的文件,请添加 -a 选项(“仅显示添加的文件”)。

A direct way seems to be to use hg status.

Relevant options:

-C --copies              show source of copied files
   --change REV          list the changed files of a revision

For example, after the example in the question where file was copied to file2 assuming that was revision 12345:

hg status -C --change 12345

would yield something like this:

M path\to\modified1.txt
M path\to\modified2.txt
A path\to\file2
  path\to\file1

The last two lines reflect the added file and its origin.

The first two files could be some others that were modified in the same commit.

If you want to exclude files that were not copies, add the -a option ("show only added files").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文