FW: Mercurial patch for CVS import

Thomas Arendsen Hein thomas at intevation.de
Tue Aug 7 08:59:42 CDT 2007


* Ralf Leibold <Ralf.Leibold at nuance.com> [20070730 18:00]:
> I found a bug importing from CVS. The $HOME/.cvspass-file has a second
> format which is 
> /1 :pserver:<user>@<host>:<port><CVSROOT-dir> <password>

I pushed a different implementation to crew-stable and crew:

# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Date 1186494986 -7200
# Node ID dc2e512cb89a94bee1da6b61aacf14d9e1abca49
# Parent  ea7b982b6c0834921aa22388a34a6d8e7a2cb60c
CVS import: Support new-style .cvspass-file format.

Based on an email from Ralf.Leibold at nuance dot com

diff -r ea7b982b6c08 -r dc2e512cb89a hgext/convert/cvs.py
--- a/hgext/convert/cvs.py	Tue Aug 07 10:24:33 2007 +0200
+++ b/hgext/convert/cvs.py	Tue Aug 07 15:56:26 2007 +0200
@@ -107,23 +107,27 @@ class convert_cvs(converter_source):
                 user, passw, serv, port, root = m.groups()
                 if not user:
                     user = "anonymous"
-                rr = ":pserver:" + user + "@" + serv + ":" +  root
-                if port:
-                    rr2, port = "-", int(port)
-                else:
-                    rr2, port = rr, 2401
-                rr += str(port)
+                if not port:
+                    port = 2401
+                else:
+                    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 at 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 at example.com:2401/cvsroot/foo Ah<Z
+                            part1, part2 = part2.split(' ', 1)
+                            format = format1
+                        else:
+                            # :pserver:user at example.com:/cvsroot/foo Ah<Z
+                            format = format0
+                        if part1 == format:
+                            passw = part2
                             break
                     pf.close()
 

-- 
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrueck - Register: Amtsgericht Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner


More information about the Mercurial-devel mailing list