##// END OF EJS Templates
convert: fix builtin cvsps under Windows...
Patrick Mezard -
r7097:d4218edd default
parent child Browse files
Show More
@@ -41,6 +41,45 b' class logentry(object):'
41 41 class logerror(Exception):
42 42 pass
43 43
44 def getrepopath(cvspath):
45 """Return the repository path from a CVS path.
46
47 >>> getrepopath('/foo/bar')
48 '/foo/bar'
49 >>> getrepopath('c:/foo/bar')
50 'c:/foo/bar'
51 >>> getrepopath(':pserver:10/foo/bar')
52 '/foo/bar'
53 >>> getrepopath(':pserver:10c:/foo/bar')
54 '/foo/bar'
55 >>> getrepopath(':pserver:/foo/bar')
56 '/foo/bar'
57 >>> getrepopath(':pserver:c:/foo/bar')
58 'c:/foo/bar'
59 >>> getrepopath(':pserver:truc@foo.bar:/foo/bar')
60 '/foo/bar'
61 >>> getrepopath(':pserver:truc@foo.bar:c:/foo/bar')
62 'c:/foo/bar'
63 """
64 # According to CVS manual, CVS paths are expressed like:
65 # [:method:][[user][:password]@]hostname[:[port]]/path/to/repository
66 #
67 # Unfortunately, Windows absolute paths start with a drive letter
68 # like 'c:' making it harder to parse. Here we assume that drive
69 # letters are only one character long and any CVS component before
70 # the repository path is at least 2 characters long, and use this
71 # to disambiguate.
72 parts = cvspath.split(':')
73 if len(parts) == 1:
74 return parts[0]
75 # Here there is an ambiguous case if we have a port number
76 # immediately followed by a Windows driver letter. We assume this
77 # never happens and decide it must be CVS path component,
78 # therefore ignoring it.
79 if len(parts[-2]) > 1:
80 return parts[-1].lstrip('0123456789')
81 return parts[-2] + ':' + parts[-1]
82
44 83 def createlog(ui, directory=None, root="", rlog=True, cache=None):
45 84 '''Collect the CVS rlog'''
46 85
@@ -83,8 +122,8 b' def createlog(ui, directory=None, root="'
83 122 except IOError:
84 123 raise logerror('Not a CVS sandbox')
85 124
86 if prefix and not prefix.endswith('/'):
87 prefix += '/'
125 if prefix and not prefix.endswith(os.sep):
126 prefix += os.sep
88 127
89 128 # Use the Root file in the sandbox, if it exists
90 129 try:
@@ -134,10 +173,10 b' def createlog(ui, directory=None, root="'
134 173 cmd = ['cvs', '-q']
135 174 if root:
136 175 cmd.append('-d%s' % root)
137 p = root.split(':')[-1]
176 p = util.normpath(getrepopath(root))
138 177 if not p.endswith('/'):
139 178 p += '/'
140 prefix = p + prefix
179 prefix = p + util.normpath(prefix)
141 180 cmd.append(['log', 'rlog'][rlog])
142 181 if date:
143 182 # no space between option and date string
@@ -165,7 +204,7 b' def createlog(ui, directory=None, root="'
165 204 rcs = match.group(1)
166 205 tags = {}
167 206 if rlog:
168 filename = rcs[:-2]
207 filename = util.normpath(rcs[:-2])
169 208 if filename.startswith(prefix):
170 209 filename = filename[len(prefix):]
171 210 if filename.startswith('/'):
@@ -191,7 +230,7 b' def createlog(ui, directory=None, root="'
191 230 # expect 'Working file' (only when using log instead of rlog)
192 231 match = re_10.match(line)
193 232 assert match, _('RCS file must be followed by working file')
194 filename = match.group(1)
233 filename = util.normpath(match.group(1))
195 234 state = 2
196 235
197 236 elif state == 2:
@@ -14,3 +14,6 b' doctest.testmod(mercurial.httprepo)'
14 14
15 15 import mercurial.util
16 16 doctest.testmod(mercurial.util)
17
18 import hgext.convert.cvsps
19 doctest.testmod(hgext.convert.cvsps)
General Comments 0
You need to be logged in to leave comments. Login now