Mercurial > hg > hg-fastimport
annotate hgfastimport/__init__.py @ 47:7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
fastimport no longer stages changes in the repository's working copy;
instead, it now works like any other convert source: the imported
history is kept in memory (except for file contents) and then
processed by the 'convert' extension.
| author | Greg Ward <greg-hg@gerg.ca> |
|---|---|
| date | Sat, 16 May 2009 12:57:22 -0400 |
| parents | 08e2157aaa9a |
| children | b027552d517b |
| rev | line source |
|---|---|
|
47
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
1 from mercurial import encoding |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
2 from hgext.convert import convcmd, hg |
|
0
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
3 |
|
34
08e2157aaa9a
Remove local fork of bzr-fastimport; use my fastimport library instead.
Greg Ward <greg-hg@gerg.ca>
parents:
33
diff
changeset
|
4 from fastimport import parser |
|
47
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
5 from hgfastimport.hgimport import fastimport_source |
|
0
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
6 |
|
14
f6f0fd01b34a
Preliminary support for reading multiple input files.
Greg Ward <greg-hg@gerg.ca>
parents:
1
diff
changeset
|
7 def fastimport(ui, repo, *sources, **opts): |
|
47
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
8 """Convert a git fastimport dump into Mercurial changesets. |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
9 |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
10 Reads a series of SOURCE fastimport dumps and adds the resulting |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
11 changes to the current Mercurial repository. |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
12 """ |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
13 # Would be nice to just call hgext.convert.convcmd.convert() and let |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
14 # it take care of things. But syntax and semantics are just a |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
15 # little mismatched: |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
16 # - fastimport takes multiple source paths (mainly because cvs2git |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
17 # produces 2 dump files) |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
18 # - fastimport's dest is implicitly the current repo |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
19 # |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
20 # So for the time being, I have copied bits of convert() over here. |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
21 # Boo, hiss. |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
22 |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
23 # assume fastimport metadata (usernames, commit messages) are |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
24 # encoded UTF-8 |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
25 convcmd.orig_encoding = encoding.encoding |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
26 encoding.encoding = 'UTF-8' |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
27 |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
28 # sink is the current repo, src is the list of fastimport streams |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
29 destc = hg.mercurial_sink(ui, repo.root) |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
30 srcc = fastimport_source(ui, repo, sources) |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
31 |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
32 # TEMP hack to keep old behaviour and minimize test churn |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
33 # (this should be an option to fastimport) |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
34 opts['datesort'] = True |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
35 |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
36 # not implemented: filemap, revmapfile |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
37 revmapfile = destc.revmapfile() |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
38 c = convcmd.converter(ui, srcc, destc, revmapfile, opts) |
|
7ff36dc9f0b1
Massive rework to use infrastructure provided by convert extension.
Greg Ward <greg-hg@gerg.ca>
parents:
34
diff
changeset
|
39 c.convert() |
|
0
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
40 |
|
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
41 cmdtable = { |
|
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
42 "fastimport": |
|
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
43 (fastimport, |
|
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
44 [], |
|
14
f6f0fd01b34a
Preliminary support for reading multiple input files.
Greg Ward <greg-hg@gerg.ca>
parents:
1
diff
changeset
|
45 'hg fastimport SOURCE ...') |
|
0
d107c6d36780
Add the start of the hg fastimport command
Paul Crowley <paul@lshift.net>
parents:
diff
changeset
|
46 } |
