Print Current Mercurial Revision Hash?

后端 未结 8 1920
无人共我
无人共我 2020-12-12 20:04

Is there a better way extract the current revision hash in Mercurial than

hg log -l1|grep changeset|cut -d: -f3

?

Part of my webapp depl

相关标签:
8条回答
  • 2020-12-12 20:23

    In case TortoiseHg is used, right-click the revision row in the Workbench and select "Copy hash" (as per documentation).

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

    Try:

    hg id -i
    

    Example:

    $ hg id -i
    adc56745e928
    
    0 讨论(0)
  • 2020-12-12 20:30
    hg --debug id -i
    

    This will output the long hash, with a plus if there are uncommitted changes.

    0 讨论(0)
  • 2020-12-12 20:32

    Summarising the answers and their responses, it seems that this is the best way to print the unique (not short form) identifier of the current version:

    hg log -l 1 --template '{node}\n' -r .
    
    0 讨论(0)
  • 2020-12-12 20:37

    You can use --template with the parent command, I use this to get the long hash:

    hg parent --template '{node}'
    
    0 讨论(0)
  • 2020-12-12 20:45

    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 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)
提交回复
热议问题