Intercept branch reads/writes in extension

Idan Kamara idankk86 at gmail.com
Tue Nov 20 08:32:27 CST 2012


On Tue, Nov 20, 2012 at 2:26 PM, v <voldermort at hotmail.com> wrote:
> I'm trying to write an extension that will change the way hg handles named
> branches. To do this, I need to wrap the code that reads/writes the branch
> name from/to changesets, but I can't find it. I've been looking through the
> code, but I keep going round in circles (this may be related to my lack of
> experience with python). Could someone point me to the right functions, or
> what I need to do if it's not as simple as that?

dirstate.branch/_branch reads it
http://selenic.com/repo/hg/file/fd903f89e42b/mercurial/dirstate.py#l92

dirstate.setbranch sets it
http://selenic.com/repo/hg/file/fd903f89e42b/mercurial/dirstate.py#l92

Depending on what you're doing this might be a little too low-level,
so wrapping commands.branch could be more appropriate.

And a tip: whenever you need to find something in the code base,
finding a command that (indirectly) invokes it and locating it in
commands.py is usually a good place to start.


More information about the Mercurial-devel mailing list