开发者

hg command to see the changeset prior to an hg fetch

What mercurial command can you use to see the changeset prior to changeset xyz?

If you do hg log -r :xyz you see all the changesets prior to (and including) xyz - listed in ascending order. But I'd like to easily see just the prior changeset.


Update: Really what I'm after is this: If I do an hg fetch, what command can I use to see the changeset PRIOR to the the changesets that were pulled in by the fetch?

hg log -开发者_高级运维r :xyz where xyz is the first changeset pulled in by the fetch works but it returns the entire list of prior changesets where I just want the most recent.


You can't do it. Once you've pulled (and fetch is just pull + either update or merge) there is no record of what you had before the pull and what you just got from the pull.

You should do hg incoming before you pull to see what you will get.

Also, stop using fetch. The acts of pulling and updating and merging are completely separate and doing them in a single commands provides inadequate error reporting and just confuses things. The command is disabled by default and there's talk of removing it entirely. Merging is coding, and it shouldn't be hidden.

Expanding to Show cases you can't cover

If before fetching your history is this:

[A]-[B]-[C]

and you (against all advice) fetch and get [D] you now have:

[A]-[B]-[C]-[D]

And you can see exactly what's new with:

hg diff -r tip-1

or with:

hg diff -r "parent(tip)"

But if starting again with A,B,C you fetch and get D,E yielding this:

[A]-[B]-[C]-[D]-[E]

there is no command you can run to see "what changed" without having previously written [C] down on a post it note.

If, on the other hand your repo started out looking like this:

[A]-[B]
  \
   -[C]

and after fetching you have this:

[A]-[B]-[D]
  \
   -[C]-[E]

there's no single command that will tell you "what changed". Similarly, if before pulling your repo looked like this:

[A]-[B]-[C]

and after fetching you got this:

[A]-[B]-[C]-[E]-[F]
  \            /
   -[D]-------/

where [F] is the new ill-advised auto-merge changeset fetch created then the command:

hg diff -r C

will tell you what's new, but there's no way to look up 'C' without having previously written it down.


I assume xyz is a changeset in hash form. Try:

hg log -r :xyz-1

That should work to list just the changeset prior to 1


I'm not sure what is meant by prior. Your question could mean you might just want the parents of the changeset. These you would get easily with

hg parent -r xyz

This does not need fancy new versions of mercurial.

hg parents [-r REV] [FILE]

show the parents of the working directory or revision

Print the working directory's parent revisions. If a revision is given via -r/--rev, the parent of that revision will be printed. If a file argument is given, the revision in which the file was last changed (before the working directory revision or the argument to --rev if given) is printed.

options:

-r --rev       show parents of the specified revision
--style     display using template map file
--template  display with template
--mq        operate on patch repository


With the parentrevspec[1] extension installed, you can use the git-like syntax below. Depending on your shell, the quotes may not be necessary.

hg log -r 'xyz^'
  1. https://www.mercurial-scm.org/wiki/ParentrevspecExtension
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜