当我执行hg pull和hg更新时,将添加哪些文件与添加

时间:2010-07-18 21:31:13

标签: version-control mercurial dvcs pull

所以在我做svn up的Subversion中,我得到了一个添加,修改,删除和冲突的文件列表。

当我执行hg pull然后hg up -v时,它只显示一个列表:getting file.ext但我无法知道该文件是新文件还是已存在。有没有办法让Mercurial显示关于文件是否被添加,修改或删除的相同类型的元数据?

Mercurial能否提供我所要求的任何能力?

4 个答案:

答案 0 :(得分:19)

Omni有你的答案,我投了赞成票,但只是为了显示所有选项:

拉前

  • hg incoming#显示您将获得的更改集
  • hg incoming --verbose#显示您将获得的更改集,包括每个
  • 的文件列表
  • hg incoming --patch#显示您将获得的所有变更集的完整差异

拉(但不更新)后:

  • hg log -r。:tip#显示您获得的变更集
  • hg log --verbose -r。:tip#显示您获得的变更集,包括每个
  • 的文件列表
  • hg log --patch -r。:trip#显示所有变更集的完整差异

答案 1 :(得分:17)

使用status命令列出工作副本与其父版本之间的文件状态更改或任何两个版本之间的 。它为您提供如下输出:

$ hg status --rev .:tip
M hgext/keyword.py
M mercurial/cmdutil.py
M mercurial/commands.py
M mercurial/context.py
M mercurial/patch.py
A tests/test-encoding-align
A tests/test-encoding-align.out

对应于此次更新:

$ hg update -v
resolving manifests
getting hgext/keyword.py
getting mercurial/cmdutil.py
getting mercurial/commands.py
getting mercurial/context.py
getting mercurial/patch.py
getting tests/test-encoding-align
getting tests/test-encoding-align.out
7 files updated, 0 files merged, 0 files removed, 0 files unresolved

修改:您可以创建preupdate挂钩,以便始终将此信息作为更新的一部分。我现在碰巧在Windows上,这个钩子工作在这里:

[hooks]
preupdate = hg status --rev .:%HG_PARENT1%

在类Unix系统上将%HG_PARENT1%替换为$HG_PARENT1。这应该使Mercurial体验更像Subversion: - )

答案 2 :(得分:6)

hg incoming --stat命令会像您要求的那样执行。此外,如果您要更新到新修订版,则可以执行hg diff --git -r <rev>,它会为您提供显示哪些文件是新文件的差异。

答案 3 :(得分:1)

您可以将hg incoming与捆绑包一起使用,以应用Martin对您尚未实际提取的更改的回答。

> cd myrepo
# Get the latest revision in my copy
> hg tip
changeset:   17:5005ce2dc418
.
.
.
# Get a bundle file of changes, but don't put them in myrepo yet
> hg incoming --bundle changes.bundle
# Overlay the bundle on myrepo and do hg status as if I've already pulled
> hg -R changes.bundle status --rev 17:tip
A addedfile
M modifiedfile
.
.
.
# Changes are good! Pull from bundle
hg pull changes.bundle
相关问题