# HG changeset patch # User Siddharth Agarwal # Date 1397529137 25200 # Node ID 96f0463a4e54f454e770a5cddea6f0a199e43267 # Parent 96458acb160a1615bd9565e7908f36e6641ad6d7 revset_gitnode: use repo.changelog.node instead of contexts For a repository with around 60,000 commits, perfrevset for gitnode becomes: before: ! wall 1.130716 comb 1.130000 user 1.130000 sys 0.000000 (best of 9) after: ! wall 0.178828 comb 0.180000 user 0.180000 sys 0.000000 (best of 54) In reality, perfrevset doesn't clear the Git-to-Mercurial map, which means that a call like `hg log -r 'gitnode(...)'` speeds up from around 1.5 seconds to 0.6. diff --git a/hggit/__init__.py b/hggit/__init__.py --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -31,6 +31,7 @@ from mercurial import hg from mercurial import ignore from mercurial import localrepo +from mercurial.node import hex from mercurial import revset from mercurial import templatekw from mercurial import util as hgutil @@ -200,8 +201,9 @@ rev = revset.getstring(args[0], "the argument to gitnode() must be a hash") git = repo.githandler + node = repo.changelog.node def matches(r): - gitnode = git.map_git_get(repo[r].hex()) + gitnode = git.map_git_get(hex(node(r))) if gitnode is None: return False return rev in [gitnode, gitnode[:12]]