##// END OF EJS Templates
remove trailing whitespace
Steve Borho -
r68:ff765ca7 default
parent child Browse files
Show More
@@ -89,7 +89,7 b' class HTTPPasswordHandler(object):'
89 def __init__(self):
89 def __init__(self):
90 self.pwd_cache = {}
90 self.pwd_cache = {}
91 self.last_reply = None
91 self.last_reply = None
92
92
93 def find_auth(self, pwmgr, realm, authuri):
93 def find_auth(self, pwmgr, realm, authuri):
94 """
94 """
95 Actual implementation of find_user_password - different
95 Actual implementation of find_user_password - different
@@ -104,7 +104,7 b' class HTTPPasswordHandler(object):'
104 after_bad_auth = (self.last_reply \
104 after_bad_auth = (self.last_reply \
105 and (self.last_reply['realm'] == realm) \
105 and (self.last_reply['realm'] == realm) \
106 and (self.last_reply['authuri'] == authuri))
106 and (self.last_reply['authuri'] == authuri))
107
107
108 # Strip arguments to get actual remote repository url.
108 # Strip arguments to get actual remote repository url.
109 base_url = self.canonical_url(authuri)
109 base_url = self.canonical_url(authuri)
110
110
@@ -113,12 +113,12 b' class HTTPPasswordHandler(object):'
113 user, pwd = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
113 user, pwd = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(
114 pwmgr, realm, authuri)
114 pwmgr, realm, authuri)
115 if user and pwd:
115 if user and pwd:
116 self._debug_reply(ui, _("Auth data found in repository URL"),
116 self._debug_reply(ui, _("Auth data found in repository URL"),
117 base_url, user, pwd)
117 base_url, user, pwd)
118 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
118 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
119 return user, pwd
119 return user, pwd
120
120
121 # Loading .hg/hgrc [auth] section contents. If prefix is given,
121 # Loading .hg/hgrc [auth] section contents. If prefix is given,
122 # it will be used as a key to lookup password in the keyring.
122 # it will be used as a key to lookup password in the keyring.
123 auth_user, pwd, prefix_url = self.load_hgrc_auth(ui, base_url)
123 auth_user, pwd, prefix_url = self.load_hgrc_auth(ui, base_url)
124 if prefix_url:
124 if prefix_url:
@@ -133,7 +133,7 b' class HTTPPasswordHandler(object):'
133 cached_auth = self.pwd_cache.get(cache_key)
133 cached_auth = self.pwd_cache.get(cache_key)
134 if cached_auth:
134 if cached_auth:
135 user, pwd = cached_auth
135 user, pwd = cached_auth
136 self._debug_reply(ui, _("Cached auth data found"),
136 self._debug_reply(ui, _("Cached auth data found"),
137 base_url, user, pwd)
137 base_url, user, pwd)
138 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
138 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
139 return user, pwd
139 return user, pwd
@@ -144,25 +144,25 b' class HTTPPasswordHandler(object):'
144 user = auth_user
144 user = auth_user
145 if pwd:
145 if pwd:
146 self.pwd_cache[cache_key] = user, pwd
146 self.pwd_cache[cache_key] = user, pwd
147 self._debug_reply(ui, _("Auth data set in .hg/hgrc"),
147 self._debug_reply(ui, _("Auth data set in .hg/hgrc"),
148 base_url, user, pwd)
148 base_url, user, pwd)
149 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
149 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
150 return user, pwd
150 return user, pwd
151 else:
151 else:
152 ui.debug(_("Username found in .hg/hgrc: %s\n" % user))
152 ui.debug(_("Username found in .hg/hgrc: %s\n" % user))
153
153
154 # Loading password from keyring.
154 # Loading password from keyring.
155 # Only if username is known (so we know the key) and we are
155 # Only if username is known (so we know the key) and we are
156 # not after failure (so we don't reuse the bad password).
156 # not after failure (so we don't reuse the bad password).
157 if user and not after_bad_auth:
157 if user and not after_bad_auth:
158 pwd = password_store.get_http_password(keyring_url, user)
158 pwd = password_store.get_http_password(keyring_url, user)
159 if pwd:
159 if pwd:
160 self.pwd_cache[cache_key] = user, pwd
160 self.pwd_cache[cache_key] = user, pwd
161 self._debug_reply(ui, _("Keyring password found"),
161 self._debug_reply(ui, _("Keyring password found"),
162 base_url, user, pwd)
162 base_url, user, pwd)
163 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
163 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
164 return user, pwd
164 return user, pwd
165
165
166 # Is the username permanently set?
166 # Is the username permanently set?
167 fixed_user = (user and True or False)
167 fixed_user = (user and True or False)
168
168
@@ -172,7 +172,7 b' class HTTPPasswordHandler(object):'
172
172
173 if not fixed_user:
173 if not fixed_user:
174 ui.status(_("Username not specified in .hg/hgrc. Keyring will not be used.\n"))
174 ui.status(_("Username not specified in .hg/hgrc. Keyring will not be used.\n"))
175
175
176 ui.write(_("http authorization required\n"))
176 ui.write(_("http authorization required\n"))
177 ui.status(_("realm: %s\n") % realm)
177 ui.status(_("realm: %s\n") % realm)
178 if fixed_user:
178 if fixed_user:
@@ -192,7 +192,7 b' class HTTPPasswordHandler(object):'
192 # Saving password to the memory cache
192 # Saving password to the memory cache
193 self.pwd_cache[cache_key] = user, pwd
193 self.pwd_cache[cache_key] = user, pwd
194
194
195 self._debug_reply(ui, _("Manually entered password"),
195 self._debug_reply(ui, _("Manually entered password"),
196 base_url, user, pwd)
196 base_url, user, pwd)
197 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
197 self.last_reply = dict(realm=realm,authuri=authuri,user=user)
198 return user, pwd
198 return user, pwd
@@ -205,23 +205,23 b' class HTTPPasswordHandler(object):'
205 element can be None)
205 element can be None)
206 """
206 """
207 # Theoretically 3 lines below should do:
207 # Theoretically 3 lines below should do:
208
208
209 #auth_token = self.readauthtoken(base_url)
209 #auth_token = self.readauthtoken(base_url)
210 #if auth_token:
210 #if auth_token:
211 # user, pwd = auth.get('username'), auth.get('password')
211 # user, pwd = auth.get('username'), auth.get('password')
212
212
213 # Unfortunately they do not work, readauthtoken always return
213 # Unfortunately they do not work, readauthtoken always return
214 # None. Why? Because ui (self.ui of passwordmgr) describes the
214 # None. Why? Because ui (self.ui of passwordmgr) describes the
215 # *remote* repository, so does *not* contain any option from
215 # *remote* repository, so does *not* contain any option from
216 # local .hg/hgrc.
216 # local .hg/hgrc.
217
217
218 # TODO: mercurial 1.4.2 is claimed to resolve this problem
218 # TODO: mercurial 1.4.2 is claimed to resolve this problem
219 # (thanks to: http://hg.xavamedia.nl/mercurial/crew/rev/fb45c1e4396f)
219 # (thanks to: http://hg.xavamedia.nl/mercurial/crew/rev/fb45c1e4396f)
220 # so since this version workaround implemented below should
220 # so since this version workaround implemented below should
221 # not be necessary. As it will take some time until people
221 # not be necessary. As it will take some time until people
222 # migrate to >= 1.4.2, it would be best to implement
222 # migrate to >= 1.4.2, it would be best to implement
223 # workaround conditionally.
223 # workaround conditionally.
224
224
225 # Workaround: we recreate the repository object
225 # Workaround: we recreate the repository object
226 repo_root = ui.config("bundle", "mainreporoot")
226 repo_root = ui.config("bundle", "mainreporoot")
227
227
@@ -289,7 +289,7 b' def find_user_password(self, realm, auth'
289 def try_smtp_login(ui, smtp_obj, username, password):
289 def try_smtp_login(ui, smtp_obj, username, password):
290 """
290 """
291 Attempts smtp login on smtp_obj (smtplib.SMTP) using username and
291 Attempts smtp login on smtp_obj (smtplib.SMTP) using username and
292 password.
292 password.
293
293
294 Returns:
294 Returns:
295 - True if login succeeded
295 - True if login succeeded
@@ -340,7 +340,7 b' def keyring_supported_smtp(ui, username)'
340 s.ehlo()
340 s.ehlo()
341 s.starttls()
341 s.starttls()
342 s.ehlo()
342 s.ehlo()
343
343
344 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
344 #>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
345 stored = password = password_store.get_smtp_password(
345 stored = password = password_store.get_smtp_password(
346 mailhost, mailport, username)
346 mailhost, mailport, username)
General Comments 0
You need to be logged in to leave comments. Login now