Improvement on newphrase handling in cvs2svn_rcsparse/common.py ?
Giovanni Pellicciotta <[email protected]> Thu, 07 Apr 2011 13:36:54 +0200
| Newsgroups | gmane.comp.version-control.subversion.cvs2svn.devel |
|---|---|
| Organization | Anubex NV |
| Message-ID | <[email protected]> |
------=_Part_8866_610544769.1302177734454
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I'm not sure whether you consider this a bug or not, but I encountered a number of 'ERROR: 'xxx.c,v' is not a valid ,v file' error messages when converting a CVS repository with
cvs2svn 2.3.0.
After some further investigation I've found that the problem was an additional line between the admin portion and the deltas portion of my CVS file
According to http://www.gsp.com/cgi-bin/man.cgi?section=5&topic=rcsfile <http://www.gsp.com/cgi-bin/man.cgi?section=5&topic=rcsfile>one or more 'newphrase's are allowed in this place.
As I'm using the internal parser, the actual parsing code that causes this ERROR can be found in cvs2svn_rcsparse/common.py
This code implicitly assumes that a newphrase is a single token that can be discarded (the lines starting with # Chew up "newphrase"):
def parse_rcs_admin(self):
while 1:
# Read initial token at beginning of line
token = self.ts.get()
try:
f = self.admin_token_map[token]
except KeyError:
# We're done once we reach the description of the RCS tree
if token[0] in string.digits:
self.ts.unget(token)
return
else:
# Chew up "newphrase"
# warn("Unexpected RCS token: $token\n")
pass
else:
if f is None:
self.ts.unget(token)
return
else:
f(self, token)
However, a newphrase can consist of multiple tokens and ends with a semicolon, so IMHO the code could be improved to handle this better, as follows:
def _parse_admin_newphrase(self):
while 1:
token = self.ts.get()
if token == ';':
break
def parse_rcs_admin(self):
while 1:
# Read initial token at beginning of line
token = self.ts.get()
print "FOUND TOKEN: %s" % (token)
try:
f = self.admin_token_map[token]
except KeyError:
# We're done once we reach the description of the RCS tree
if token[0] in string.digits:
self.ts.unget(token)
return
else:
# Chew up "newphrase"
self._parse_admin_newphrase()
else:
if f is None:
self.ts.unget(token)
return
else:
f(self, token)
Best regards,
Giovanni Pellicciotta
------------------------------------------------------
http://cvs2svn.tigris.org/ds/viewMessage.do?dsForumId=1667&dsMessageId=2717617
To unsubscribe from this discussion, e-mail: [[email protected]].
------=_Part_8866_610544769.1302177734454
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
I'm not sure whether you consider this a bug or not, but I
encountered a number of
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]-->'ERROR:
'xxx.c,v' is not a valid ,v file' error messages when converting a
CVS repository with cvs2svn 2.3.0.<br>
<br>
After some further investigation I've found that the problem was an
additional line between the admin portion and the deltas portion of
my CVS file<br>
According to <a
href="http://www.gsp.com/cgi-bin/man.cgi?section=5&topic=rcsfile"
style="color: rgb(0, 51, 153);">http://www.gsp.com/cgi-bin/man.cgi?section=5&topic=rcsfile</a><span
class="Apple-style-span" style="border-collapse: separate; color:
rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal;
font-variant: normal; font-weight: normal; letter-spacing: normal;
line-height: normal; orphans: 2; text-indent: 0px; text-transform:
none; white-space: normal; widows: 2; word-spacing: 0px;
font-size: medium;"><span class="Apple-style-span"
style="font-family: sans-serif;"></span></span> one or more
'newphrase's are allowed in this place.<br>
As I'm using the internal parser, the actual parsing code that
causes this ERROR can be found in cvs2svn_rcsparse/common.py<br>
This code implicitly assumes that a newphrase is a single token that
can be discarded (the lines starting with # Chew up "newphrase"):<br>
<br>
<font face="Courier New, Courier, monospace"> def
parse_rcs_admin(self):<br>
while 1:<br>
# Read initial token at beginning of line<br>
token = self.ts.get()<br>
<br>
try:<br>
f = self.admin_token_map[token]<br>
except KeyError:<br>
# We're done once we reach the description of the RCS tree<br>
if token[0] in string.digits:<br>
self.ts.unget(token)<br>
return<br>
else:<br>
# Chew up "newphrase"<br>
# warn("Unexpected RCS token: $token\n")<br>
pass<br>
else:<br>
if f is None:<br>
self.ts.unget(token)<br>
return<br>
else:<br>
f(self, token)</font><br>
<br>
However, a newphrase can consist of multiple tokens and ends with a
semicolon, so IMHO the code could be improved to handle this better,
as follows:<br>
<br>
<!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--><font face="Courier New, Courier, monospace"> def
_parse_admin_newphrase(self):<br>
while 1:<br>
token = self.ts.get()<br>
if token == ';':<br>
break<br>
<br>
def parse_rcs_admin(self):<br>
while 1:<br>
# Read initial token at beginning of line<br>
token = self.ts.get()<br>
print "FOUND TOKEN: %s" % (token)<br>
try:<br>
f = self.admin_token_map[token]<br>
except KeyError:<br>
# We're done once we reach the description of the RCS tree<br>
if token[0] in string.digits:<br>
self.ts.unget(token)<br>
return<br>
else:<br>
# Chew up "newphrase"<br>
self._parse_admin_newphrase() <br>
else:<br>
if f is None:<br>
self.ts.unget(token)<br>
return<br>
else:<br>
f(self, token)</font><br>
<br>
<br>
Best regards,<br>
Giovanni Pellicciotta<br>
<br>
<br>
</body>
</html>
------=_Part_8866_610544769.1302177734454--