changeset 5146:7106f4899aa0

merge with crew-stable
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 07 Aug 2007 15:57:23 +0200
parents 0751c25ea0c0 (current diff) dc2e512cb89a (diff)
children c80af96943aa
files hgext/convert/cvs.py
diffstat 1 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/cvs.py	Tue Aug 07 12:24:25 2007 +0200
+++ b/hgext/convert/cvs.py	Tue Aug 07 15:57:23 2007 +0200
@@ -124,23 +124,27 @@
                 user, passw, serv, port, root = m.groups()
                 if not user:
                     user = "anonymous"
-                rr = ":pserver:" + user + "@" + serv + ":" +  root
-                if port:
-                    rr2, port = "-", int(port)
+                if not port:
+                    port = 2401
                 else:
-                    rr2, port = rr, 2401
-                rr += str(port)
+                    port = int(port)
+                format0 = ":pserver:%s@%s:%s" % (user, serv, root)
+                format1 = ":pserver:%s@%s:%d%s" % (user, serv, port, root)
 
                 if not passw:
                     passw = "A"
                     pf = open(os.path.join(os.environ["HOME"], ".cvspass"))
-                    for l in pf:
-                        # :pserver:cvs@mea.tmt.tele.fi:/cvsroot/zmailer Ah<Z
-                        m = re.match(r'(/\d+\s+/)?(.*)', l)
-                        l = m.group(2)
-                        w, p = l.split(' ', 1)
-                        if w in [rr, rr2]:
-                            passw = p
+                    for line in pf.read().splitlines():
+                        part1, part2 = line.split(' ', 1)
+                        if part1 == '/1':
+                            # /1 :pserver:user@example.com:2401/cvsroot/foo Ah<Z
+                            part1, part2 = part2.split(' ', 1)
+                            format = format1
+                        else:
+                            # :pserver:user@example.com:/cvsroot/foo Ah<Z
+                            format = format0
+                        if part1 == format:
+                            passw = part2
                             break
                     pf.close()