[PATCH] dirstate: make subrepos an optional arg to status() and walk()

Matt Mackall mpm at selenic.com
Fri Mar 5 11:11:25 CST 2010


On Fri, 2010-03-05 at 09:19 -0500, Greg Ward wrote:
> # HG changeset patch
> # User Greg Ward <greg-hg at gerg.ca>
> # Date 1266244676 18000
> # Branch stable
> # Node ID cf238442eb60e1abc5a54bc1362b3e0d7513db99
> # Parent  eab98889e7924972ca4ea5664198a01e83d69532
> dirstate: make subrepos an optional arg to status() and walk().
> 
> This makes the incompatible API change in 24ce8f0c0a39 much less
> annoying for third-party extension authors who need to maintain
> compatibility with Mercurial 1.4 and 1.5.

Sorry, I'm not going to take this.

I've often stated that Mercurial intentionally doesn't have a stable
API. There are a lot of things we still intend to improve and I expect
we'll be doing so for a long time. If we had frozen the API back at,
say, 1.0, a lot of the progress we've made since then simply would have
been too painful to bother with.

And yes, we could do various things like default args to preserve
compatibility with some older APIs but that kind of cruft also creates a
maintenance headache on our side (in addition to making the code ugly).
And there's not much point in trying to preserve some APIs if we're
going to break others.

So if you're going to maintain third-party extensions that work over
multiple revisions (and you happen to be using an API that changes),
you're going to have to bite the bullet and use a wrapping pattern.
Here's a simple sketch:

import inspect
from mercurial import dirstate

proto = inspect.getargspec(dirstate.dirstate.status)
if 'subrepos' in proto[0]: # 1.5 or later
    def mystatus(ds, a, b, c):
	return ds.status([], a, b, c)
else:
    def mystatus(ds, a, b, c):
        return ds.status(a, b, c)

And really, that's not so bad.

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list