Mercurial > hg > hg-fastimport
diff hgfastimport/__init__.py @ 74:a4f13dc5e3f7
Support Mercurial 5.6 and Python-3.6
This change the minimum Mercurial supported version 4.1
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Mon, 18 Jan 2021 18:04:38 +0000 |
| parents | a99e5c6c8e1c |
| children |
line wrap: on
line diff
--- a/hgfastimport/__init__.py Sun Aug 12 07:54:35 2018 -0400 +++ b/hgfastimport/__init__.py Mon Jan 18 18:04:38 2021 +0000 @@ -2,9 +2,10 @@ from __future__ import absolute_import from mercurial import ( - cmdutil, + commands, encoding, - util, + error, + pycompat, ) from mercurial.i18n import _ @@ -16,28 +17,30 @@ from .hgimport import fastimport_source +testedwith = b'5.6.1' +minimumhgversion = b'4.1' + cmdtable = {} try: from mercurial import registrar command = registrar.command(cmdtable) except (ImportError, AttributeError): + from mercurial import cmdutil command = cmdutil.command(cmdtable) -testedwith = '4.7' - -@command("fastimport", - [('', 'branchsort', None, _('try to sort changesets by branches')), - ('', 'datesort', None, _('try to sort changesets by date')), - ('', 'sourcesort', None, _('preserve source changesets order'))], - _('hg fastimport SOURCE ...'), - norepo=False) +@command(b'fastimport', + [(b'', b'branchsort', None, _(b'try to sort changesets by branches')), + (b'', b'datesort', None, _(b'try to sort changesets by date')), + (b'', b'sourcesort', None, _(b'preserve source changesets order'))], + _(b'hg fastimport SOURCE ...'), + norepo=False) def fastimport(ui, repo, *sources, **opts): - """Convert a git fastimport dump into Mercurial changesets. + '''Convert a git fastimport dump into Mercurial changesets. Reads a series of SOURCE fastimport dumps and adds the resulting changes to the current Mercurial repository. - """ + ''' # Would be nice to just call hgext.convert.convcmd.convert() and let # it take care of things. But syntax and semantics are just a # little mismatched: @@ -49,24 +52,27 @@ # Boo, hiss. if not sources: - sources = ("-") + sources = (b'-') # assume fastimport metadata (usernames, commit messages) are # encoded UTF-8 convcmd.orig_encoding = encoding.encoding - encoding.encoding = 'UTF-8' + encoding.encoding = b'UTF-8' # sink is the current repo, src is the list of fastimport streams - destc = hg.mercurial_sink(ui, 'hg', repo.root) - srcc = fastimport_source(ui, 'fastimport', repo, sources) + destc = hg.mercurial_sink(ui, b'hg', repo.root) + srcc = fastimport_source(ui, b'fastimport', repo, sources) - # XXX figuring out sortmode copied straight from hgext/convert/convcmd.py - defaultsort = 'branchsort' # for efficiency and consistency - sortmodes = ('branchsort', 'datesort', 'sourcesort') + opts = pycompat.byteskwargs(opts) + defaultsort = b'branchsort' # for efficiency and consistency + sortmodes = (b'branchsort', b'datesort', b'sourcesort') sortmode = [m for m in sortmodes if opts.get(m)] if len(sortmode) > 1: - raise util.Abort(_('more than one sort mode specified')) - sortmode = sortmode and sortmode[0] or defaultsort + raise error.Abort(_(b'more than one sort mode specified')) + if sortmode: + sortmode = sortmode[0] + else: + sortmode = defaultsort # not implemented: filemap, revmapfile revmapfile = destc.revmapfile()
