Show More
@@ -1,196 +1,197 b'' | |||
|
1 | 1 | # convert.py Foreign SCM converter |
|
2 | 2 | # |
|
3 | 3 | # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> |
|
4 | 4 | # |
|
5 | 5 | # This software may be used and distributed according to the terms |
|
6 | 6 | # of the GNU General Public License, incorporated herein by reference. |
|
7 | 7 | '''converting foreign VCS repositories to Mercurial''' |
|
8 | 8 | |
|
9 | 9 | import convcmd |
|
10 | 10 | from mercurial import commands |
|
11 | from mercurial.i18n import _ | |
|
11 | 12 | |
|
12 | 13 | # Commands definition was moved elsewhere to ease demandload job. |
|
13 | 14 | |
|
14 | 15 | def convert(ui, src, dest=None, revmapfile=None, **opts): |
|
15 | 16 | """Convert a foreign SCM repository to a Mercurial one. |
|
16 | 17 | |
|
17 | 18 | Accepted source formats [identifiers]: |
|
18 | 19 | - Mercurial [hg] |
|
19 | 20 | - CVS [cvs] |
|
20 | 21 | - Darcs [darcs] |
|
21 | 22 | - git [git] |
|
22 | 23 | - Subversion [svn] |
|
23 | 24 | - Monotone [mtn] |
|
24 | 25 | - GNU Arch [gnuarch] |
|
25 | 26 | |
|
26 | 27 | Accepted destination formats [identifiers]: |
|
27 | 28 | - Mercurial [hg] |
|
28 | 29 | - Subversion [svn] (history on branches is not preserved) |
|
29 | 30 | |
|
30 | 31 | If no revision is given, all revisions will be converted. Otherwise, |
|
31 | 32 | convert will only import up to the named revision (given in a format |
|
32 | 33 | understood by the source). |
|
33 | 34 | |
|
34 | 35 | If no destination directory name is specified, it defaults to the |
|
35 | 36 | basename of the source with '-hg' appended. If the destination |
|
36 | 37 | repository doesn't exist, it will be created. |
|
37 | 38 | |
|
38 | 39 | If <REVMAP> isn't given, it will be put in a default location |
|
39 | 40 | (<dest>/.hg/shamap by default). The <REVMAP> is a simple text |
|
40 | 41 | file that maps each source commit ID to the destination ID for |
|
41 | 42 | that revision, like so: |
|
42 | 43 | <source ID> <destination ID> |
|
43 | 44 | |
|
44 | 45 | If the file doesn't exist, it's automatically created. It's updated |
|
45 | 46 | on each commit copied, so convert-repo can be interrupted and can |
|
46 | 47 | be run repeatedly to copy new commits. |
|
47 | 48 | |
|
48 | 49 | The [username mapping] file is a simple text file that maps each source |
|
49 | 50 | commit author to a destination commit author. It is handy for source SCMs |
|
50 | 51 | that use unix logins to identify authors (eg: CVS). One line per author |
|
51 | 52 | mapping and the line format is: |
|
52 | 53 | srcauthor=whatever string you want |
|
53 | 54 | |
|
54 | 55 | The filemap is a file that allows filtering and remapping of files |
|
55 | 56 | and directories. Comment lines start with '#'. Each line can |
|
56 | 57 | contain one of the following directives: |
|
57 | 58 | |
|
58 | 59 | include path/to/file |
|
59 | 60 | |
|
60 | 61 | exclude path/to/file |
|
61 | 62 | |
|
62 | 63 | rename from/file to/file |
|
63 | 64 | |
|
64 | 65 | The 'include' directive causes a file, or all files under a |
|
65 | 66 | directory, to be included in the destination repository, and the |
|
66 | 67 | exclusion of all other files and dirs not explicitely included. |
|
67 | 68 | The 'exclude' directive causes files or directories to be omitted. |
|
68 | 69 | The 'rename' directive renames a file or directory. To rename from a |
|
69 | 70 | subdirectory into the root of the repository, use '.' as the path to |
|
70 | 71 | rename to. |
|
71 | 72 | |
|
72 | 73 | The splicemap is a file that allows insertion of synthetic |
|
73 | 74 | history, letting you specify the parents of a revision. This is |
|
74 | 75 | useful if you want to e.g. give a Subversion merge two parents, or |
|
75 | 76 | graft two disconnected series of history together. Each entry |
|
76 | 77 | contains a key, followed by a space, followed by one or two |
|
77 | 78 | values, separated by spaces. The key is the revision ID in the |
|
78 | 79 | source revision control system whose parents should be modified |
|
79 | 80 | (same format as a key in .hg/shamap). The values are the revision |
|
80 | 81 | IDs (in either the source or destination revision control system) |
|
81 | 82 | that should be used as the new parents for that node. |
|
82 | 83 | |
|
83 | 84 | Mercurial Source |
|
84 | 85 | ----------------- |
|
85 | 86 | |
|
86 | 87 | --config convert.hg.saverev=True (boolean) |
|
87 | 88 | allow target to preserve source revision ID |
|
88 | 89 | --config convert.hg.startrev=0 (hg revision identifier) |
|
89 | 90 | convert start revision and its descendants |
|
90 | 91 | |
|
91 | 92 | CVS Source |
|
92 | 93 | ---------- |
|
93 | 94 | |
|
94 | 95 | CVS source will use a sandbox (i.e. a checked-out copy) from CVS |
|
95 | 96 | to indicate the starting point of what will be converted. Direct |
|
96 | 97 | access to the repository files is not needed, unless of course |
|
97 | 98 | the repository is :local:. The conversion uses the top level |
|
98 | 99 | directory in the sandbox to find the CVS repository, and then uses |
|
99 | 100 | CVS rlog commands to find files to convert. This means that unless |
|
100 | 101 | a filemap is given, all files under the starting directory will be |
|
101 | 102 | converted, and that any directory reorganisation in the CVS |
|
102 | 103 | sandbox is ignored. |
|
103 | 104 | |
|
104 | 105 | Because CVS does not have changesets, it is necessary to collect |
|
105 | 106 | individual commits to CVS and merge them into changesets. CVS source |
|
106 | 107 | can use the external 'cvsps' program (this is a legacy option and may |
|
107 | 108 | be removed in future) or use its internal changeset merging code. |
|
108 | 109 | External cvsps is default, and options may be passed to it by setting |
|
109 | 110 | --config convert.cvsps='cvsps -A -u --cvs-direct -q' |
|
110 | 111 | The options shown are the defaults. |
|
111 | 112 | |
|
112 | 113 | Internal cvsps is selected by setting |
|
113 | 114 | --config convert.cvsps=builtin |
|
114 | 115 | and has a few more configurable options: |
|
115 | 116 | --config convert.cvsps.fuzz=60 (integer) |
|
116 | 117 | Specify the maximum time (in seconds) that is allowed between |
|
117 | 118 | commits with identical user and log message in a single |
|
118 | 119 | changeset. When very large files were checked in as part |
|
119 | 120 | of a changeset then the default may not be long enough. |
|
120 | 121 | --config convert.cvsps.mergeto='{{mergetobranch ([-\w]+)}}' |
|
121 | 122 | Specify a regular expression to which commit log messages are |
|
122 | 123 | matched. If a match occurs, then the conversion process will |
|
123 | 124 | insert a dummy revision merging the branch on which this log |
|
124 | 125 | message occurs to the branch indicated in the regex. |
|
125 | 126 | --config convert.cvsps.mergefrom='{{mergefrombranch ([-\w]+)}}' |
|
126 | 127 | Specify a regular expression to which commit log messages are |
|
127 | 128 | matched. If a match occurs, then the conversion process will |
|
128 | 129 | add the most recent revision on the branch indicated in the |
|
129 | 130 | regex as the second parent of the changeset. |
|
130 | 131 | |
|
131 | 132 | The hgext/convert/cvsps wrapper script allows the builtin changeset |
|
132 | 133 | merging code to be run without doing a conversion. Its parameters and |
|
133 | 134 | output are similar to that of cvsps 2.1. |
|
134 | 135 | |
|
135 | 136 | Subversion Source |
|
136 | 137 | ----------------- |
|
137 | 138 | |
|
138 | 139 | Subversion source detects classical trunk/branches/tags layouts. |
|
139 | 140 | By default, the supplied "svn://repo/path/" source URL is |
|
140 | 141 | converted as a single branch. If "svn://repo/path/trunk" exists |
|
141 | 142 | it replaces the default branch. If "svn://repo/path/branches" |
|
142 | 143 | exists, its subdirectories are listed as possible branches. If |
|
143 | 144 | "svn://repo/path/tags" exists, it is looked for tags referencing |
|
144 | 145 | converted branches. Default "trunk", "branches" and "tags" values |
|
145 | 146 | can be overriden with following options. Set them to paths |
|
146 | 147 | relative to the source URL, or leave them blank to disable |
|
147 | 148 | autodetection. |
|
148 | 149 | |
|
149 | 150 | --config convert.svn.branches=branches (directory name) |
|
150 | 151 | specify the directory containing branches |
|
151 | 152 | --config convert.svn.tags=tags (directory name) |
|
152 | 153 | specify the directory containing tags |
|
153 | 154 | --config convert.svn.trunk=trunk (directory name) |
|
154 | 155 | specify the name of the trunk branch |
|
155 | 156 | |
|
156 | 157 | Source history can be retrieved starting at a specific revision, |
|
157 | 158 | instead of being integrally converted. Only single branch |
|
158 | 159 | conversions are supported. |
|
159 | 160 | |
|
160 | 161 | --config convert.svn.startrev=0 (svn revision number) |
|
161 | 162 | specify start Subversion revision. |
|
162 | 163 | |
|
163 | 164 | Mercurial Destination |
|
164 | 165 | --------------------- |
|
165 | 166 | |
|
166 | 167 | --config convert.hg.clonebranches=False (boolean) |
|
167 | 168 | dispatch source branches in separate clones. |
|
168 | 169 | --config convert.hg.tagsbranch=default (branch name) |
|
169 | 170 | tag revisions branch name |
|
170 | 171 | --config convert.hg.usebranchnames=True (boolean) |
|
171 | 172 | preserve branch names |
|
172 | 173 | |
|
173 | 174 | """ |
|
174 | 175 | return convcmd.convert(ui, src, dest, revmapfile, **opts) |
|
175 | 176 | |
|
176 | 177 | def debugsvnlog(ui, **opts): |
|
177 | 178 | return convcmd.debugsvnlog(ui, **opts) |
|
178 | 179 | |
|
179 | 180 | commands.norepo += " convert debugsvnlog" |
|
180 | 181 | |
|
181 | 182 | cmdtable = { |
|
182 | 183 | "convert": |
|
183 | 184 | (convert, |
|
184 | [('A', 'authors', '', 'username mapping filename'), | |
|
185 | ('d', 'dest-type', '', 'destination repository type'), | |
|
186 | ('', 'filemap', '', 'remap file names using contents of file'), | |
|
187 | ('r', 'rev', '', 'import up to target revision REV'), | |
|
188 | ('s', 'source-type', '', 'source repository type'), | |
|
189 | ('', 'splicemap', '', 'splice synthesized history into place'), | |
|
190 | ('', 'datesort', None, 'try to sort changesets by date')], | |
|
191 | 'hg convert [OPTION]... SOURCE [DEST [REVMAP]]'), | |
|
185 | [('A', 'authors', '', _('username mapping filename')), | |
|
186 | ('d', 'dest-type', '', _('destination repository type')), | |
|
187 | ('', 'filemap', '', _('remap file names using contents of file')), | |
|
188 | ('r', 'rev', '', _('import up to target revision REV')), | |
|
189 | ('s', 'source-type', '', _('source repository type')), | |
|
190 | ('', 'splicemap', '', _('splice synthesized history into place')), | |
|
191 | ('', 'datesort', None, _('try to sort changesets by date'))], | |
|
192 | _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')), | |
|
192 | 193 | "debugsvnlog": |
|
193 | 194 | (debugsvnlog, |
|
194 | 195 | [], |
|
195 | 196 | 'hg debugsvnlog'), |
|
196 | 197 | } |
General Comments 0
You need to be logged in to leave comments.
Login now