Mercurial > hg > hg-fastimport
comparison hgext3rd/fastimport/__init__.py @ 96:7eb15a5c4cad
Be consitent in how we use strings
Everywhere else uses "string", so change to this in __init__.py
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 22 Jan 2021 00:03:52 +0000 |
| parents | 3b398a887b95 |
| children | cde0e1d24e58 |
comparison
equal
deleted
inserted
replaced
| 95:3b398a887b95 | 96:7eb15a5c4cad |
|---|---|
| 1 ''' import Git fast-import streams ''' | 1 """ import Git fast-import streams """ |
| 2 from __future__ import absolute_import | 2 from __future__ import absolute_import |
| 3 | 3 |
| 4 from mercurial import ( | 4 from mercurial import ( |
| 5 commands, | 5 commands, |
| 6 encoding, | 6 encoding, |
| 15 hg, | 15 hg, |
| 16 ) | 16 ) |
| 17 | 17 |
| 18 from .hgimport import fastimport_source | 18 from .hgimport import fastimport_source |
| 19 | 19 |
| 20 __version__ = b'0.1.0' | 20 __version__ = b"0.1.0" |
| 21 testedwith = b'5.6.1' | 21 testedwith = b"5.6.1" |
| 22 minimumhgversion = b'4.1' | 22 minimumhgversion = b"4.1" |
| 23 | 23 |
| 24 cmdtable = {} | 24 cmdtable = {} |
| 25 try: | 25 try: |
| 26 from mercurial import registrar | 26 from mercurial import registrar |
| 27 command = registrar.command(cmdtable) | 27 command = registrar.command(cmdtable) |
| 28 except (ImportError, AttributeError): | 28 except (ImportError, AttributeError): |
| 29 from mercurial import cmdutil | 29 from mercurial import cmdutil |
| 30 command = cmdutil.command(cmdtable) | 30 command = cmdutil.command(cmdtable) |
| 31 | 31 |
| 32 @command(b'fastimport', | 32 @command(b"fastimport", |
| 33 [(b'', b'branchsort', None, _(b'try to sort changesets by branches')), | 33 [(b"", b"branchsort", None, _(b"try to sort changesets by branches")), |
| 34 (b'', b'datesort', None, _(b'try to sort changesets by date')), | 34 (b"", b"datesort", None, _(b"try to sort changesets by date")), |
| 35 (b'', b'sourcesort', None, _(b'preserve source changesets order')), | 35 (b"", b"sourcesort", None, _(b"preserve source changesets order")), |
| 36 (b'', b'blobpath', b'', _(b'path for persistent blob data'))], | 36 (b"", b"blobpath", b"", _(b"path for persistent blob data"))], |
| 37 _(b'hg fastimport SOURCE ...'), | 37 _(b"hg fastimport SOURCE ..."), |
| 38 norepo=False) | 38 norepo=False) |
| 39 | 39 |
| 40 def fastimport(ui, repo, *sources, **opts): | 40 def fastimport(ui, repo, *sources, **opts): |
| 41 '''Convert a git fastimport dump into Mercurial changesets. | 41 """Convert a git fastimport dump into Mercurial changesets. |
| 42 | 42 |
| 43 Reads a series of SOURCE fastimport dumps and adds the resulting | 43 Reads a series of SOURCE fastimport dumps and adds the resulting |
| 44 changes to the current Mercurial repository. | 44 changes to the current Mercurial repository. |
| 45 ''' | 45 """ |
| 46 # Would be nice to just call hgext.convert.convcmd.convert() and let | 46 # Would be nice to just call hgext.convert.convcmd.convert() and let |
| 47 # it take care of things. But syntax and semantics are just a | 47 # it take care of things. But syntax and semantics are just a |
| 48 # little mismatched: | 48 # little mismatched: |
| 49 # - fastimport takes multiple source paths (mainly because cvs2git | 49 # - fastimport takes multiple source paths (mainly because cvs2git |
| 50 # produces 2 dump files) | 50 # produces 2 dump files) |
| 52 # | 52 # |
| 53 # So for the time being, I have copied bits of convert() over here. | 53 # So for the time being, I have copied bits of convert() over here. |
| 54 # Boo, hiss. | 54 # Boo, hiss. |
| 55 | 55 |
| 56 if not sources: | 56 if not sources: |
| 57 sources = (b'-') | 57 sources = (b"-") |
| 58 | 58 |
| 59 opts = pycompat.byteskwargs(opts) | 59 opts = pycompat.byteskwargs(opts) |
| 60 | 60 |
| 61 # assume fastimport metadata (usernames, commit messages) are | 61 # assume fastimport metadata (usernames, commit messages) are |
| 62 # encoded UTF-8 | 62 # encoded UTF-8 |
| 63 convcmd.orig_encoding = encoding.encoding | 63 convcmd.orig_encoding = encoding.encoding |
| 64 encoding.encoding = b'UTF-8' | 64 encoding.encoding = b"UTF-8" |
| 65 | 65 |
| 66 # sink is the current repo, src is the list of fastimport streams | 66 # sink is the current repo, src is the list of fastimport streams |
| 67 destc = hg.mercurial_sink(ui, b'hg', repo.root) | 67 destc = hg.mercurial_sink(ui, b"hg", repo.root) |
| 68 srcc = fastimport_source(ui, b'fastimport', repo, sources, opts[b'blobpath']) | 68 srcc = fastimport_source(ui, b"fastimport", repo, sources, opts[b"blobpath"]) |
| 69 | 69 |
| 70 defaultsort = b'branchsort' # for efficiency and consistency | 70 defaultsort = b"branchsort" # for efficiency and consistency |
| 71 sortmodes = (b'branchsort', b'datesort', b'sourcesort') | 71 sortmodes = (b"branchsort", b"datesort", b"sourcesort") |
| 72 sortmode = [m for m in sortmodes if opts.get(m)] | 72 sortmode = [m for m in sortmodes if opts.get(m)] |
| 73 if len(sortmode) > 1: | 73 if len(sortmode) > 1: |
| 74 raise error.Abort(_(b'more than one sort mode specified')) | 74 raise error.Abort(_(b"more than one sort mode specified")) |
| 75 if sortmode: | 75 if sortmode: |
| 76 sortmode = sortmode[0] | 76 sortmode = sortmode[0] |
| 77 else: | 77 else: |
| 78 sortmode = defaultsort | 78 sortmode = defaultsort |
| 79 | 79 |
