Reusing the remote repo object when wrapping the incoming command

Angel Ezquerra ezquerra at
Thu Jan 19 02:33:01 CST 2012


I am working on an extension in which I want to wrap the incoming
command. The extension must execute the regular incoming command and
then do some additional work, which requires it to talk to the remote
repo using pushkeys. In order to do so I think that I must create a
repository object for the remote repo, so that I can call the
listkeys() method.

The problem that I have is that it seems that I must create an
hg.repository() object after calling mercurial's vanilla incoming
command. This seems wasteful since I would think that the incoming
command must already have created an object for the remote repository.

For example, if you wrap the clone command you do not need to do this,
because the clone function returns the local and the remote repo

So my question is: should I worry about this? Is it expensive to
create the remote repository object? Or perhaps mercurial does some
sort of caching that makes creating the remote repository object again
efficient? If not, what is the best way to deal with this? Should I
simply do something like:

    expandedpath = ui.expandpath(srcpath)
    other = hg.repository(ui, expandedpath)

where srcpath is the path of the remote repo?

Thank you in advance,


More information about the Mercurial-devel mailing list