comparison hgext/convert/__init__.py @ 4753:07efcce17d28

convert: add -r argument specifying latest revision to convert
author Brendan Cully <brendan@kublai.com>
date Sun, 01 Jul 2007 15:02:15 -0700
parents 1069205a8894
children 7c8cd400e86a
comparison
equal deleted inserted replaced
4752:20ec5cc02f18 4753:07efcce17d28
15 15
16 commands.norepo += " convert" 16 commands.norepo += " convert"
17 17
18 converters = [convert_cvs, convert_git, convert_mercurial] 18 converters = [convert_cvs, convert_git, convert_mercurial]
19 19
20 def converter(ui, path): 20 def converter(ui, path, rev=None):
21 if not os.path.isdir(path): 21 if not os.path.isdir(path):
22 raise util.Abort("%s: not a directory" % path) 22 raise util.Abort("%s: not a directory" % path)
23 for c in converters: 23 for c in converters:
24 try: 24 try:
25 return c(ui, path) 25 if rev:
26 return c(ui, path, rev=rev)
27 else:
28 return c(ui, path)
26 except NoRepo: 29 except NoRepo:
27 pass 30 pass
28 raise util.Abort("%s: unknown repository type" % path) 31 raise util.Abort("%s: unknown repository type" % path)
29 32
30 class convert(object): 33 class convert(object):
246 - CVS 249 - CVS
247 250
248 Accepted destination formats: 251 Accepted destination formats:
249 - Mercurial 252 - Mercurial
250 253
254 If no revision is given, all revisions will be converted. Otherwise,
255 convert will only import up to the named revision (given in a format
256 understood by the source).
257
251 If destination isn't given, a new Mercurial repo named <src>-hg will 258 If destination isn't given, a new Mercurial repo named <src>-hg will
252 be created. If <mapfile> isn't given, it will be put in a default 259 be created. If <mapfile> isn't given, it will be put in a default
253 location (<dest>/.hg/shamap by default) 260 location (<dest>/.hg/shamap by default)
254 261
255 The <mapfile> is a simple text file that maps each source commit ID to 262 The <mapfile> is a simple text file that maps each source commit ID to
265 that use unix logins to identify authors (eg: CVS). One line per author 272 that use unix logins to identify authors (eg: CVS). One line per author
266 mapping and the line format is: 273 mapping and the line format is:
267 srcauthor=whatever string you want 274 srcauthor=whatever string you want
268 ''' 275 '''
269 276
270 srcc = converter(ui, src) 277 srcc = converter(ui, src, rev=opts.get('rev'))
271 if not hasattr(srcc, "getcommit"): 278 if not hasattr(srcc, "getcommit"):
272 raise util.Abort("%s: can't read from this repo type" % src) 279 raise util.Abort("%s: can't read from this repo type" % src)
273 280
274 if not dest: 281 if not dest:
275 dest = src + "-hg" 282 dest = src + "-hg"
311 318
312 cmdtable = { 319 cmdtable = {
313 "convert": 320 "convert":
314 (_convert, 321 (_convert,
315 [('A', 'authors', '', 'username mapping filename'), 322 [('A', 'authors', '', 'username mapping filename'),
323 ('r', 'rev', '', 'import up to target revision REV'),
316 ('', 'datesort', None, 'try to sort changesets by date')], 324 ('', 'datesort', None, 'try to sort changesets by date')],
317 'hg convert [OPTION]... SOURCE [DEST [MAPFILE]]'), 325 'hg convert [OPTION]... SOURCE [DEST [MAPFILE]]'),
318 } 326 }