diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -587,8 +587,8 @@ def clone(ui, source, dest=None, **opts) repo = hg.repository(ui, dest, create=1) repo.pull(other) - f = repo.opener("hgrc", "w") - f.write("[paths]\n") + f = repo.opener("hgrc", "a") + f.write("\n[paths]\n") f.write("default = %s\n" % abspath) if not opts['noupdate']: diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -27,11 +27,6 @@ class localrepository: self.root = os.path.abspath(path) self.ui = ui - - if create: - os.mkdir(self.path) - os.mkdir(self.join("data")) - self.opener = util.opener(self.path) self.wopener = util.opener(self.root) self.manifest = manifest.manifest(self.opener) @@ -39,6 +34,13 @@ class localrepository: self.tagscache = None self.nodetagscache = None + if create: + os.mkdir(self.path) + os.mkdir(self.join("data")) + f = self.opener("hgrc", "w") + f.write("[web]\n") + f.write("contact = %s\n" % ui.shortuser(ui.username())) + self.dirstate = dirstate.dirstate(self.opener, ui, self.root) try: self.ui.readconfig(self.opener("hgrc"))