Examining a changeset in HG

前端 未结 5 1880
执念已碎
执念已碎 2020-12-24 06:08

How can I examine a changeset in mercurial without looking up its parent? In mercurial, what\'s the equivalent of

git show HEAD^

Git-show

相关标签:
5条回答
  • 2020-12-24 06:19

    I think you want hg export cset.

    0 讨论(0)
  • 2020-12-24 06:24

    A similar command to "git show HEAD^" would be:

    hg log -pr -2   # -1 (last commit), -2 - one before it, etc.
    

    OR

    hg exp tip^  # tip^ is similar to -r -2
    

    or for instance if you want to look at the last 3 commits (with diff):

    hg log -pr -3:  # colon means start 3 commits behind and up to tip inclusive
    

    A bit to late with the answer, but still. :)

    UPDATE: apparently now HG supports git syntax as well:

    hg exp tip^^^..tip
    

    or

    hg log -pr tip~4
    
    0 讨论(0)
  • 2020-12-24 06:29

    If you just want to see the contents and differential of a commit, use this:

    hg diff -c <the commit hash or bookmark name>
    

    To see the commit you've checked out (HEAD in git), do this:

    hg diff -c -1
    

    If you want to see the commit before it (HEAD^ in git), do this:

    hg diff -c -2
    

    Simple.

    0 讨论(0)
  • 2020-12-24 06:30

    You should also take a look at the parentrevspec extension to enable a more Git-like syntax for specifying revisions.

    0 讨论(0)
  • 2020-12-24 06:34

    Your question has two parts. First, how to get the metadata and diff for a changeset all at once:

    hg log --patch --rev tip
    

    You can shorten the options:

    hg log -pr tip
    

    The second part of the question is how to say "the parent changeset of X" without looking it up. For that you can use the parentrevspec extension Martin mentioned.

    Once you enable the extension you can do:

    hg log -pr tip^
    

    You could add an alias to your ~/.hgrc file if you don't want to retrain your fingers from git's command:

    [alias]
    show = log -pr
    

    Then you could use:

    hg show tip^
    
    0 讨论(0)
提交回复
热议问题