How can I find my working revision in mercurial

前端 未结 6 518
独厮守ぢ
独厮守ぢ 2021-02-01 12:27

In a mercurial repo I can run hg up {revision} to change the revision of my working directory, but what command can I run to discover what revision I\'m looking at?

相关标签:
6条回答
  • 2021-02-01 12:44

    The most specific non-DEPRECATED command which due to the presence of --template can print only revision information if that conciseness is required (as implied by the question):

    hg log -l 1 -b . -T '{rev}:{node|short}\n'

    Or:

    hg log -l 1 -b . -T '{rev}\n'

    Or:

    hg log -l 1 -r . -T '{rev}\n'

    Or for unique long form of hash:

    hg log -l 1 -r . -T '{node}\n'

    The -b . or branch(.) (dot for branch name) means the current working directory branch and -r . means the current working directory revision, which is documented in hg help revsets and hg help revisions.

    Note if there is an uncommitted merge, the . (dot) only displays the first parent of two parents of the working group.

    0 讨论(0)
  • 2021-02-01 12:55

    This command:

    hg parent
    
    0 讨论(0)
  • 2021-02-01 12:55

    hg identify (or hg id for short) will print the (shortened 12-character identifier of) the parent hashes, and a + if there are any uncommitted modifications in your working copy.

    To get the full hashes, you can use hg identify --debug instead.

    0 讨论(0)
  • 2021-02-01 13:03

    In addition to hg parents, you can use hg summary to get the most important summary information about your current state. It looks like this:

    % hg summary
    parent: 13051:120eccaaa522 tip
     encoding: fix typo in variable name
    branch: default
    commit: 2 unknown (clean)
    update: (current)
    mq:     20 unapplied
    

    and tells me at a glance that I'm at revision 13051, that I'm on the default branch with a clean working copy (though there are 2 untracked files). This is the tip revision in my repository, so an update wont do anything. Finally, I have 20 unapplied MQ patches.

    0 讨论(0)
  • 2021-02-01 13:03

    This will also helpful,

    hg log -v -r `hg id -i`
    
    0 讨论(0)
  • 2021-02-01 13:05

    Another option is to enable the graphlog extension, then run hg glog. You'll see output like this (bear in mind I use a template to change the output):

    o    changeset:   200:c8c281cf0a6d
    |\   branch:      craig-aspinall
    | |  tag:         tip
    | |  parent:      199:1a692f3b9134
    | |  parent:      187:2d0e0ed9d31c
    | |  user:        Craig Aspinall
    | |  date:        Tue Nov 23 21:36:30 2010 +1000
    | |  summary:     Merged latest changes
    | |
    | o  changeset:   199:1a692f3b9134
    | |  branch:      craig-aspinall
    | |  parent:      123:1dc90c9b7ede
    | |  user:        Craig Aspinall
    | |  date:        Tue Nov 23 21:35:22 2010 +1000
    | |  summary:     Final solutions to L04
    | |
    | | @    changeset:   198:78b488c2607d       <==== This is where I am currently.
    | | |\   branch:      OJ
    | | | |  parent:      119:70ec3d9e4d3a
    | | | |  parent:      197:44bac809d37d
    | | | |  user:        OJ Reeves
    | | | |  date:        Tue Nov 23 20:19:07 2010 +1000
    | | | |  summary:     Merged with the mainline
    | | | |
    | | | o  changeset:   197:44bac809d37d
    | | | |  user:        Tony Morris
    | | | |  date:        Tue Nov 23 18:40:03 2010 +1000
    | | | |  summary:     Started parallel anagrams
    | | | |
    | | | o  changeset:   196:92241b51970b
    | | | |  user:        Tony Morris
    | | | |  date:        Tue Nov 23 17:52:32 2010 +1000
    | | | |  summary:     Started parallel anagrams
    | | | |
    

    The node/revision with the @ symbol is where you are.

    0 讨论(0)
提交回复
热议问题