[PATCH] cvs conversion now properly parse cvsroot

Hrvoje Kozak hrvoje1212 at gmail.com
Fri May 3 13:14:58 CDT 2013


# HG changeset patch
# User Blesso hrvoje1212 at gmail.com
# Date 1367602499 -7200
# Branch stable
# Node ID 2fb5c25951f23acfc22b7aa1054ed0089afea19e
# Parent  762208a3edabc483936fff7ef4c8e02b25a8fba0
convert: fix bug of wrong CVS path parsing without port number (issue3678)

The cvsps.py:getrepopath suffers from a string parsing bug (it returns
"user at server/path/to/repository" if the CVSROOT is given like this:
":pserver:user at server/path/to/repository" ), which gives returnes the wrong
value becouse cvsps.py fails to strip the prefix from filenames.
With this patch for the same input we get the correct repo path that is:
"/path/to/repository"

diff -r 762208a3edab -r 2fb5c25951f2 hgext/convert/cvsps.py
--- a/hgext/convert/cvsps.py    Wed May 01 17:49:53 2013 -0500
+++ b/hgext/convert/cvsps.py    Fri May 03 19:34:59 2013 +0200
@@ -50,7 +50,7 @@
     >>> getrepopath('/foo/bar')
     '/foo/bar'
     >>> getrepopath('c:/foo/bar')
-    'c:/foo/bar'
+    '/foo/bar'
     >>> getrepopath(':pserver:10/foo/bar')
     '/foo/bar'
     >>> getrepopath(':pserver:10c:/foo/bar')
@@ -58,30 +58,31 @@
     >>> getrepopath(':pserver:/foo/bar')
     '/foo/bar'
     >>> getrepopath(':pserver:c:/foo/bar')
-    'c:/foo/bar'
+    '/foo/bar'
     >>> getrepopath(':pserver:truc at foo.bar:/foo/bar')
     '/foo/bar'
     >>> getrepopath(':pserver:truc at foo.bar:c:/foo/bar')
-    'c:/foo/bar'
+    '/foo/bar'
+    >>> getrepopath('user at server/path/to/repository')
+    '/path/to/repository'
     """
     # According to CVS manual, CVS paths are expressed like:
     # [:method:][[user][:password]@]hostname[:[port]]/path/to/repository
     #
-    # Unfortunately, Windows absolute paths start with a drive letter
-    # like 'c:' making it harder to parse. Here we assume that drive
-    # letters are only one character long and any CVS component before
-    # the repository path is at least 2 characters long, and use this
-    # to disambiguate.
+    # CVSpath is splitted into parts and then position of the first
occurance
+    # of the '/' char after the '@' is located. The solution is the rest
of the
+    # string after that '/' sign including it
+
     parts = cvspath.split(':')
-    if len(parts) == 1:
-        return parts[0]
-    # Here there is an ambiguous case if we have a port number
-    # immediately followed by a Windows driver letter. We assume this
-    # never happens and decide it must be CVS path component,
-    # therefore ignoring it.
-    if len(parts[-2]) > 1:
-        return parts[-1].lstrip('0123456789')
-    return parts[-2] + ':' + parts[-1]
+    atposition = parts[-1].find('@')
+    start = 0
+
+    if atposition != -1:
+        start = atposition
+
+    repopath = parts[-1][parts[-1].find('/', start):]
+    return repopath
+

 def createlog(ui, directory=None, root="", rlog=True, cache=None):
     '''Collect the CVS rlog'''
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130503/74048067/attachment.html>


More information about the Mercurial-devel mailing list