comparison mercurial/hg.py @ 22837:2be7d5ebd4d0

config: use the same hgrc for a cloned repo as for an uninitted repo This just copies the same local sample hgrc, except it sets the default path to the repo it was cloned from. This is cut-and-paste from the local sample hgrc, but I think it's acceptable, since the two pieces of code are right next to each other and they're small. There is danger of them going out of synch, but it would complicate the code too much to get rid of this C&P. I also add ui as an import to hg.py, but with demandimport, this should not be a noticeable performance hit.
author Jordi Guti?rrez Hermoso <jordigh@octave.org>
date Mon, 06 Oct 2014 16:35:02 -0400
parents d7b114493315
children e53f6b72a0e4
comparison
equal deleted inserted replaced
22836:5a831e4e6d7a 22837:2be7d5ebd4d0
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 from i18n import _ 9 from i18n import _
10 from lock import release 10 from lock import release
11 from node import nullid 11 from node import nullid
12
12 import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo 13 import localrepo, bundlerepo, unionrepo, httppeer, sshpeer, statichttprepo
13 import bookmarks, lock, util, extensions, error, node, scmutil, phases, url 14 import bookmarks, lock, util, extensions, error, node, scmutil, phases, url
14 import cmdutil, discovery, repoview, exchange 15 import cmdutil, discovery, repoview, exchange
16 import ui as uimod
15 import merge as mergemod 17 import merge as mergemod
16 import verify as verifymod 18 import verify as verifymod
17 import errno, os, shutil 19 import errno, os, shutil
18 20
19 def _local(path): 21 def _local(path):
427 429
428 cleandir = None 430 cleandir = None
429 431
430 destrepo = destpeer.local() 432 destrepo = destpeer.local()
431 if destrepo: 433 if destrepo:
432 template = ( 434 template = uimod.samplehgrcs['cloned']
433 '# You may want to set your username here if it is not set\n'
434 "# globally, or this repository requires a different\n"
435 '# username from your usual configuration. If you want to\n'
436 '# set something for all of your repositories on this\n'
437 '# computer, try running the command\n'
438 "# 'hg config --edit --global'\n"
439 '# [ui]\n'
440 '# username = Jane Doe <jdoe@example.com>\n'
441 '[paths]\n'
442 'default = %s\n'
443 )
444 fp = destrepo.opener("hgrc", "w", text=True) 435 fp = destrepo.opener("hgrc", "w", text=True)
445 u = util.url(abspath) 436 u = util.url(abspath)
446 u.passwd = None 437 u.passwd = None
447 defaulturl = str(u) 438 defaulturl = str(u)
448 fp.write(template % defaulturl) 439 fp.write(template % defaulturl)