plan for mercurial api

Vadim Gelfer vadim.gelfer at gmail.com
Mon Jul 31 18:48:40 UTC 2006


there was discussion on irc today about mercurial api. i write down
notes from transcript so people can comment back.

problem now is that commands.py has high level code that would be nice
to use from python but is designed for command line. localrepo.py has
mix of repository and dirstate code.

plan is to move dirstate code from localrepo.py into hg.py and move
code that commands.py uses into hg.py and cmdutils.py.

functions will look like this. now we have:

  commands.py: remove(ui, repo, *pats, **opts)
  localrepo.py: remove(self, list, unlink=False, wlock=None)

instead we will have:

  localrepo.py: nothing
  hg.py: remove(repo, files, unlink=False, force=False, wlock=None)
  commands.py: calls hg.remove

3rd party python code can call functions in hg.py.

i have questions about how this will to work.

1. how i do change behavior of e.g. hg.remove? one way is monkeypatch,
but that is not clean.

2. is it good to have functions in hg.py or better to have class with methods?

please if you have opinions or other questions let me know. i want to
start on refactor soonest. i have already done some little bit (you
can use hg.clone now).



More information about the Mercurial mailing list