36 return c.putcommit and c(ui, path) |
36 return c.putcommit and c(ui, path) |
37 except (AttributeError, NoRepo): |
37 except (AttributeError, NoRepo): |
38 pass |
38 pass |
39 raise util.Abort('%s: unknown repository type' % path) |
39 raise util.Abort('%s: unknown repository type' % path) |
40 |
40 |
41 class convert(object): |
41 class converter(object): |
42 def __init__(self, ui, source, dest, revmapfile, filemapper, opts): |
42 def __init__(self, ui, source, dest, revmapfile, filemapper, opts): |
43 |
43 |
44 self.source = source |
44 self.source = source |
45 self.dest = dest |
45 self.dest = dest |
46 self.ui = ui |
46 self.ui = ui |
361 return name |
361 return name |
362 |
362 |
363 def active(self): |
363 def active(self): |
364 return bool(self.include or self.exclude or self.rename) |
364 return bool(self.include or self.exclude or self.rename) |
365 |
365 |
366 def _convert(ui, src, dest=None, revmapfile=None, **opts): |
366 def convert(ui, src, dest=None, revmapfile=None, **opts): |
367 """Convert a foreign SCM repository to a Mercurial one. |
367 """Convert a foreign SCM repository to a Mercurial one. |
368 |
368 |
369 Accepted source formats: |
369 Accepted source formats: |
370 - GIT |
370 - GIT |
371 - CVS |
371 - CVS |
460 revmapfile = destc.revmapfile() |
460 revmapfile = destc.revmapfile() |
461 except: |
461 except: |
462 revmapfile = os.path.join(destc, "map") |
462 revmapfile = os.path.join(destc, "map") |
463 |
463 |
464 |
464 |
465 c = convert(ui, srcc, destc, revmapfile, filemapper(ui, opts['filemap']), |
465 c = converter(ui, srcc, destc, revmapfile, filemapper(ui, opts['filemap']), |
466 opts) |
466 opts) |
467 c.convert() |
467 c.convert() |
468 |
468 |
469 |
469 |
470 cmdtable = { |
470 cmdtable = { |
471 "convert": |
471 "convert": |
472 (_convert, |
472 (convert, |
473 [('A', 'authors', '', 'username mapping filename'), |
473 [('A', 'authors', '', 'username mapping filename'), |
474 ('', 'filemap', '', 'remap file names using contents of file'), |
474 ('', 'filemap', '', 'remap file names using contents of file'), |
475 ('r', 'rev', '', 'import up to target revision REV'), |
475 ('r', 'rev', '', 'import up to target revision REV'), |
476 ('', 'datesort', None, 'try to sort changesets by date')], |
476 ('', 'datesort', None, 'try to sort changesets by date')], |
477 'hg convert [OPTION]... SOURCE [DEST [MAPFILE]]'), |
477 'hg convert [OPTION]... SOURCE [DEST [MAPFILE]]'), |