4 # |
4 # |
5 # This software may be used and distributed according to the terms |
5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. |
6 # of the GNU General Public License, incorporated herein by reference. |
7 |
7 |
8 import sys, os, zlib, sha, time, re, locale, socket |
8 import sys, os, zlib, sha, time, re, locale, socket |
9 from mercurial import hg, ui, util, commands |
9 from mercurial import hg, ui, util, commands, repo |
10 |
10 |
11 commands.norepo += " convert" |
11 commands.norepo += " convert" |
12 |
12 |
13 class NoRepo(Exception): pass |
13 class NoRepo(Exception): pass |
14 |
14 |
699 raise util.Abort("%s: can't read from this repo type\n" % src) |
699 raise util.Abort("%s: can't read from this repo type\n" % src) |
700 |
700 |
701 if not dest: |
701 if not dest: |
702 dest = src + "-hg" |
702 dest = src + "-hg" |
703 ui.status("assuming destination %s\n" % dest) |
703 ui.status("assuming destination %s\n" % dest) |
704 if not os.path.isdir(dest): |
704 |
705 ui.status("creating repository %s\n" % dest) |
705 # Try to be smart and initalize things when required |
706 os.system("hg init " + dest) |
706 if os.path.isdir(dest): |
|
707 if len(os.listdir(dest)) > 0: |
|
708 try: |
|
709 hg.repository(ui, dest) |
|
710 ui.status("destination %s is a Mercurial repository\n" % dest) |
|
711 except repo.RepoError: |
|
712 raise util.Abort( |
|
713 """destination directory %s is not empty. |
|
714 Please specify an empty directory to be initialized or an already initialized |
|
715 mercurial repository |
|
716 """ % dest) |
|
717 else: |
|
718 ui.status("initializing destination %s repository\n" % dest) |
|
719 hg.repository(ui, dest, create=True) |
|
720 elif os.path.exists(dest): |
|
721 raise util.Abort("destination %s exists and is not a directory\n" % dest) |
|
722 else: |
|
723 ui.status("initializing destination %s repository\n" % dest) |
|
724 hg.repository(ui, dest, create=True) |
|
725 |
707 destc = converter(ui, dest) |
726 destc = converter(ui, dest) |
708 if not hasattr(destc, "putcommit"): |
727 if not hasattr(destc, "putcommit"): |
709 raise util.Abort("%s: can't write to this repo type\n" % src) |
728 raise util.Abort("%s: can't write to this repo type\n" % src) |
710 |
729 |
711 if not mapfile: |
730 if not mapfile: |