在 hg 状态中显示重命名?

发布于 2024-08-29 19:06:06 字数 439 浏览 3 评论 0原文

我知道 Mercurial 可以跟踪文件的重命名,但是当我执行 hg status 时,如何让它显示我的重命名而不是添加/删除?例如,而不是:

A bin/extract-csv-column.pl
A bin/find-mirna-binding.pl
A bin/xls2csv-separate-sheets.pl
A lib/Text/CSV/Euclid.pm
R src/extract-csv-column.pl
R src/find-mirna-binding.pl
R src/modules/Text/CSV/Euclid.pm
R src/xls2csv-separate-sheets.pl

我想要一些指示,表明四个文件已被移动。

我想我在某处读到输出是这样的,以保持与某些东西的向后兼容性,但我并不担心这一点。

I know that Mercurial can track renames of files, but how do I get it to show me renames instead of adds/removes when I do hg status? For instance, instead of:

A bin/extract-csv-column.pl
A bin/find-mirna-binding.pl
A bin/xls2csv-separate-sheets.pl
A lib/Text/CSV/Euclid.pm
R src/extract-csv-column.pl
R src/find-mirna-binding.pl
R src/modules/Text/CSV/Euclid.pm
R src/xls2csv-separate-sheets.pl

I want some indication that four files have been moved.

I think I read somewhere that the output is like this to preserve backward-compatibility with something-or-other, but I'm not worried about that.

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

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

发布评论

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

评论(2

带刺的爱情 2024-09-05 19:06:06

有几种方法可以做到这一点。

在提交之前,您可以使用 hg diff --git 显示重命名的内容:

$ hg diff --git
diff --git a/theTest.txt b/aTest.txt
rename from theTest.txt
rename to aTest.txt

请注意,这仅在您使用 hg mvhg rename 或 mvhg addremove --similarity 100

提交后,您仍然可以使用 hg diff,但必须使用 -r 指定更改:

$ hg diff -r 0 -r 1 --git
diff --git a/test.txt b/theTest.txt
rename from test.txt
rename to theTest.txt

对于 hg statushg log,使用 -C 命令行标志查看文件复制的源。

$ hg status -C
A aTest.txt
  theTest.txt
R theTest.txt

aTest.txt 正下方的行表示复制的源 (theTest.txt)。

$ hg log -v -C
changeset:   1:4d7b42489d9f
tag:         tip
user:        jhurne
date:        Tue Apr 20 20:57:07 2010 -0400
files:       test.txt theTest.txt
copies:      theTest.txt (test.txt)
description:
Renamed test.txt

您可以看到受影响的文件(test.txt 和 theTest.txt),并且“theTest.txt”是从 test.txt 复制的。

There are several ways to do this.

Before you commit, you can use hg diff --git to show what was renamed:

$ hg diff --git
diff --git a/theTest.txt b/aTest.txt
rename from theTest.txt
rename to aTest.txt

Note that this only works if you used hg mv, hg rename, or mv and hg addremove --similarity 100.

After you commit, you can still use hg diff, but you'll have to specify the change using -r:

$ hg diff -r 0 -r 1 --git
diff --git a/test.txt b/theTest.txt
rename from test.txt
rename to theTest.txt

For both hg status and hg log, use the -C command-line flag to see the source that a file was copied from.

$ hg status -C
A aTest.txt
  theTest.txt
R theTest.txt

The line just below aTest.txt indicates the source it was copied from (theTest.txt).

$ hg log -v -C
changeset:   1:4d7b42489d9f
tag:         tip
user:        jhurne
date:        Tue Apr 20 20:57:07 2010 -0400
files:       test.txt theTest.txt
copies:      theTest.txt (test.txt)
description:
Renamed test.txt

You can see the files that were affected (test.txt and theTest.txt), and that "theTest.txt" was copied from test.txt.

2024-09-05 19:06:06

您可以使用 hg Summary 查看有多少文件已被重命名。如果您想查看已重命名的实际文件,我发现的最快方法是执行

hg st -a -C

以下操作: 这将输出如下内容:

A <path\to\renamed\file>
  <path\copied\from>
A <path\to\added\file>
A <path\to\renamed\file>
  <path\copied\from>

由于 hg status 认为重命名是复制和删除,因此重命名的文件将列出从文件复制。添加但未重命名的文件将不会列出从文件复制的文件。

You can find out how many files have been renamed with hg summary. If you want to see the actual files that were renamed, the fastest way I've found is to do:

hg st -a -C

This will output something like this:

A <path\to\renamed\file>
  <path\copied\from>
A <path\to\added\file>
A <path\to\renamed\file>
  <path\copied\from>

Since hg status considers a rename to be a copy and a remove, your renamed files will list a copied from file. Files that were added but not renamed will not list a copied from file.

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