official python interface for mercurial
Chad Dombrova
chadrik at gmail.com
Wed May 19 01:07:07 UTC 2010
On May 18, 2010, at 4:52 PM, Benoit Boissinot wrote:
> On Tue, May 18, 2010 at 7:49 PM, Chad Dombrova <chadrik at gmail.com>
> wrote:
>> this is something that i am also very interested in.
> The following is orthogonal to the original request.
my interest in an official API is not for the sake of stability as was
the case with the original request. what i hoped to gain from an
"official python interface" is an API with more features targeting
developers wishing to integrate mercurial into python applications.
my problem with the internal API is that it is, quite understandably,
designed with internal use in mind. IMHO, a good API would take
more than refactoring existing code, although that would help, it
would also constitute utilities not internally used by mercurial, but
which every third party developer building tools with mercurial has to
rewrite since no official library seems to exist. tortoisehg.hglib
might be a good starting place.
this thread coincided with another on the tortoisehg list about
creating a better dispatch runner: http://groups.google.com/group/thg-dev/browse_thread/thread/31840c1401844873?hl=en
the need for this sort of utility stems from the fact that the
mercurial api is targeted at creating a command-line program where
each action is atomic: startup, do something, quit. as a result, there
is currently no clean and easy way that i know of to do the following
with the context of a python program:
bootstrap mercurial, loading all extensions
call a mercurial command, triggering pre- and post- hooks
call another mercurial command, triggering pre- and post- hooks
by clean i mean, not using syntax like this:
_dispatch('update', '-C', '-r', '100'])
....and instead using syntax like this:
commandrunner('update', clean=True, rev=100)
in the coming weeks i plan to take a stab at refactoring
mercurial.dispatch to be more "external app friendly". basically, i
hope to break it apart so that we can get entry somewhere between
_dispatch and runcommand. we'll see how it goes.
for all of those features that can't be achieved through refactoring,
it would be great to see an officially blessed hgutil module.
-chad
More information about the Mercurial
mailing list