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