##// END OF EJS Templates
clone: don't save user's password in .hg/hgrc (Issue3122)
Augie Fackler -
r15552:62c9183a stable
parent child Browse files
Show More
@@ -356,10 +356,13 b' def clone(ui, peeropts, source, dest=Non'
356 if destrepo.local():
356 if destrepo.local():
357 fp = destrepo.opener("hgrc", "w", text=True)
357 fp = destrepo.opener("hgrc", "w", text=True)
358 fp.write("[paths]\n")
358 fp.write("[paths]\n")
359 fp.write("default = %s\n" % abspath)
359 u = util.url(abspath)
360 u.passwd = None
361 defaulturl = str(u)
362 fp.write("default = %s\n" % defaulturl)
360 fp.close()
363 fp.close()
361
364
362 destrepo.ui.setconfig('paths', 'default', abspath)
365 destrepo.ui.setconfig('paths', 'default', defaulturl)
363
366
364 if update:
367 if update:
365 if update is not True:
368 if update is not True:
@@ -12,13 +12,30 b''
12 $ echo a >> a
12 $ echo a >> a
13 $ hg ci -mb
13 $ hg ci -mb
14
14
15 Cloning with a password in the URL should not save the password in .hg/hgrc:
16
17 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
18 $ cat hg.pid >> $DAEMON_PIDS
19 $ hg clone http://foo:xyzzy@localhost:$HGPORT/ test3
20 requesting all changes
21 adding changesets
22 adding manifests
23 adding file changes
24 added 2 changesets with 2 changes to 1 files
25 updating to branch default
26 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
27 $ cat test3/.hg/hgrc
28 [paths]
29 default = http://foo@localhost:$HGPORT/
30 $ "$TESTDIR/killdaemons.py"
31
15 expect error, cloning not allowed
32 expect error, cloning not allowed
16
33
17 $ echo '[web]' > .hg/hgrc
34 $ echo '[web]' > .hg/hgrc
18 $ echo 'allowpull = false' >> .hg/hgrc
35 $ echo 'allowpull = false' >> .hg/hgrc
19 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
36 $ hg serve -p $HGPORT -d --pid-file=hg.pid -E errors.log
20 $ cat hg.pid >> $DAEMON_PIDS
37 $ cat hg.pid >> $DAEMON_PIDS
21 $ hg clone http://localhost:$HGPORT/ test3
38 $ hg clone http://localhost:$HGPORT/ test4
22 requesting all changes
39 requesting all changes
23 abort: authorization failed
40 abort: authorization failed
24 [255]
41 [255]
@@ -43,7 +43,7 b''
43 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo
43 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo
44
44
45 $ hg pull
45 $ hg pull
46 pulling from http://foo:***@localhost:$HGPORT/
46 pulling from http://foo@localhost:$HGPORT/
47 searching for changes
47 searching for changes
48 no changes found
48 no changes found
49
49
General Comments 0
You need to be logged in to leave comments. Login now