# HG changeset patch # User Greg Ward # Date 1289442683 18000 # Node ID a88f0dd05e92c894d1e142e7fc8e212701763ac6 # Parent 9608f415ebe8a89a365d7daa5452681f42170b1a Adapt to Mercurial 1.6 API change. Convertor source method getmode() has been merged into getfile(). diff -r 9608f415ebe8 -r a88f0dd05e92 hgfastimport/hgimport.py --- a/hgfastimport/hgimport.py Sun Jul 19 11:56:59 2009 -0400 +++ b/hgfastimport/hgimport.py Wed Nov 10 21:31:23 2010 -0500 @@ -23,10 +23,14 @@ import os import shutil -from hgext.convert import common +from hgext.convert import common, hg as converthg from fastimport import processor, parser +# convertor source objects had a getmode() method up to Mercurial 1.5, +# but in 1.6 it was merged with getfile() +HAVE_GETMODE = hasattr(converthg.mercurial_source, 'getmode') + class fastimport_source(common.converter_source): """Interface between the fastimport processor below and Mercurial's normal conversion infrastructure. @@ -53,19 +57,29 @@ allheads.extend(branchheads) return allheads - def getfile(self, name, fileid): - """Return file contents as a string. rev is the identifier returned - by a previous call to getchanges(). - """ - if fileid is None: # deleted file - raise IOError - return self.processor.getblob(fileid) + # Mercurial <= 1.5 + if HAVE_GETMODE: + def getfile(self, name, fileid): + """Return file contents as a string. rev is the identifier returned + by a previous call to getchanges(). + """ + if fileid is None: # deleted file + raise IOError + return self.processor.getblob(fileid) - def getmode(self, name, fileid): - """Return file mode, eg. '', 'x', or 'l'. rev is the identifier - returned by a previous call to getchanges(). - """ - return self.processor.getmode(name, fileid) + def getmode(self, name, fileid): + """Return file mode, eg. '', 'x', or 'l'. rev is the identifier + returned by a previous call to getchanges(). + """ + return self.processor.getmode(name, fileid) + + # Mercurial >= 1.6 + else: + def getfile(self, name, fileid): + if fileid is None: # deleted file + raise IOError + return (self.processor.getblob(fileid), + self.processor.getmode(name, fileid)) def getchanges(self, commitid): """Returns a tuple of (files, copies).