536: Mercurial (hg) scmtools back end ignores authentication credentials

derek******@gmai***** (Google Code) (Is this you? Claim this profile.)
July 14, 2008
The hg scmtools backend doesn't use the username and password provided in
the repository admin page when accessing the server via http (or https). In
our corporate environment, read access via https is protected by
authentication credentials, so this was causing us a problem when viewing
diffs.

The attached patch enabled this to work properly in our environment using a
Debian-based server with Python 2.5.2. It also seems to work alright with
unauthenticated remote servers, though it has not been tested thoroughly.
Index: scmtools/hg.py
===================================================================
--- scmtools/hg.py	(revision 1390)
+++ scmtools/hg.py	(working copy)
@@ -8,7 +8,9 @@
     def __init__(self, repository):
         SCMTool.__init__(self, repository)
         if repository.path.startswith('http'):
-            self.client = HgWebClient(repository.path)
+            self.client = HgWebClient(repository.path,
+                                      repository.username,
+                                      repository.password)
         else:
             self.client = HgClient(repository.path)
 
@@ -73,8 +75,10 @@
 
 
 class HgWebClient:
-    def __init__(self, repoPath):
+    def __init__(self, repoPath, username, password):
         self.url = repoPath
+        self.username = username
+        self.password = password
 
     def cat_file(self, path, rev="tip"):
         if rev == HEAD:
@@ -82,7 +86,11 @@
         elif rev == PRE_CREATION:
             rev = ""
         try:
-    
chipx86
#1 chipx86
Can you put this up on http://reviews.review-board.org/ ?
#2 derek******@gmai***** (Google Code) (Is this you? Claim this profile.)
http://reviews.review-board.org/r/448/
david
#3 david
Fixed in r1401.  Thanks!
  • +Fixed