Mercurial > hg > hg-fastimport
diff hgfastimport/hgimport.py @ 55:a88f0dd05e92
Adapt to Mercurial 1.6 API change.
Convertor source method getmode() has been merged into getfile().
| author | Greg Ward <greg-hg@gerg.ca> |
|---|---|
| date | Wed, 10 Nov 2010 21:31:23 -0500 |
| parents | 38fe4f98a3ff |
| children | e827bffa5fc5 76bd0ea8add3 |
line wrap: on
line diff
--- 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).
