Mercurial > hg > hg-fastimport
diff hgfastimport/__init__.py @ 73:a99e5c6c8e1c
Fix compatibility with 4.6+
Update to work with hg 4.5+
Switch to modern @command decorator API
Adds compatiblility with hg 4.2
Clean up formatting and add description
Update to work with hg 3.4+
Update to work with hg 3.2+
This breaks compatibility with <3.2.
Merged from patches from github:danielj7/hg-fastimport
| author | Daniel Johnson <daniel@daniel-johnson.org> |
|---|---|
| date | Sun, 12 Aug 2018 07:54:35 -0400 |
| parents | 6b716ecb1cf3 |
| children | a4f13dc5e3f7 |
line wrap: on
line diff
--- a/hgfastimport/__init__.py Fri Dec 13 22:38:47 2013 -0500 +++ b/hgfastimport/__init__.py Sun Aug 12 07:54:35 2018 -0400 @@ -1,8 +1,36 @@ -from mercurial import encoding +''' import Git fast-import streams ''' +from __future__ import absolute_import + +from mercurial import ( + cmdutil, + encoding, + util, +) + from mercurial.i18n import _ -from hgext.convert import convcmd, hg + +from hgext.convert import ( + convcmd, + hg, +) + +from .hgimport import fastimport_source -from hgimport import fastimport_source +cmdtable = {} +try: + from mercurial import registrar + command = registrar.command(cmdtable) +except (ImportError, AttributeError): + 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) def fastimport(ui, repo, *sources, **opts): """Convert a git fastimport dump into Mercurial changesets. @@ -29,8 +57,8 @@ encoding.encoding = 'UTF-8' # sink is the current repo, src is the list of fastimport streams - destc = hg.mercurial_sink(ui, repo.root) - srcc = fastimport_source(ui, repo, sources) + destc = hg.mercurial_sink(ui, 'hg', repo.root) + srcc = fastimport_source(ui, 'fastimport', repo, sources) # XXX figuring out sortmode copied straight from hgext/convert/convcmd.py defaultsort = 'branchsort' # for efficiency and consistency @@ -39,19 +67,8 @@ if len(sortmode) > 1: raise util.Abort(_('more than one sort mode specified')) sortmode = sortmode and sortmode[0] or defaultsort - + # not implemented: filemap, revmapfile revmapfile = destc.revmapfile() c = convcmd.converter(ui, srcc, destc, revmapfile, opts) c.convert(sortmode) - -# XXX sort options copied straight from hgext/convert/__init__.py -cmdtable = { - "fastimport": - (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 ...') -}
