Patchwork cvs conversion now properly parse cvsroot

login
register
mail settings
Submitter Hrvoje Kozak
Date May 2, 2013, 11:37 p.m.
Message ID <CAPY-=99TVXYo_AKau6WgxJoLT4KCT_f__8LJGkzBs_=C9XEXUA@mail.gmail.com>
Download mbox | patch
Permalink /patch/1535/
State Superseded, archived
Headers show

Comments

Hrvoje Kozak - May 2, 2013, 11:37 p.m.
Bug 3678 fix

The cvsps.py:getrepopath suffers from a string parsing bug (it returns
"user@server/path/to/repository" if the CVSROOT is given like this:
":pserver:user@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"

# HG changeset patch
# User Blesso hrvoje1212@gmail.com
# Date 1367535301 -7200
# Branch stable
# Node ID 4d5bb9a7d2b31ca450f4ff2af6da4984bd75161c
# Parent  762208a3edabc483936fff7ef4c8e02b25a8fba0
bug 3678 fix

Patch

diff -r 762208a3edab -r 4d5bb9a7d2b3 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 00:55:01 2013 +0200
@@ -67,21 +67,17 @@ 
     # 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 = atPosition if atPosition != -1 else 0
+
+    repoPath = parts[-1][parts[-1].find('/', start):]
+    return repoPath