##// END OF EJS Templates
ui: remove urllib2 from being imported early...
Kyle Lippincott -
r30945:8b83b626 default
parent child Browse files
Show More
@@ -94,6 +94,24 b' default = %s'
94 # pager =""",
94 # pager =""",
95 }
95 }
96
96
97
98 class httppasswordmgrdbproxy(object):
99 """Delays loading urllib2 until it's needed."""
100 def __init__(self):
101 self._mgr = None
102
103 def _get_mgr(self):
104 if self._mgr is None:
105 self._mgr = urlreq.httppasswordmgrwithdefaultrealm()
106 return self._mgr
107
108 def add_password(self, *args, **kwargs):
109 return self._get_mgr().add_password(*args, **kwargs)
110
111 def find_user_password(self, *args, **kwargs):
112 return self._get_mgr().find_user_password(*args, **kwargs)
113
114
97 class ui(object):
115 class ui(object):
98 def __init__(self, src=None):
116 def __init__(self, src=None):
99 """Create a fresh new ui object if no src given
117 """Create a fresh new ui object if no src given
@@ -145,7 +163,7 b' class ui(object):'
145 # shared read-only environment
163 # shared read-only environment
146 self.environ = encoding.environ
164 self.environ = encoding.environ
147
165
148 self.httppasswordmgrdb = urlreq.httppasswordmgrwithdefaultrealm()
166 self.httppasswordmgrdb = httppasswordmgrdbproxy()
149
167
150 allowed = self.configlist('experimental', 'exportableenviron')
168 allowed = self.configlist('experimental', 'exportableenviron')
151 if '*' in allowed:
169 if '*' in allowed:
@@ -172,7 +190,7 b' class ui(object):'
172 """Clear internal state that shouldn't persist across commands"""
190 """Clear internal state that shouldn't persist across commands"""
173 if self._progbar:
191 if self._progbar:
174 self._progbar.resetstate() # reset last-print time of progress bar
192 self._progbar.resetstate() # reset last-print time of progress bar
175 self.httppasswordmgrdb = urlreq.httppasswordmgrwithdefaultrealm()
193 self.httppasswordmgrdb = httppasswordmgrdbproxy()
176
194
177 def formatter(self, topic, opts):
195 def formatter(self, topic, opts):
178 return formatter.formatter(self, topic, opts)
196 return formatter.formatter(self, topic, opts)
General Comments 0
You need to be logged in to leave comments. Login now