##// END OF EJS Templates
convert: add svnrev, svnpath and svnuuid template keywords...
Patrick Mezard -
r13691:ad02eba5 default
parent child Browse files
Show More
@@ -1,336 +1,364 b''
1 # convert.py Foreign SCM converter
1 # convert.py Foreign SCM converter
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 '''import revisions from foreign VCS repositories into Mercurial'''
8 '''import revisions from foreign VCS repositories into Mercurial'''
9
9
10 import convcmd
10 import convcmd
11 import cvsps
11 import cvsps
12 import subversion
12 import subversion
13 from mercurial import commands
13 from mercurial import commands, templatekw
14 from mercurial.i18n import _
14 from mercurial.i18n import _
15
15
16 # Commands definition was moved elsewhere to ease demandload job.
16 # Commands definition was moved elsewhere to ease demandload job.
17
17
18 def convert(ui, src, dest=None, revmapfile=None, **opts):
18 def convert(ui, src, dest=None, revmapfile=None, **opts):
19 """convert a foreign SCM repository to a Mercurial one.
19 """convert a foreign SCM repository to a Mercurial one.
20
20
21 Accepted source formats [identifiers]:
21 Accepted source formats [identifiers]:
22
22
23 - Mercurial [hg]
23 - Mercurial [hg]
24 - CVS [cvs]
24 - CVS [cvs]
25 - Darcs [darcs]
25 - Darcs [darcs]
26 - git [git]
26 - git [git]
27 - Subversion [svn]
27 - Subversion [svn]
28 - Monotone [mtn]
28 - Monotone [mtn]
29 - GNU Arch [gnuarch]
29 - GNU Arch [gnuarch]
30 - Bazaar [bzr]
30 - Bazaar [bzr]
31 - Perforce [p4]
31 - Perforce [p4]
32
32
33 Accepted destination formats [identifiers]:
33 Accepted destination formats [identifiers]:
34
34
35 - Mercurial [hg]
35 - Mercurial [hg]
36 - Subversion [svn] (history on branches is not preserved)
36 - Subversion [svn] (history on branches is not preserved)
37
37
38 If no revision is given, all revisions will be converted.
38 If no revision is given, all revisions will be converted.
39 Otherwise, convert will only import up to the named revision
39 Otherwise, convert will only import up to the named revision
40 (given in a format understood by the source).
40 (given in a format understood by the source).
41
41
42 If no destination directory name is specified, it defaults to the
42 If no destination directory name is specified, it defaults to the
43 basename of the source with ``-hg`` appended. If the destination
43 basename of the source with ``-hg`` appended. If the destination
44 repository doesn't exist, it will be created.
44 repository doesn't exist, it will be created.
45
45
46 By default, all sources except Mercurial will use --branchsort.
46 By default, all sources except Mercurial will use --branchsort.
47 Mercurial uses --sourcesort to preserve original revision numbers
47 Mercurial uses --sourcesort to preserve original revision numbers
48 order. Sort modes have the following effects:
48 order. Sort modes have the following effects:
49
49
50 --branchsort convert from parent to child revision when possible,
50 --branchsort convert from parent to child revision when possible,
51 which means branches are usually converted one after
51 which means branches are usually converted one after
52 the other. It generates more compact repositories.
52 the other. It generates more compact repositories.
53
53
54 --datesort sort revisions by date. Converted repositories have
54 --datesort sort revisions by date. Converted repositories have
55 good-looking changelogs but are often an order of
55 good-looking changelogs but are often an order of
56 magnitude larger than the same ones generated by
56 magnitude larger than the same ones generated by
57 --branchsort.
57 --branchsort.
58
58
59 --sourcesort try to preserve source revisions order, only
59 --sourcesort try to preserve source revisions order, only
60 supported by Mercurial sources.
60 supported by Mercurial sources.
61
61
62 If ``REVMAP`` isn't given, it will be put in a default location
62 If ``REVMAP`` isn't given, it will be put in a default location
63 (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
63 (``<dest>/.hg/shamap`` by default). The ``REVMAP`` is a simple
64 text file that maps each source commit ID to the destination ID
64 text file that maps each source commit ID to the destination ID
65 for that revision, like so::
65 for that revision, like so::
66
66
67 <source ID> <destination ID>
67 <source ID> <destination ID>
68
68
69 If the file doesn't exist, it's automatically created. It's
69 If the file doesn't exist, it's automatically created. It's
70 updated on each commit copied, so :hg:`convert` can be interrupted
70 updated on each commit copied, so :hg:`convert` can be interrupted
71 and can be run repeatedly to copy new commits.
71 and can be run repeatedly to copy new commits.
72
72
73 The authormap is a simple text file that maps each source commit
73 The authormap is a simple text file that maps each source commit
74 author to a destination commit author. It is handy for source SCMs
74 author to a destination commit author. It is handy for source SCMs
75 that use unix logins to identify authors (eg: CVS). One line per
75 that use unix logins to identify authors (eg: CVS). One line per
76 author mapping and the line format is::
76 author mapping and the line format is::
77
77
78 source author = destination author
78 source author = destination author
79
79
80 Empty lines and lines starting with a ``#`` are ignored.
80 Empty lines and lines starting with a ``#`` are ignored.
81
81
82 The filemap is a file that allows filtering and remapping of files
82 The filemap is a file that allows filtering and remapping of files
83 and directories. Each line can contain one of the following
83 and directories. Each line can contain one of the following
84 directives::
84 directives::
85
85
86 include path/to/file-or-dir
86 include path/to/file-or-dir
87
87
88 exclude path/to/file-or-dir
88 exclude path/to/file-or-dir
89
89
90 rename path/to/source path/to/destination
90 rename path/to/source path/to/destination
91
91
92 Comment lines start with ``#``. A specified path matches if it
92 Comment lines start with ``#``. A specified path matches if it
93 equals the full relative name of a file or one of its parent
93 equals the full relative name of a file or one of its parent
94 directories. The ``include`` or ``exclude`` directive with the
94 directories. The ``include`` or ``exclude`` directive with the
95 longest matching path applies, so line order does not matter.
95 longest matching path applies, so line order does not matter.
96
96
97 The ``include`` directive causes a file, or all files under a
97 The ``include`` directive causes a file, or all files under a
98 directory, to be included in the destination repository, and the
98 directory, to be included in the destination repository, and the
99 exclusion of all other files and directories not explicitly
99 exclusion of all other files and directories not explicitly
100 included. The ``exclude`` directive causes files or directories to
100 included. The ``exclude`` directive causes files or directories to
101 be omitted. The ``rename`` directive renames a file or directory if
101 be omitted. The ``rename`` directive renames a file or directory if
102 it is converted. To rename from a subdirectory into the root of
102 it is converted. To rename from a subdirectory into the root of
103 the repository, use ``.`` as the path to rename to.
103 the repository, use ``.`` as the path to rename to.
104
104
105 The splicemap is a file that allows insertion of synthetic
105 The splicemap is a file that allows insertion of synthetic
106 history, letting you specify the parents of a revision. This is
106 history, letting you specify the parents of a revision. This is
107 useful if you want to e.g. give a Subversion merge two parents, or
107 useful if you want to e.g. give a Subversion merge two parents, or
108 graft two disconnected series of history together. Each entry
108 graft two disconnected series of history together. Each entry
109 contains a key, followed by a space, followed by one or two
109 contains a key, followed by a space, followed by one or two
110 comma-separated values::
110 comma-separated values::
111
111
112 key parent1, parent2
112 key parent1, parent2
113
113
114 The key is the revision ID in the source
114 The key is the revision ID in the source
115 revision control system whose parents should be modified (same
115 revision control system whose parents should be modified (same
116 format as a key in .hg/shamap). The values are the revision IDs
116 format as a key in .hg/shamap). The values are the revision IDs
117 (in either the source or destination revision control system) that
117 (in either the source or destination revision control system) that
118 should be used as the new parents for that node. For example, if
118 should be used as the new parents for that node. For example, if
119 you have merged "release-1.0" into "trunk", then you should
119 you have merged "release-1.0" into "trunk", then you should
120 specify the revision on "trunk" as the first parent and the one on
120 specify the revision on "trunk" as the first parent and the one on
121 the "release-1.0" branch as the second.
121 the "release-1.0" branch as the second.
122
122
123 The branchmap is a file that allows you to rename a branch when it is
123 The branchmap is a file that allows you to rename a branch when it is
124 being brought in from whatever external repository. When used in
124 being brought in from whatever external repository. When used in
125 conjunction with a splicemap, it allows for a powerful combination
125 conjunction with a splicemap, it allows for a powerful combination
126 to help fix even the most badly mismanaged repositories and turn them
126 to help fix even the most badly mismanaged repositories and turn them
127 into nicely structured Mercurial repositories. The branchmap contains
127 into nicely structured Mercurial repositories. The branchmap contains
128 lines of the form::
128 lines of the form::
129
129
130 original_branch_name new_branch_name
130 original_branch_name new_branch_name
131
131
132 where "original_branch_name" is the name of the branch in the
132 where "original_branch_name" is the name of the branch in the
133 source repository, and "new_branch_name" is the name of the branch
133 source repository, and "new_branch_name" is the name of the branch
134 is the destination repository. No whitespace is allowed in the
134 is the destination repository. No whitespace is allowed in the
135 branch names. This can be used to (for instance) move code in one
135 branch names. This can be used to (for instance) move code in one
136 repository from "default" to a named branch.
136 repository from "default" to a named branch.
137
137
138 Mercurial Source
138 Mercurial Source
139 ''''''''''''''''
139 ''''''''''''''''
140
140
141 The Mercurial source recognizes the following configuration
141 The Mercurial source recognizes the following configuration
142 options, which you can set on the command line with ``--config``:
142 options, which you can set on the command line with ``--config``:
143
143
144 :convert.hg.ignoreerrors: ignore integrity errors when reading.
144 :convert.hg.ignoreerrors: ignore integrity errors when reading.
145 Use it to fix Mercurial repositories with missing revlogs, by
145 Use it to fix Mercurial repositories with missing revlogs, by
146 converting from and to Mercurial. Default is False.
146 converting from and to Mercurial. Default is False.
147
147
148 :convert.hg.saverev: store original revision ID in changeset
148 :convert.hg.saverev: store original revision ID in changeset
149 (forces target IDs to change). It takes and boolean argument
149 (forces target IDs to change). It takes and boolean argument
150 and defaults to False.
150 and defaults to False.
151
151
152 :convert.hg.startrev: convert start revision and its descendants.
152 :convert.hg.startrev: convert start revision and its descendants.
153 It takes a hg revision identifier and defaults to 0.
153 It takes a hg revision identifier and defaults to 0.
154
154
155 CVS Source
155 CVS Source
156 ''''''''''
156 ''''''''''
157
157
158 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
158 CVS source will use a sandbox (i.e. a checked-out copy) from CVS
159 to indicate the starting point of what will be converted. Direct
159 to indicate the starting point of what will be converted. Direct
160 access to the repository files is not needed, unless of course the
160 access to the repository files is not needed, unless of course the
161 repository is ``:local:``. The conversion uses the top level
161 repository is ``:local:``. The conversion uses the top level
162 directory in the sandbox to find the CVS repository, and then uses
162 directory in the sandbox to find the CVS repository, and then uses
163 CVS rlog commands to find files to convert. This means that unless
163 CVS rlog commands to find files to convert. This means that unless
164 a filemap is given, all files under the starting directory will be
164 a filemap is given, all files under the starting directory will be
165 converted, and that any directory reorganization in the CVS
165 converted, and that any directory reorganization in the CVS
166 sandbox is ignored.
166 sandbox is ignored.
167
167
168 The following options can be used with ``--config``:
168 The following options can be used with ``--config``:
169
169
170 :convert.cvsps.cache: Set to False to disable remote log caching,
170 :convert.cvsps.cache: Set to False to disable remote log caching,
171 for testing and debugging purposes. Default is True.
171 for testing and debugging purposes. Default is True.
172
172
173 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
173 :convert.cvsps.fuzz: Specify the maximum time (in seconds) that is
174 allowed between commits with identical user and log message in
174 allowed between commits with identical user and log message in
175 a single changeset. When very large files were checked in as
175 a single changeset. When very large files were checked in as
176 part of a changeset then the default may not be long enough.
176 part of a changeset then the default may not be long enough.
177 The default is 60.
177 The default is 60.
178
178
179 :convert.cvsps.mergeto: Specify a regular expression to which
179 :convert.cvsps.mergeto: Specify a regular expression to which
180 commit log messages are matched. If a match occurs, then the
180 commit log messages are matched. If a match occurs, then the
181 conversion process will insert a dummy revision merging the
181 conversion process will insert a dummy revision merging the
182 branch on which this log message occurs to the branch
182 branch on which this log message occurs to the branch
183 indicated in the regex. Default is ``{{mergetobranch
183 indicated in the regex. Default is ``{{mergetobranch
184 ([-\\w]+)}}``
184 ([-\\w]+)}}``
185
185
186 :convert.cvsps.mergefrom: Specify a regular expression to which
186 :convert.cvsps.mergefrom: Specify a regular expression to which
187 commit log messages are matched. If a match occurs, then the
187 commit log messages are matched. If a match occurs, then the
188 conversion process will add the most recent revision on the
188 conversion process will add the most recent revision on the
189 branch indicated in the regex as the second parent of the
189 branch indicated in the regex as the second parent of the
190 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
190 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
191
191
192 :hook.cvslog: Specify a Python function to be called at the end of
192 :hook.cvslog: Specify a Python function to be called at the end of
193 gathering the CVS log. The function is passed a list with the
193 gathering the CVS log. The function is passed a list with the
194 log entries, and can modify the entries in-place, or add or
194 log entries, and can modify the entries in-place, or add or
195 delete them.
195 delete them.
196
196
197 :hook.cvschangesets: Specify a Python function to be called after
197 :hook.cvschangesets: Specify a Python function to be called after
198 the changesets are calculated from the the CVS log. The
198 the changesets are calculated from the the CVS log. The
199 function is passed a list with the changeset entries, and can
199 function is passed a list with the changeset entries, and can
200 modify the changesets in-place, or add or delete them.
200 modify the changesets in-place, or add or delete them.
201
201
202 An additional "debugcvsps" Mercurial command allows the builtin
202 An additional "debugcvsps" Mercurial command allows the builtin
203 changeset merging code to be run without doing a conversion. Its
203 changeset merging code to be run without doing a conversion. Its
204 parameters and output are similar to that of cvsps 2.1. Please see
204 parameters and output are similar to that of cvsps 2.1. Please see
205 the command help for more details.
205 the command help for more details.
206
206
207 Subversion Source
207 Subversion Source
208 '''''''''''''''''
208 '''''''''''''''''
209
209
210 Subversion source detects classical trunk/branches/tags layouts.
210 Subversion source detects classical trunk/branches/tags layouts.
211 By default, the supplied ``svn://repo/path/`` source URL is
211 By default, the supplied ``svn://repo/path/`` source URL is
212 converted as a single branch. If ``svn://repo/path/trunk`` exists
212 converted as a single branch. If ``svn://repo/path/trunk`` exists
213 it replaces the default branch. If ``svn://repo/path/branches``
213 it replaces the default branch. If ``svn://repo/path/branches``
214 exists, its subdirectories are listed as possible branches. If
214 exists, its subdirectories are listed as possible branches. If
215 ``svn://repo/path/tags`` exists, it is looked for tags referencing
215 ``svn://repo/path/tags`` exists, it is looked for tags referencing
216 converted branches. Default ``trunk``, ``branches`` and ``tags``
216 converted branches. Default ``trunk``, ``branches`` and ``tags``
217 values can be overridden with following options. Set them to paths
217 values can be overridden with following options. Set them to paths
218 relative to the source URL, or leave them blank to disable auto
218 relative to the source URL, or leave them blank to disable auto
219 detection.
219 detection.
220
220
221 The following options can be set with ``--config``:
221 The following options can be set with ``--config``:
222
222
223 :convert.svn.branches: specify the directory containing branches.
223 :convert.svn.branches: specify the directory containing branches.
224 The default is ``branches``.
224 The default is ``branches``.
225
225
226 :convert.svn.tags: specify the directory containing tags. The
226 :convert.svn.tags: specify the directory containing tags. The
227 default is ``tags``.
227 default is ``tags``.
228
228
229 :convert.svn.trunk: specify the name of the trunk branch. The
229 :convert.svn.trunk: specify the name of the trunk branch. The
230 default is ``trunk``.
230 default is ``trunk``.
231
231
232 Source history can be retrieved starting at a specific revision,
232 Source history can be retrieved starting at a specific revision,
233 instead of being integrally converted. Only single branch
233 instead of being integrally converted. Only single branch
234 conversions are supported.
234 conversions are supported.
235
235
236 :convert.svn.startrev: specify start Subversion revision number.
236 :convert.svn.startrev: specify start Subversion revision number.
237 The default is 0.
237 The default is 0.
238
238
239 Perforce Source
239 Perforce Source
240 '''''''''''''''
240 '''''''''''''''
241
241
242 The Perforce (P4) importer can be given a p4 depot path or a
242 The Perforce (P4) importer can be given a p4 depot path or a
243 client specification as source. It will convert all files in the
243 client specification as source. It will convert all files in the
244 source to a flat Mercurial repository, ignoring labels, branches
244 source to a flat Mercurial repository, ignoring labels, branches
245 and integrations. Note that when a depot path is given you then
245 and integrations. Note that when a depot path is given you then
246 usually should specify a target directory, because otherwise the
246 usually should specify a target directory, because otherwise the
247 target may be named ``...-hg``.
247 target may be named ``...-hg``.
248
248
249 It is possible to limit the amount of source history to be
249 It is possible to limit the amount of source history to be
250 converted by specifying an initial Perforce revision:
250 converted by specifying an initial Perforce revision:
251
251
252 :convert.p4.startrev: specify initial Perforce revision (a
252 :convert.p4.startrev: specify initial Perforce revision (a
253 Perforce changelist number).
253 Perforce changelist number).
254
254
255 Mercurial Destination
255 Mercurial Destination
256 '''''''''''''''''''''
256 '''''''''''''''''''''
257
257
258 The following options are supported:
258 The following options are supported:
259
259
260 :convert.hg.clonebranches: dispatch source branches in separate
260 :convert.hg.clonebranches: dispatch source branches in separate
261 clones. The default is False.
261 clones. The default is False.
262
262
263 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
263 :convert.hg.tagsbranch: branch name for tag revisions, defaults to
264 ``default``.
264 ``default``.
265
265
266 :convert.hg.usebranchnames: preserve branch names. The default is
266 :convert.hg.usebranchnames: preserve branch names. The default is
267 True.
267 True.
268 """
268 """
269 return convcmd.convert(ui, src, dest, revmapfile, **opts)
269 return convcmd.convert(ui, src, dest, revmapfile, **opts)
270
270
271 def debugsvnlog(ui, **opts):
271 def debugsvnlog(ui, **opts):
272 return subversion.debugsvnlog(ui, **opts)
272 return subversion.debugsvnlog(ui, **opts)
273
273
274 def debugcvsps(ui, *args, **opts):
274 def debugcvsps(ui, *args, **opts):
275 '''create changeset information from CVS
275 '''create changeset information from CVS
276
276
277 This command is intended as a debugging tool for the CVS to
277 This command is intended as a debugging tool for the CVS to
278 Mercurial converter, and can be used as a direct replacement for
278 Mercurial converter, and can be used as a direct replacement for
279 cvsps.
279 cvsps.
280
280
281 Hg debugcvsps reads the CVS rlog for current directory (or any
281 Hg debugcvsps reads the CVS rlog for current directory (or any
282 named directory) in the CVS repository, and converts the log to a
282 named directory) in the CVS repository, and converts the log to a
283 series of changesets based on matching commit log entries and
283 series of changesets based on matching commit log entries and
284 dates.'''
284 dates.'''
285 return cvsps.debugcvsps(ui, *args, **opts)
285 return cvsps.debugcvsps(ui, *args, **opts)
286
286
287 commands.norepo += " convert debugsvnlog debugcvsps"
287 commands.norepo += " convert debugsvnlog debugcvsps"
288
288
289 cmdtable = {
289 cmdtable = {
290 "convert":
290 "convert":
291 (convert,
291 (convert,
292 [('', 'authors', '',
292 [('', 'authors', '',
293 _('username mapping filename (DEPRECATED, use --authormap instead)'),
293 _('username mapping filename (DEPRECATED, use --authormap instead)'),
294 _('FILE')),
294 _('FILE')),
295 ('s', 'source-type', '',
295 ('s', 'source-type', '',
296 _('source repository type'), _('TYPE')),
296 _('source repository type'), _('TYPE')),
297 ('d', 'dest-type', '',
297 ('d', 'dest-type', '',
298 _('destination repository type'), _('TYPE')),
298 _('destination repository type'), _('TYPE')),
299 ('r', 'rev', '',
299 ('r', 'rev', '',
300 _('import up to target revision REV'), _('REV')),
300 _('import up to target revision REV'), _('REV')),
301 ('A', 'authormap', '',
301 ('A', 'authormap', '',
302 _('remap usernames using this file'), _('FILE')),
302 _('remap usernames using this file'), _('FILE')),
303 ('', 'filemap', '',
303 ('', 'filemap', '',
304 _('remap file names using contents of file'), _('FILE')),
304 _('remap file names using contents of file'), _('FILE')),
305 ('', 'splicemap', '',
305 ('', 'splicemap', '',
306 _('splice synthesized history into place'), _('FILE')),
306 _('splice synthesized history into place'), _('FILE')),
307 ('', 'branchmap', '',
307 ('', 'branchmap', '',
308 _('change branch names while converting'), _('FILE')),
308 _('change branch names while converting'), _('FILE')),
309 ('', 'branchsort', None, _('try to sort changesets by branches')),
309 ('', 'branchsort', None, _('try to sort changesets by branches')),
310 ('', 'datesort', None, _('try to sort changesets by date')),
310 ('', 'datesort', None, _('try to sort changesets by date')),
311 ('', 'sourcesort', None, _('preserve source changesets order'))],
311 ('', 'sourcesort', None, _('preserve source changesets order'))],
312 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')),
312 _('hg convert [OPTION]... SOURCE [DEST [REVMAP]]')),
313 "debugsvnlog":
313 "debugsvnlog":
314 (debugsvnlog,
314 (debugsvnlog,
315 [],
315 [],
316 'hg debugsvnlog'),
316 'hg debugsvnlog'),
317 "debugcvsps":
317 "debugcvsps":
318 (debugcvsps,
318 (debugcvsps,
319 [
319 [
320 # Main options shared with cvsps-2.1
320 # Main options shared with cvsps-2.1
321 ('b', 'branches', [], _('only return changes on specified branches')),
321 ('b', 'branches', [], _('only return changes on specified branches')),
322 ('p', 'prefix', '', _('prefix to remove from file names')),
322 ('p', 'prefix', '', _('prefix to remove from file names')),
323 ('r', 'revisions', [],
323 ('r', 'revisions', [],
324 _('only return changes after or between specified tags')),
324 _('only return changes after or between specified tags')),
325 ('u', 'update-cache', None, _("update cvs log cache")),
325 ('u', 'update-cache', None, _("update cvs log cache")),
326 ('x', 'new-cache', None, _("create new cvs log cache")),
326 ('x', 'new-cache', None, _("create new cvs log cache")),
327 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
327 ('z', 'fuzz', 60, _('set commit time fuzz in seconds')),
328 ('', 'root', '', _('specify cvsroot')),
328 ('', 'root', '', _('specify cvsroot')),
329 # Options specific to builtin cvsps
329 # Options specific to builtin cvsps
330 ('', 'parents', '', _('show parent changesets')),
330 ('', 'parents', '', _('show parent changesets')),
331 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
331 ('', 'ancestors', '', _('show current changeset in ancestor branches')),
332 # Options that are ignored for compatibility with cvsps-2.1
332 # Options that are ignored for compatibility with cvsps-2.1
333 ('A', 'cvs-direct', None, _('ignored for compatibility')),
333 ('A', 'cvs-direct', None, _('ignored for compatibility')),
334 ],
334 ],
335 _('hg debugcvsps [OPTION]... [PATH]...')),
335 _('hg debugcvsps [OPTION]... [PATH]...')),
336 }
336 }
337
338 def kwconverted(ctx, name):
339 rev = ctx.extra().get('convert_revision', '')
340 if rev.startswith('svn:'):
341 if name == 'svnrev':
342 return str(subversion.revsplit(rev)[2])
343 elif name == 'svnpath':
344 return subversion.revsplit(rev)[1]
345 elif name == 'svnuuid':
346 return subversion.revsplit(rev)[0]
347 return rev
348
349 def kwsvnrev(repo, ctx, **args):
350 """:svnrev: String. Converted subversion revision number."""
351 return kwconverted(ctx, 'svnrev')
352
353 def kwsvnpath(repo, ctx, **args):
354 """:svnpath: String. Converted subversion revision project path."""
355 return kwconverted(ctx, 'svnpath')
356
357 def kwsvnuuid(repo, ctx, **args):
358 """:svnuuid: String. Converted subversion revision repository identifier."""
359 return kwconverted(ctx, 'svnuuid')
360
361 def extsetup(ui):
362 templatekw.keywords['svnrev'] = kwsvnrev
363 templatekw.keywords['svnpath'] = kwsvnpath
364 templatekw.keywords['svnuuid'] = kwsvnuuid
@@ -1,86 +1,101 b''
1
1
2 $ "$TESTDIR/hghave" svn svn-bindings || exit 80
2 $ "$TESTDIR/hghave" svn svn-bindings || exit 80
3
3
4 $ cat >> $HGRCPATH <<EOF
4 $ cat >> $HGRCPATH <<EOF
5 > [extensions]
5 > [extensions]
6 > convert =
6 > convert =
7 > graphlog =
7 > graphlog =
8 > EOF
8 > EOF
9
9
10 $ svnadmin create svn-repo
10 $ svnadmin create svn-repo
11 $ svnadmin load -q svn-repo < "$TESTDIR/svn/branches.svndump"
11 $ svnadmin load -q svn-repo < "$TESTDIR/svn/branches.svndump"
12
12
13 Convert trunk and branches
13 Convert trunk and branches
14
14
15 $ cat > branchmap <<EOF
15 $ cat > branchmap <<EOF
16 > old3 newbranch
16 > old3 newbranch
17 > EOF
17 > EOF
18 $ hg convert --branchmap=branchmap --datesort -r 10 svn-repo A-hg
18 $ hg convert --branchmap=branchmap --datesort -r 10 svn-repo A-hg
19 initializing destination A-hg repository
19 initializing destination A-hg repository
20 scanning source...
20 scanning source...
21 sorting...
21 sorting...
22 converting...
22 converting...
23 10 init projA
23 10 init projA
24 9 hello
24 9 hello
25 8 branch trunk, remove c and dir
25 8 branch trunk, remove c and dir
26 7 change a
26 7 change a
27 6 change b
27 6 change b
28 5 move and update c
28 5 move and update c
29 4 move and update c
29 4 move and update c
30 3 change b again
30 3 change b again
31 2 move to old2
31 2 move to old2
32 1 move back to old
32 1 move back to old
33 0 last change to a
33 0 last change to a
34
34
35 Test template keywords
36
37 $ hg -R A-hg log --template '{rev} {svnuuid}{svnpath}@{svnrev}\n'
38 10 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@10
39 9 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@9
40 8 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old2@8
41 7 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@7
42 6 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@6
43 5 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@6
44 4 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@5
45 3 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@4
46 2 644ede6c-2b81-4367-9dc8-d786514f2cde/branches/old@3
47 1 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@2
48 0 644ede6c-2b81-4367-9dc8-d786514f2cde/trunk@1
49
35 Convert again
50 Convert again
36
51
37 $ hg convert --branchmap=branchmap --datesort svn-repo A-hg
52 $ hg convert --branchmap=branchmap --datesort svn-repo A-hg
38 scanning source...
53 scanning source...
39 sorting...
54 sorting...
40 converting...
55 converting...
41 0 branch trunk@1 into old3
56 0 branch trunk@1 into old3
42
57
43 $ cd A-hg
58 $ cd A-hg
44 $ hg glog --template 'branch={branches} {rev} {desc|firstline} files: {files}\n'
59 $ hg glog --template 'branch={branches} {rev} {desc|firstline} files: {files}\n'
45 o branch=newbranch 11 branch trunk@1 into old3 files:
60 o branch=newbranch 11 branch trunk@1 into old3 files:
46 |
61 |
47 | o branch= 10 last change to a files: a
62 | o branch= 10 last change to a files: a
48 | |
63 | |
49 | | o branch=old 9 move back to old files:
64 | | o branch=old 9 move back to old files:
50 | | |
65 | | |
51 | | o branch=old2 8 move to old2 files:
66 | | o branch=old2 8 move to old2 files:
52 | | |
67 | | |
53 | | o branch=old 7 change b again files: b
68 | | o branch=old 7 change b again files: b
54 | | |
69 | | |
55 | o | branch= 6 move and update c files: b
70 | o | branch= 6 move and update c files: b
56 | | |
71 | | |
57 | | o branch=old 5 move and update c files: c
72 | | o branch=old 5 move and update c files: c
58 | | |
73 | | |
59 | | o branch=old 4 change b files: b
74 | | o branch=old 4 change b files: b
60 | | |
75 | | |
61 | o | branch= 3 change a files: a
76 | o | branch= 3 change a files: a
62 | | |
77 | | |
63 | | o branch=old 2 branch trunk, remove c and dir files: c
78 | | o branch=old 2 branch trunk, remove c and dir files: c
64 | |/
79 | |/
65 | o branch= 1 hello files: a b c dir/e
80 | o branch= 1 hello files: a b c dir/e
66 |/
81 |/
67 o branch= 0 init projA files:
82 o branch= 0 init projA files:
68
83
69
84
70 $ hg branches
85 $ hg branches
71 newbranch 11:08fca3ff8634
86 newbranch 11:08fca3ff8634
72 default 10:098988aa63ba
87 default 10:098988aa63ba
73 old 9:b308f345079b
88 old 9:b308f345079b
74 old2 8:49f2336c7b8b (inactive)
89 old2 8:49f2336c7b8b (inactive)
75 $ hg tags -q
90 $ hg tags -q
76 tip
91 tip
77 $ cd ..
92 $ cd ..
78
93
79 Test hg failing to call itself
94 Test hg failing to call itself
80
95
81 $ HG=foobar hg convert svn-repo B-hg
96 $ HG=foobar hg convert svn-repo B-hg
82 * (glob)
97 * (glob)
83 initializing destination B-hg repository
98 initializing destination B-hg repository
84 abort: Mercurial failed to run itself, check hg executable is in PATH
99 abort: Mercurial failed to run itself, check hg executable is in PATH
85 [255]
100 [255]
86
101
General Comments 0
You need to be logged in to leave comments. Login now