##// END OF EJS Templates
Add some more smart when initializing destination repository
Edouard Gomez -
r4521:d634b61e default
parent child Browse files
Show More
@@ -6,7 +6,7 b''
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
@@ -701,9 +701,28 b' def _convert(ui, src, dest=None, mapfile'
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)
General Comments 0
You need to be logged in to leave comments. Login now