##// END OF EJS Templates
Do not display passwords with pull/push/incoming/outgoing...
Manuel Holtgrewe -
r5525:dcbda0c4 default
parent child Browse files
Show More
@@ -1652,7 +1652,7 b' def incoming(ui, repo, source="default",'
1652 1652 cmdutil.setremoteconfig(ui, opts)
1653 1653
1654 1654 other = hg.repository(ui, source)
1655 ui.status(_('comparing with %s\n') % source)
1655 ui.status(_('comparing with %s\n') % util.hidepassword(source))
1656 1656 if revs:
1657 1657 revs = [other.lookup(rev) for rev in revs]
1658 1658 incoming = repo.findincoming(other, heads=revs, force=opts["force"])
@@ -1962,7 +1962,7 b' def outgoing(ui, repo, dest=None, **opts'
1962 1962 revs = [repo.lookup(rev) for rev in revs]
1963 1963
1964 1964 other = hg.repository(ui, dest)
1965 ui.status(_('comparing with %s\n') % dest)
1965 ui.status(_('comparing with %s\n') % util.hidepassword(dest))
1966 1966 o = repo.findoutgoing(other, force=opts['force'])
1967 1967 if not o:
1968 1968 ui.status(_("no changes found\n"))
@@ -2095,7 +2095,7 b' def pull(ui, repo, source="default", **o'
2095 2095 cmdutil.setremoteconfig(ui, opts)
2096 2096
2097 2097 other = hg.repository(ui, source)
2098 ui.status(_('pulling from %s\n') % (source))
2098 ui.status(_('pulling from %s\n') % util.hidepassword(source))
2099 2099 if revs:
2100 2100 try:
2101 2101 revs = [other.lookup(rev) for rev in revs]
@@ -2142,7 +2142,7 b' def push(ui, repo, dest=None, **opts):'
2142 2142 cmdutil.setremoteconfig(ui, opts)
2143 2143
2144 2144 other = hg.repository(ui, dest)
2145 ui.status('pushing to %s\n' % (dest))
2145 ui.status('pushing to %s\n' % util.hidepassword(dest))
2146 2146 if revs:
2147 2147 revs = [repo.lookup(rev) for rev in revs]
2148 2148 r = repo.push(other, opts['force'], revs=revs)
@@ -15,6 +15,7 b' platform-specific details from the core.'
15 15 from i18n import _
16 16 import cStringIO, errno, getpass, popen2, re, shutil, sys, tempfile, strutil
17 17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil
18 import re, urlparse
18 19
19 20 try:
20 21 set = set
@@ -1698,3 +1699,33 b' def drop_scheme(scheme, path):'
1698 1699 def uirepr(s):
1699 1700 # Avoid double backslash in Windows path repr()
1700 1701 return repr(s).replace('\\\\', '\\')
1702
1703 def hidepassword(url):
1704 '''replaces the password in the url string by three asterisks (***)
1705
1706 >>> hidepassword('http://www.example.com/some/path#fragment')
1707 'http://www.example.com/some/path#fragment'
1708 >>> hidepassword('http://me@www.example.com/some/path#fragment')
1709 'http://me@www.example.com/some/path#fragment'
1710 >>> hidepassword('http://me:simplepw@www.example.com/path#frag')
1711 'http://me:***@www.example.com/path#frag'
1712 >>> hidepassword('http://me:complex:pw@www.example.com/path#frag')
1713 'http://me:***@www.example.com/path#frag'
1714 >>> hidepassword('/path/to/repo')
1715 '/path/to/repo'
1716 >>> hidepassword('relative/path/to/repo')
1717 'relative/path/to/repo'
1718 >>> hidepassword('c:\\\\path\\\\to\\\\repo')
1719 'c:\\\\path\\\\to\\\\repo'
1720 >>> hidepassword('c:/path/to/repo')
1721 'c:/path/to/repo'
1722 >>> hidepassword('bundle://path/to/bundle')
1723 'bundle://path/to/bundle'
1724 '''
1725 url_parts = list(urlparse.urlparse(url))
1726 host_with_pw_pattern = re.compile('^([^:]*):([^@]*)@(.*)$')
1727 if host_with_pw_pattern.match(url_parts[1]):
1728 url_parts[1] = re.sub(host_with_pw_pattern, r'\1:***@\3',
1729 url_parts[1])
1730 return urlparse.urlunparse(url_parts)
1731
@@ -7,3 +7,6 b' doctest.testmod(mercurial.changelog)'
7 7
8 8 import mercurial.httprepo
9 9 doctest.testmod(mercurial.httprepo)
10
11 import mercurial.util
12 doctest.testmod(mercurial.util)
General Comments 0
You need to be logged in to leave comments. Login now