I am trying to debug a Mercurial extension. This extension adds some code that should be executed when a pull
is performed. The original author setup this hook by changing the class of the repository object.
Here is the relevant code (which is actually a valid Mercurial extension):
def reposetup(ui, repo):
class myrepo(repo.__class__):
def pull(self, remote, heads=None, force=False):
print "pull called"
return super(myrepo, self).pull(remote, heads, force)
print "reposetup called"
if repo.local():
print "repo is local"
repo.__class__ = myrepo
When I perform a hg pull
with this extension enabled, here is the output:
# hg pull
reposetup called
repo is local
pulling from ssh://hgbox/myrepo
reposetup called
searching for changes
no changes found
Is this a reasonable way to inject the code of the extension in the pull
command? Why is the "pull called" statement never reached?
I use Mercurial 3.4.1 on Windows 7 with python 2.7.5.