Show More
@@ -10,7 +10,7 b' from cvs import convert_cvs' | |||||
10 | from git import convert_git |
|
10 | from git import convert_git | |
11 | from hg import convert_mercurial |
|
11 | from hg import convert_mercurial | |
12 |
|
12 | |||
13 | import os |
|
13 | import os, shutil | |
14 | from mercurial import hg, ui, util, commands |
|
14 | from mercurial import hg, ui, util, commands | |
15 |
|
15 | |||
16 | commands.norepo += " convert" |
|
16 | commands.norepo += " convert" | |
@@ -274,15 +274,12 b' def _convert(ui, src, dest=None, mapfile' | |||||
274 | srcauthor=whatever string you want |
|
274 | srcauthor=whatever string you want | |
275 | ''' |
|
275 | ''' | |
276 |
|
276 | |||
277 | srcc = converter(ui, src, rev=opts.get('rev')) |
|
|||
278 | if not hasattr(srcc, "getcommit"): |
|
|||
279 | raise util.Abort("%s: can't read from this repo type" % src) |
|
|||
280 |
|
||||
281 | if not dest: |
|
277 | if not dest: | |
282 | dest = src + "-hg" |
|
278 | dest = src + "-hg" | |
283 | ui.status("assuming destination %s\n" % dest) |
|
279 | ui.status("assuming destination %s\n" % dest) | |
284 |
|
280 | |||
285 | # Try to be smart and initalize things when required |
|
281 | # Try to be smart and initalize things when required | |
|
282 | created = False | |||
286 | if os.path.isdir(dest): |
|
283 | if os.path.isdir(dest): | |
287 | if len(os.listdir(dest)) > 0: |
|
284 | if len(os.listdir(dest)) > 0: | |
288 | try: |
|
285 | try: | |
@@ -297,16 +294,27 b' def _convert(ui, src, dest=None, mapfile' | |||||
297 | else: |
|
294 | else: | |
298 | ui.status("initializing destination %s repository\n" % dest) |
|
295 | ui.status("initializing destination %s repository\n" % dest) | |
299 | hg.repository(ui, dest, create=True) |
|
296 | hg.repository(ui, dest, create=True) | |
|
297 | created = True | |||
300 | elif os.path.exists(dest): |
|
298 | elif os.path.exists(dest): | |
301 | raise util.Abort("destination %s exists and is not a directory" % dest) |
|
299 | raise util.Abort("destination %s exists and is not a directory" % dest) | |
302 | else: |
|
300 | else: | |
303 | ui.status("initializing destination %s repository\n" % dest) |
|
301 | ui.status("initializing destination %s repository\n" % dest) | |
304 | hg.repository(ui, dest, create=True) |
|
302 | hg.repository(ui, dest, create=True) | |
|
303 | created = True | |||
305 |
|
304 | |||
306 | destc = converter(ui, dest) |
|
305 | destc = converter(ui, dest) | |
307 | if not hasattr(destc, "putcommit"): |
|
306 | if not hasattr(destc, "putcommit"): | |
308 | raise util.Abort("%s: can't write to this repo type" % src) |
|
307 | raise util.Abort("%s: can't write to this repo type" % src) | |
309 |
|
308 | |||
|
309 | try: | |||
|
310 | srcc = converter(ui, src, rev=opts.get('rev')) | |||
|
311 | if not hasattr(srcc, "getcommit"): | |||
|
312 | raise util.Abort("%s: can't read from this repo type" % src) | |||
|
313 | except Exception: | |||
|
314 | if created: | |||
|
315 | shutil.rmtree(dest, True) | |||
|
316 | raise | |||
|
317 | ||||
310 | if not mapfile: |
|
318 | if not mapfile: | |
311 | try: |
|
319 | try: | |
312 | mapfile = destc.mapfile() |
|
320 | mapfile = destc.mapfile() |
General Comments 0
You need to be logged in to leave comments.
Login now