Get Mercurial next commit hash -
i @ revision 56, hash 6af16aa3edf8. next revision 57, hash ???. there way know hash of revision 57? need in pre-commit hook.
why tho?
i developed script, called via pre-commit hook, update version files. way, compiled executables can give info revision build from. i'm adding revision number of current commit in version file, retrieved "parent revision number + 1". since revision number not reliable when collaborating other people on same repository, prefer add hash, too. don't know how retrieve it...
no, cannot predict next hash when know changeset completely. commit time plays role there:
~/hg-test $ hg ci -m "b in foo" ~/hg-test $ hg id d65d61e6898a tip ~/hg-test $ hg rollback ~/hg-test $ hg ci -m "b in foo" ~/hg-test $ hg id c7f5ff744e43 tip https://www.mercurial-scm.org/wiki/nodeid
i suggest solve problem such: in build tools, query whether project built repository. if so: retrieve repository information. e.g.
ver = $(hg log -r. -t"{node|short} {date|isodate}") will give you
c7f5ff744e43 2017-07-26 14:05 +0200 generate version file information in build chain on fly
for distribution purposes, generate , amend file package, build process, when finds not started repository checkout, still has version file can make use of.
Comments
Post a Comment