Mercurial > hg > hg-fastimport
comparison hgext3rd/fastimport/__init__.py @ 95:3b398a887b95
Use a sqlite3 database to store the blob data if available
This is much more performant than using a filesystem when we are
dealing with a large number of blobs.
If sqlite3 is not available, then fallback to writing to the filesystem.
In both cases, the blob data is compressed before writing to save space.
A new option has also been added to specify a path for persistent blob data.
This is only really important for large continuous interations where the
source data has no concept of export marks and thus only gets bigger.
What we gain here is a reduction in the write load on the disk.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 21 Jan 2021 23:59:21 +0000 |
| parents | dc1d11466aa6 |
| children | 7eb15a5c4cad |
comparison
equal
deleted
inserted
replaced
| 94:b18c5670f6c0 | 95:3b398a887b95 |
|---|---|
| 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'hg fastimport SOURCE ...'), | 37 _(b'hg fastimport SOURCE ...'), |
| 37 norepo=False) | 38 norepo=False) |
| 38 | 39 |
| 39 def fastimport(ui, repo, *sources, **opts): | 40 def fastimport(ui, repo, *sources, **opts): |
| 40 '''Convert a git fastimport dump into Mercurial changesets. | 41 '''Convert a git fastimport dump into Mercurial changesets. |
| 53 # Boo, hiss. | 54 # Boo, hiss. |
| 54 | 55 |
| 55 if not sources: | 56 if not sources: |
| 56 sources = (b'-') | 57 sources = (b'-') |
| 57 | 58 |
| 59 opts = pycompat.byteskwargs(opts) | |
| 60 | |
| 58 # assume fastimport metadata (usernames, commit messages) are | 61 # assume fastimport metadata (usernames, commit messages) are |
| 59 # encoded UTF-8 | 62 # encoded UTF-8 |
| 60 convcmd.orig_encoding = encoding.encoding | 63 convcmd.orig_encoding = encoding.encoding |
| 61 encoding.encoding = b'UTF-8' | 64 encoding.encoding = b'UTF-8' |
| 62 | 65 |
| 63 # 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 |
| 64 destc = hg.mercurial_sink(ui, b'hg', repo.root) | 67 destc = hg.mercurial_sink(ui, b'hg', repo.root) |
| 65 srcc = fastimport_source(ui, b'fastimport', repo, sources) | 68 srcc = fastimport_source(ui, b'fastimport', repo, sources, opts[b'blobpath']) |
| 66 | 69 |
| 67 opts = pycompat.byteskwargs(opts) | |
| 68 defaultsort = b'branchsort' # for efficiency and consistency | 70 defaultsort = b'branchsort' # for efficiency and consistency |
| 69 sortmodes = (b'branchsort', b'datesort', b'sourcesort') | 71 sortmodes = (b'branchsort', b'datesort', b'sourcesort') |
| 70 sortmode = [m for m in sortmodes if opts.get(m)] | 72 sortmode = [m for m in sortmodes if opts.get(m)] |
| 71 if len(sortmode) > 1: | 73 if len(sortmode) > 1: |
| 72 raise error.Abort(_(b'more than one sort mode specified')) | 74 raise error.Abort(_(b'more than one sort mode specified')) |
