# HG changeset patch # User Matt Mackall # Date 1367797894 18000 # Node ID a718a0ba6787ae9546d0aa453c8a7dae25d4405b # Parent facd906caeebdd22519f5bf4836b1c1ad41a4e55# Parent 0a12e5f3a979ee302dc10647483200df00a105ab merge with stable diff -r facd906caeeb -r a718a0ba6787 hgext/convert/cvsps.py --- a/hgext/convert/cvsps.py Fri May 03 15:36:18 2013 -0700 +++ b/hgext/convert/cvsps.py Sun May 05 18:51:34 2013 -0500 @@ -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,30 @@ >>> getrepopath(':pserver:/foo/bar') '/foo/bar' >>> getrepopath(':pserver:c:/foo/bar') - 'c:/foo/bar' + '/foo/bar' >>> getrepopath(':pserver:truc@foo.bar:/foo/bar') '/foo/bar' >>> getrepopath(':pserver:truc@foo.bar:c:/foo/bar') - 'c:/foo/bar' + '/foo/bar' + >>> getrepopath('user@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 occurrence + # 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'''