attic extension broken by updatedir move in hg 1.7+

John Hein 2xfaanyctv at snkmail.com
Fri Nov 12 02:00:32 CST 2010


Matt Mackall wrote at 21:23 -0600 on Nov 11, 2010:
 > On Fri, 2010-11-12 at 02:40 +0000, John Hein wrote:
 > > [...]
 > > What's the right way for 3rd party extensions to be portable
 > > across different mercurial versions?
 >
 > Looks like attic hasn't been touched in 8 months, might be abandoned.
 >
 > My general advice would be:
 >
 > a) subscribe to the API changes on the wiki:
 >
 > http://mercurial.selenic.com/wiki/ApiChanges
 >
 > b) test extensions BEFORE the release date (Nov 1, Mar 1, Jul 1)
 >
 > c) make wrapper functions that use introspection to check whether they
 > have the old API or the new API
 >
 > ie:
 >
 > def updatedir(*args)
 >     if hasattr(patch, 'updatedir'):
 >         patch.updatedir(*args)
 >     else:
 >         cmdutil.updatedir(*args)
 >
 > Occasionally, we'll change argument lists, which can be examined with
 > inspect.getargspec.
 >
 > I've stuck this on the wiki under ApiChanges.

Thanks.  That's great.
Below I modified your example to try to resolve this issue:

TypeError: updatedir() got an unexpected keyword argument 'similarity'

def updatedir(*args, **kwargs):
    # updatedir moved from patch to cmdutil in hg 1.7
    if hasattr(patch, 'updatedir'):
        patch.updatedir(*args, **kwargs)
    else:
        cmdutil.updatedir(*args, **kwargs)


More information about the Mercurial-devel mailing list