author | Matt Mackall <mpm@selenic.com> |
Thu, 14 Feb 2008 10:28:27 -0600 | |
changeset 6096 | d8477881ee0f |
parent 6035 | df659eb23360 |
child 6143 | 5b159ebb19cf |
permissions | -rw-r--r-- |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
1 |
# convert.py Foreign SCM converter |
3917
645e1dd4b8ae
convert-repo: update usage information
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3911
diff
changeset
|
2 |
# |
4635
63b9d2deed48
Updated copyright notices and add "and others" to "hg version"
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4591
diff
changeset
|
3 |
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
316 | 4 |
# |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
5 |
# This software may be used and distributed according to the terms |
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
6 |
# of the GNU General Public License, incorporated herein by reference. |
316 | 7 |
|
5621
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
8 |
import convcmd |
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
9 |
from mercurial import commands |
316 | 10 |
|
5621
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
11 |
# Commands definition was moved elsewhere to ease demandload job. |
694 | 12 |
|
5281
a176f9c8b26e
convert: rename a class and a function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5256
diff
changeset
|
13 |
def convert(ui, src, dest=None, revmapfile=None, **opts): |
4958
71fed370b7a7
Backout ad09ce1d393c and replace ''' with """ to make some highlighting happy.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4957
diff
changeset
|
14 |
"""Convert a foreign SCM repository to a Mercurial one. |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
15 |
|
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
16 |
Accepted source formats: |
5484
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
17 |
- Mercurial |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
18 |
- CVS |
5359
6b6104430964
convert: support darcs as a source repo
Bryan O'Sullivan <bos@serpentine.com>
parents:
5356
diff
changeset
|
19 |
- Darcs |
6b6104430964
convert: support darcs as a source repo
Bryan O'Sullivan <bos@serpentine.com>
parents:
5356
diff
changeset
|
20 |
- git |
6b6104430964
convert: support darcs as a source repo
Bryan O'Sullivan <bos@serpentine.com>
parents:
5356
diff
changeset
|
21 |
- Subversion |
6035
df659eb23360
convert: added GNU Arch source converter
Aleix Conchillo Flaque <aleix@member.fsf.org>
parents:
5760
diff
changeset
|
22 |
- GNU Arch |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
23 |
|
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
24 |
Accepted destination formats: |
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
25 |
- Mercurial |
5513
f0c58fd4b798
convert: add support for Subversion as a sink
Bryan O'Sullivan <bos@serpentine.com>
parents:
5510
diff
changeset
|
26 |
- Subversion (history on branches is not preserved) |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
27 |
|
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4719
diff
changeset
|
28 |
If no revision is given, all revisions will be converted. Otherwise, |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4719
diff
changeset
|
29 |
convert will only import up to the named revision (given in a format |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4719
diff
changeset
|
30 |
understood by the source). |
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4719
diff
changeset
|
31 |
|
4883
72ac66e88c43
convert: Use clone's behaviour for the default destionation name.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4719
diff
changeset
|
32 |
If no destination directory name is specified, it defaults to the |
4958
71fed370b7a7
Backout ad09ce1d393c and replace ''' with """ to make some highlighting happy.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4957
diff
changeset
|
33 |
basename of the source with '-hg' appended. If the destination |
71fed370b7a7
Backout ad09ce1d393c and replace ''' with """ to make some highlighting happy.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4957
diff
changeset
|
34 |
repository doesn't exist, it will be created. |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
35 |
|
5484
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
36 |
If <MAPFILE> isn't given, it will be put in a default location |
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
37 |
(<dest>/.hg/shamap by default). The <MAPFILE> is a simple text |
4883
72ac66e88c43
convert: Use clone's behaviour for the default destionation name.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4719
diff
changeset
|
38 |
file that maps each source commit ID to the destination ID for |
72ac66e88c43
convert: Use clone's behaviour for the default destionation name.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4719
diff
changeset
|
39 |
that revision, like so: |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
40 |
<source ID> <destination ID> |
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
41 |
|
4958
71fed370b7a7
Backout ad09ce1d393c and replace ''' with """ to make some highlighting happy.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4957
diff
changeset
|
42 |
If the file doesn't exist, it's automatically created. It's updated |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
43 |
on each commit copied, so convert-repo can be interrupted and can |
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
44 |
be run repeatedly to copy new commits. |
4589
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
45 |
|
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
46 |
The [username mapping] file is a simple text file that maps each source |
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
47 |
commit author to a destination commit author. It is handy for source SCMs |
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
48 |
that use unix logins to identify authors (eg: CVS). One line per author |
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
49 |
mapping and the line format is: |
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
50 |
srcauthor=whatever string you want |
5256
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
51 |
|
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
52 |
The filemap is a file that allows filtering and remapping of files |
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
53 |
and directories. Comment lines start with '#'. Each line can |
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
54 |
contain one of the following directives: |
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
55 |
|
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
56 |
include path/to/file |
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
57 |
|
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
58 |
exclude path/to/file |
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
59 |
|
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
60 |
rename from/file to/file |
5760
0145f9afb0e7
Removed tabs and trailing whitespace in python files
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5632
diff
changeset
|
61 |
|
5256
0b0caffcf175
convert: document filemap.
Bryan O'Sullivan <bos@serpentine.com>
parents:
5204
diff
changeset
|
62 |
The 'include' directive causes a file, or all files under a |
5484
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
63 |
directory, to be included in the destination repository, and the |
5488
247af577fe29
fix typo in convert help text, update test
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5484
diff
changeset
|
64 |
exclusion of all other files and dirs not explicitely included. |
5484
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
65 |
The 'exclude' directive causes files or directories to be omitted. |
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
66 |
The 'rename' directive renames a file or directory. To rename from a |
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
67 |
subdirectory into the root of the repository, use '.' as the path to |
07bdb5e5d08c
Update convert help text
"Rafael Villar Burke <pachi@rvburke.com>"
parents:
5441
diff
changeset
|
68 |
rename to. |
5556
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
69 |
|
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
70 |
Back end options: |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
71 |
|
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
72 |
--config convert.hg.clonebranches=False (boolean) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
73 |
hg target: XXX not documented |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
74 |
--config convert.hg.saverev=True (boolean) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
75 |
hg source: allow target to preserve source revision ID |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
76 |
--config convert.hg.tagsbranch=default (branch name) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
77 |
hg target: XXX not documented |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
78 |
--config convert.hg.usebranchnames=True (boolean) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
79 |
hg target: preserve branch names |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
80 |
|
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
81 |
--config convert.svn.branches=branches (directory name) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
82 |
svn source: specify the directory containing branches |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
83 |
--config convert.svn.tags=tags (directory name) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
84 |
svn source: specify the directory containing tags |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
85 |
--config convert.svn.trunk=trunk (directory name) |
61fdf2558c0a
convert: some tidyups, doc improvements, and test fixes
Bryan O'Sullivan <bos@serpentine.com>
parents:
5554
diff
changeset
|
86 |
svn source: specify the name of the trunk branch |
4958
71fed370b7a7
Backout ad09ce1d393c and replace ''' with """ to make some highlighting happy.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4957
diff
changeset
|
87 |
""" |
5621
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
88 |
return convcmd.convert(ui, src, dest, revmapfile, **opts) |
316 | 89 |
|
5621
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
90 |
def debugsvnlog(ui, **opts): |
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
91 |
return convcmd.debugsvnlog(ui, **opts) |
316 | 92 |
|
5621
badbefa55972
convert: move commands definition to ease demandload job (issue 860)
Patrick Mezard <pmezard@gmail.com>
parents:
5521
diff
changeset
|
93 |
commands.norepo += " convert debugsvnlog" |
5127
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5121
diff
changeset
|
94 |
|
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
95 |
cmdtable = { |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
96 |
"convert": |
5281
a176f9c8b26e
convert: rename a class and a function
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
5256
diff
changeset
|
97 |
(convert, |
4589
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
98 |
[('A', 'authors', '', 'username mapping filename'), |
5441
71e7c86adcb7
convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents:
5438
diff
changeset
|
99 |
('d', 'dest-type', '', 'destination repository type'), |
5016
4ebc8693ce72
convert: add filename filtering and renaming support
Bryan O'Sullivan <bos@serpentine.com>
parents:
5014
diff
changeset
|
100 |
('', 'filemap', '', 'remap file names using contents of file'), |
4760
07efcce17d28
convert: add -r argument specifying latest revision to convert
Brendan Cully <brendan@kublai.com>
parents:
4719
diff
changeset
|
101 |
('r', 'rev', '', 'import up to target revision REV'), |
5441
71e7c86adcb7
convert: refactor sink initialisation, to remove hardcoding of hg
Bryan O'Sullivan <bos@serpentine.com>
parents:
5438
diff
changeset
|
102 |
('s', 'source-type', '', 'source repository type'), |
4589
451e91ed535e
convert extension: Add support for username mapping
Edouard Gomez <ed.gomez@free.fr>
parents:
4588
diff
changeset
|
103 |
('', 'datesort', None, 'try to sort changesets by date')], |
4532
c3a78a49d7f0
Some small cleanups for convert extension:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
4521
diff
changeset
|
104 |
'hg convert [OPTION]... SOURCE [DEST [MAPFILE]]'), |
5138
9cda2315c7a9
convert: Use debugsvnlog instead of git-like debug-svn-log.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5134
diff
changeset
|
105 |
"debugsvnlog": |
5127
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5121
diff
changeset
|
106 |
(debugsvnlog, |
39b6eaee6fd7
convert: replace fork with subprocess call.
Patrick Mezard <pmezard@gmail.com>
parents:
5121
diff
changeset
|
107 |
[], |
5138
9cda2315c7a9
convert: Use debugsvnlog instead of git-like debug-svn-log.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
5134
diff
changeset
|
108 |
'hg debugsvnlog'), |
4513
ac2fe196ac9b
Turns convert.py into a real extension
Edouard Gomez <ed.gomez@free.fr>
parents:
4512
diff
changeset
|
109 |
} |