# HG changeset patch # User Matt Harbison # Date 1511401741 18000 # Node ID 671aba341d90389397c0d0ed6b3a63dc11c673e6 # Parent e0a1b9ee93cdfb40ba43e8838a1edf4ea3ea24f3 convert: save an indicator of the repo type for sources and sinks This seems like basic info to have, and will be used shortly when deciding whether or not to wrap the class for lfs conversions. The other option is to just add a function to each class. But this seems better in that the strings aren't duplicated, and the constructor for most of these will run even if the VCS isn't installed, so it's easier to catch errors. diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/bzr.py --- a/hgext/convert/bzr.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/bzr.py Wed Nov 22 20:49:01 2017 -0500 @@ -44,8 +44,8 @@ class bzr_source(common.converter_source): """Reads Bazaar repositories by using the Bazaar Python libraries""" - def __init__(self, ui, path, revs=None): - super(bzr_source, self).__init__(ui, path, revs=revs) + def __init__(self, ui, repotype, path, revs=None): + super(bzr_source, self).__init__(ui, repotype, path, revs=revs) if not os.path.exists(os.path.join(path, '.bzr')): raise common.NoRepo(_('%s does not look like a Bazaar repository') diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/common.py --- a/hgext/convert/common.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/common.py Wed Nov 22 20:49:01 2017 -0500 @@ -73,12 +73,13 @@ class converter_source(object): """Conversion source interface""" - def __init__(self, ui, path=None, revs=None): + def __init__(self, ui, repotype, path=None, revs=None): """Initialize conversion source (or raise NoRepo("message") exception if path is not a valid repository)""" self.ui = ui self.path = path self.revs = revs + self.repotype = repotype self.encoding = 'utf-8' @@ -218,7 +219,7 @@ class converter_sink(object): """Conversion sink (target) interface""" - def __init__(self, ui, path): + def __init__(self, ui, repotype, path): """Initialize conversion sink (or raise NoRepo("message") exception if path is not a valid repository) @@ -227,6 +228,7 @@ self.ui = ui self.path = path self.created = [] + self.repotype = repotype def revmapfile(self): """Path to a file that will contain lines diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/convcmd.py --- a/hgext/convert/convcmd.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/convcmd.py Wed Nov 22 20:49:01 2017 -0500 @@ -114,7 +114,7 @@ for name, source, sortmode in source_converters: try: if not type or name == type: - return source(ui, path, revs), sortmode + return source(ui, name, path, revs), sortmode except (NoRepo, MissingTool) as inst: exceptions.append(inst) if not ui.quiet: @@ -128,7 +128,7 @@ for name, sink in sink_converters: try: if not type or name == type: - return sink(ui, path) + return sink(ui, name, path) except NoRepo as inst: ui.note(_("convert: %s\n") % inst) except MissingTool as inst: diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/cvs.py --- a/hgext/convert/cvs.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/cvs.py Wed Nov 22 20:49:01 2017 -0500 @@ -32,8 +32,8 @@ NoRepo = common.NoRepo class convert_cvs(converter_source): - def __init__(self, ui, path, revs=None): - super(convert_cvs, self).__init__(ui, path, revs=revs) + def __init__(self, ui, repotype, path, revs=None): + super(convert_cvs, self).__init__(ui, repotype, path, revs=revs) cvs = os.path.join(path, "CVS") if not os.path.exists(cvs): diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/darcs.py --- a/hgext/convert/darcs.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/darcs.py Wed Nov 22 20:49:01 2017 -0500 @@ -40,8 +40,8 @@ pass class darcs_source(common.converter_source, common.commandline): - def __init__(self, ui, path, revs=None): - common.converter_source.__init__(self, ui, path, revs=revs) + def __init__(self, ui, repotype, path, revs=None): + common.converter_source.__init__(self, ui, repotype, path, revs=revs) common.commandline.__init__(self, ui, 'darcs') # check for _darcs, ElementTree so that we can easily skip diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/filemap.py --- a/hgext/convert/filemap.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/filemap.py Wed Nov 22 20:49:01 2017 -0500 @@ -172,7 +172,7 @@ class filemap_source(common.converter_source): def __init__(self, ui, baseconverter, filemap): - super(filemap_source, self).__init__(ui) + super(filemap_source, self).__init__(ui, baseconverter.repotype) self.base = baseconverter self.filemapper = filemapper(ui, filemap) self.commits = {} diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/git.py --- a/hgext/convert/git.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/git.py Wed Nov 22 20:49:01 2017 -0500 @@ -66,8 +66,8 @@ def gitpipe(self, *args, **kwargs): return self._gitcmd(self._run3, *args, **kwargs) - def __init__(self, ui, path, revs=None): - super(convert_git, self).__init__(ui, path, revs=revs) + def __init__(self, ui, repotype, path, revs=None): + super(convert_git, self).__init__(ui, repotype, path, revs=revs) common.commandline.__init__(self, ui, 'git') # Pass an absolute path to git to prevent from ever being interpreted diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/gnuarch.py --- a/hgext/convert/gnuarch.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/gnuarch.py Wed Nov 22 20:49:01 2017 -0500 @@ -36,8 +36,8 @@ self.ren_files = {} self.ren_dirs = {} - def __init__(self, ui, path, revs=None): - super(gnuarch_source, self).__init__(ui, path, revs=revs) + def __init__(self, ui, repotype, path, revs=None): + super(gnuarch_source, self).__init__(ui, repotype, path, revs=revs) if not os.path.exists(os.path.join(path, '{arch}')): raise common.NoRepo(_("%s does not look like a GNU Arch repository") diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/hg.py --- a/hgext/convert/hg.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/hg.py Wed Nov 22 20:49:01 2017 -0500 @@ -45,8 +45,8 @@ sha1re = re.compile(r'\b[0-9a-f]{12,40}\b') class mercurial_sink(common.converter_sink): - def __init__(self, ui, path): - common.converter_sink.__init__(self, ui, path) + def __init__(self, ui, repotype, path): + common.converter_sink.__init__(self, ui, repotype, path) self.branchnames = ui.configbool('convert', 'hg.usebranchnames') self.clonebranches = ui.configbool('convert', 'hg.clonebranches') self.tagsbranch = ui.config('convert', 'hg.tagsbranch') @@ -444,8 +444,8 @@ return rev in self.repo class mercurial_source(common.converter_source): - def __init__(self, ui, path, revs=None): - common.converter_source.__init__(self, ui, path, revs) + def __init__(self, ui, repotype, path, revs=None): + common.converter_source.__init__(self, ui, repotype, path, revs) self.ignoreerrors = ui.configbool('convert', 'hg.ignoreerrors') self.ignored = set() self.saverev = ui.configbool('convert', 'hg.saverev') diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/monotone.py --- a/hgext/convert/monotone.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/monotone.py Wed Nov 22 20:49:01 2017 -0500 @@ -19,8 +19,8 @@ from . import common class monotone_source(common.converter_source, common.commandline): - def __init__(self, ui, path=None, revs=None): - common.converter_source.__init__(self, ui, path, revs) + def __init__(self, ui, repotype, path=None, revs=None): + common.converter_source.__init__(self, ui, repotype, path, revs) if revs and len(revs) > 1: raise error.Abort(_('monotone source does not support specifying ' 'multiple revs')) diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/p4.py --- a/hgext/convert/p4.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/p4.py Wed Nov 22 20:49:01 2017 -0500 @@ -43,11 +43,11 @@ return filename class p4_source(common.converter_source): - def __init__(self, ui, path, revs=None): + def __init__(self, ui, repotype, path, revs=None): # avoid import cycle from . import convcmd - super(p4_source, self).__init__(ui, path, revs=revs) + super(p4_source, self).__init__(ui, repotype, path, revs=revs) if "/" in path and not path.startswith('//'): raise common.NoRepo(_('%s does not look like a P4 repository') % diff -r e0a1b9ee93cd -r 671aba341d90 hgext/convert/subversion.py --- a/hgext/convert/subversion.py Wed Nov 15 23:43:15 2017 -0500 +++ b/hgext/convert/subversion.py Wed Nov 22 20:49:01 2017 -0500 @@ -285,8 +285,8 @@ # the parent module. A revision has at most one parent. # class svn_source(converter_source): - def __init__(self, ui, url, revs=None): - super(svn_source, self).__init__(ui, url, revs=revs) + def __init__(self, ui, repotype, url, revs=None): + super(svn_source, self).__init__(ui, repotype, url, revs=revs) if not (url.startswith('svn://') or url.startswith('svn+ssh://') or (os.path.exists(url) and @@ -1112,9 +1112,9 @@ def authorfile(self): return self.join('hg-authormap') - def __init__(self, ui, path): + def __init__(self, ui, repotype, path): - converter_sink.__init__(self, ui, path) + converter_sink.__init__(self, ui, repotype, path) commandline.__init__(self, ui, 'svn') self.delete = [] self.setexec = []