comparison mercurial/util.py @ 7270:2db33c1a5654

factor out the url handling from httprepo Create url.py to handle all the url handling: - proxy handling - workaround various python bugs - handle username/password embedded in the url
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 27 Oct 2008 21:50:01 +0100
parents 5d14b06b1cc1
children 00d76fa3ffba
comparison
equal deleted inserted replaced
7269:95a53961d7a6 7270:2db33c1a5654
13 """ 13 """
14 14
15 from i18n import _ 15 from i18n import _
16 import cStringIO, errno, getpass, re, shutil, sys, tempfile 16 import cStringIO, errno, getpass, re, shutil, sys, tempfile
17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil 17 import os, stat, threading, time, calendar, ConfigParser, locale, glob, osutil
18 import imp, urlparse 18 import imp
19 19
20 # Python compatibility 20 # Python compatibility
21 21
22 try: 22 try:
23 set = set 23 set = set
1930 return path 1930 return path
1931 1931
1932 def uirepr(s): 1932 def uirepr(s):
1933 # Avoid double backslash in Windows path repr() 1933 # Avoid double backslash in Windows path repr()
1934 return repr(s).replace('\\\\', '\\') 1934 return repr(s).replace('\\\\', '\\')
1935
1936 def hidepassword(url):
1937 '''hide user credential in a url string'''
1938 scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
1939 netloc = re.sub('([^:]*):([^@]*)@(.*)', r'\1:***@\3', netloc)
1940 return urlparse.urlunparse((scheme, netloc, path, params, query, fragment))
1941
1942 def removeauth(url):
1943 '''remove all authentication information from a url string'''
1944 scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)
1945 netloc = netloc[netloc.find('@')+1:]
1946 return urlparse.urlunparse((scheme, netloc, path, params, query, fragment))