创建一个新分支,做了很多更改,如何查看更改的文件列表?

发布于 2024-12-28 03:55:10 字数 223 浏览 1 评论 0原文

因此创建了一个新分支,我们对代码库进行了一些重大更改。

现在我们要合并,但在此之前我想获取分支中更改的所有文件的列表。

如何获取文件列表?我尝试过:

hg status --change REV

但我不确定这是否是我想要的,因为我希望在此分支中更改所有文件,而不是分支中的特定修订版。

顺便说一句,我如何查看修订号?

So there was a new branch created where we made some breaking changes to the codebase.

Now we are going to merge, but before that I want to get a list of all the files that were changed in the branch.

How can I get a list of files? I tried:

hg status --change REV

But i'm not sure if that is what I want, since I want all files changed in this branch and not a specific revision in the branch.

BTW, how can I view the revision numbers?

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

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

发布评论

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

评论(5

软甜啾 2025-01-04 03:55:10

尝试

$ hg status --rev "branch('your-branch')"

获取分支上第一个和最后一个变更集之间的更改(hg status 将隐式使用 min(branch('your-branch'))>max(branch('your-branch')) 当你给它一系列的修改时,像这样)。

由于您将进行合并,因此您应该真正查看一下

$ hg status --rev default:your-branch

default 分支和 your-branch 之间发生了什么变化。这会向您显示已完成的修改,并过滤掉由于与 default 合并而在分支上完成的任何修改。

如果您的历史记录如下所示,这是必要的:

your-branch:      x --- o --- o --- o --- o --- o --- y
                 /           /           /
default:  o --- a --- o --- b --- o --- c --- o --- o --- d

您已经将 default 多次合并到您的分支中。将 default 合并到您的分支中是正常的,因为您希望定期集成该分支中的最新内容,以避免分支彼此相距太远。

但是,如果在 default 上引入了一个新文件,然后合并到 B 中,那么您并不想在 hg status 中看到它> 输出。如果您这样做,您将会看到它,

$ hg status --rev a:y

因为该文件不存在于 a 中,但存在于 y 中。如果这样做

$ hg status --rev d:y

,那么您将不会在输出中看到该文件,假设它存在于两个头中。


您在评论中写道,您正在使用 Kiln 存储库。当他们说“分支”时,他们的意思是“克隆”,但上面的内容仍然可以根据您的情况进行调整。所有变更集都将位于默认命名分支上,但这没关系。

在“branch”存储库的本地克隆中运行以下命令:

$ hg bookmark -r tip mybranch

这将当前提示标记为 mybranch 的头部。然后从主存储库中提取所有变更集:

$ hg pull https://you.kilnhg.com/Repo/public/Group/Main

然后将 new 提示标记为主存储库的提示:

$ hg bookmark -r tip main

您现在可以运行

$ hg status --rev main:mybranch

以查看 main 和 <代码>我的分支。如果你想查看你在分支本身上做了什么,使用

$ hg status --rev "::mybranch - ::main"

::mybranch 部分将选择作为 mybranch 祖先的变更集 - 这是你的所有新工作,加上你分支之前的旧历史。我们使用 - ::main 删除旧历史记录。在旧版本的 Mercurial 中,您可以使用 hg log -r -r mybranch:0 -P main

Try with

$ hg status --rev "branch('your-branch')"

to get the changes between the first and the last changeset on the branch (hg status will implicitly use min(branch('your-branch')) and max(branch('your-branch')) when you give it a range of revisions like this).

Since you'll be merging, you should really look at

$ hg status --rev default:your-branch

to see what is changed between the default branch and your-branch. This shows you the modifications done, and filters out any modifications done on the branch due to merges with default.

This is necessary in case your history looks like this:

your-branch:      x --- o --- o --- o --- o --- o --- y
                 /           /           /
default:  o --- a --- o --- b --- o --- c --- o --- o --- d

where you've already merged default into your branch a couple of times. Merging default into your branch is normal since you want to regularly integrate the latest stuff from that branch to avoid the branches drifting too far away from each other.

But if a new file was introduced on default and later merged up into B, then you don't really want to see that in the hg status output. You will see it if you do

$ hg status --rev a:y

since the file was not present in a, but is present in y. If you do

$ hg status --rev d:y

then you wont see the file in the output, assuming that it's present in both heads.


You write in a comment that you're working Kiln repository. They mean "clone" when they say "branch", but the above can still be adapted for your case. All changesets will be on the default named branch, but that's okay.

Run the following command in your local clone of the "branch" repository:

$ hg bookmark -r tip mybranch

This marks the current tip as the head of mybranch. Then pull all the changesets from the main repository:

$ hg pull https://you.kilnhg.com/Repo/public/Group/Main

You then mark the new tip as the tip of the main repository:

$ hg bookmark -r tip main

You can now run

$ hg status --rev main:mybranch

to see the changes between main and my-branch. If you want to see what you did on the branch itself, the use

$ hg status --rev "::mybranch - ::main"

The ::mybranch part will select changesets that are ancestors of mybranch — this is all your new work, plus old history from before you branched. We remove the old history with - ::main. In older versions of Mercurial, you would use hg log -r -r mybranch:0 -P main.

伴随着你 2025-01-04 03:55:10

在这种情况下,我更喜欢从新签出的存储库副本进行测试合并。这样做的好处是我可以看到合并会产生多少冲突,并且我可以保留合并结果,因为我是在它自己的副本中进行的。

In cases like this, I prefer to do a test merge from a newly checked-out copy of the repo. This has the advantage that I can see how many conflicts the merge will produce, and I can keep the merge result because I did it in its own copy.

凑诗 2025-01-04 03:55:10

要查看修订号,请启用 graphlog 扩展 并运行:

$ hg log -b your-branch -G

这将为您提供一个漂亮的 ASCII 图表。这可以方便地快速查看图表,但我建议使用 TortoiseHg 作为跨平台日志查看器:

< img src="https://i.sstatic.net/yUCER.png" alt="TortoiseHg 2.0 工作台">

To view the revision numbers, enable the graphlog extension and run:

$ hg log -b your-branch -G

This gives you a nice ASCII graph. This can be handy to quickly look at the graph, but I recommend using TortoiseHg for a cross-platform log viewer:

TortoiseHg 2.0 workbench

也只是曾经 2025-01-04 03:55:10

我必须将默认分支合并到我的分支中才能获得一些修复,现在上面的命令还显示由于合并而更改的文件(此文件在默认分支中再次合并后发生了更改)。

因此,为了仅获取正确的文件,我使用如下方法:

hg log --rev "branch('my-branch') and not merge()" --template '{files}\n' | sed -e 's/ /\n/g' | sort -u

如果文件名中有空格,则可以这样做:

hg log --rev "branch('my-branch') and not merge()" --template '{rev}\0' | xargs -0 -I @ hg status -n --change @ | sort -u

并且为了回答您的最后一个问题,修订版本可以这样显示:

hg log --rev "branch('my-branch') and not merge()" --template '{rev}\n'

提示:我使用 hg-别名:

[alias]
_lf = ! $HG log --rev "branch(\"$1\") and not merge()" --template '{rev}\0' | xargs -0 -I @ hg status -n --change @ | sort -u

I had to merge the default branch into my branch to get some fixes, now the commands above shows also files changed because of merges (this files changed after the merge again in the default branch).

Therefore, to get only the correct files I use something like this:

hg log --rev "branch('my-branch') and not merge()" --template '{files}\n' | sed -e 's/ /\n/g' | sort -u

if you have spaces in file names, you can do it this way:

hg log --rev "branch('my-branch') and not merge()" --template '{rev}\0' | xargs -0 -I @ hg status -n --change @ | sort -u

And to answer your last question, revisions can be shown this way:

hg log --rev "branch('my-branch') and not merge()" --template '{rev}\n'

TIP: I use a hg-alias for this:

[alias]
_lf = ! $HG log --rev "branch(\"$1\") and not merge()" --template '{rev}\0' | xargs -0 -I @ hg status -n --change @ | sort -u
忘羡 2025-01-04 03:55:10

使用mercurial,如果您想获取当前分支中更改的所有文件的列表(更改集的更改),您可以使用以下命令: :

hg log --branch $(hg branch) --stat | grep '|' | awk -F\  '{printf ("%s\n", $1)}' | sort -u

结果示例:

api/tests/test_my_app.py
docker/run.sh
api/my_app.py

命令说明:

hg log --branch $(hg branch) --stat

显示整个存储库或文件的修订历史记录,并输出 diffstat 样式的更改摘要

hg branch

显示当前分支名称

grep '|'

搜索文本模式,在本例中为“|”

awk -F\  '{printf ("%s\n", $1)}'

空格分隔符表示记录中的每个字段并在新行中打印每个字段

sort -u

对所有打印行进行排序并删除重复项

With mercurial, if you want to get the list of all the files changed in your current branch (changes done of your changeset) you can use these commands: :

hg log --branch $(hg branch) --stat | grep '|' | awk -F\  '{printf ("%s\n", $1)}' | sort -u

Example result:

api/tests/test_my_app.py
docker/run.sh
api/my_app.py

Explanation of the commands:

hg log --branch $(hg branch) --stat

Show revision history of entire repository or files and output diffstat-style summary of changes

hg branch

Show the current branch name

grep '|'

Search for a text pattern, in this case, it is "|"

awk -F\  '{printf ("%s\n", $1)}'

Space separator denotes each field in a record and prints each one in a new line

sort -u

Sort all the printed lines and delete duplicates

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