[PATCH] cvsps: cvs log loop uses lookahead to avoid misleading text
David Champion
dgc at uchicago.edu
Sun Jan 4 01:16:31 CST 2009
# HG changeset patch
# User David Champion <dgc at uchicago.edu>
# Date 1231053321 21600
# Node ID ae946d023d8ee3a312cae7f35dd14d1f5568f7fb
# Parent 016a7319e76ba15474a89199657c5aa39bd3b339
cvsps: cvs log loop uses lookahead to avoid misleading text
Changes cvsps.py's cvs log reader to use a one-line lookahead, so
that possibly misleading log messages can be disambiguated. In
particular I have past committers who used cvs log's 28-character
row of hyphens within commit messages; this throws cvsps and disrupts
conversion. The only alternative in this case is to edit the cvs
,v file by hand, which bloodies mercurial's "don't change history"
principle.
diff -r 016a7319e76b -r ae946d023d8e hgext/convert/cvsps.py
--- a/hgext/convert/cvsps.py Wed Dec 31 18:00:35 2008 -0600
+++ b/hgext/convert/cvsps.py Sun Jan 04 01:15:21 2009 -0600
@@ -186,12 +186,20 @@
tags = {} # dictionary of revisions on current file with their tags
state = 0
store = False # set when a new record can be appended
+ lno = 0
cmd = [util.shellquote(arg) for arg in cmd]
ui.note(_("running %s\n") % (' '.join(cmd)))
ui.debug(_("prefix=%r directory=%r root=%r\n") % (prefix, directory, root))
- for line in util.popen(' '.join(cmd)):
+ pfp = util.popen(' '.join(cmd))
+ peek = pfp.readline()
+ while True:
+ line = peek
+ if line == '':
+ break
+ peek = pfp.readline()
+ lno += 1
if line.endswith('\n'):
line = line[:-1]
#ui.debug('state=%d line=%r\n' % (state, line))
@@ -312,7 +320,7 @@
e.branches = [tuple([int(y) for y in x.strip().split('.')])
for x in m.group(1).split(';')]
state = 8
- elif re_31.match(line):
+ elif re_31.match(line) and re_50.match(peek):
state = 5
store = True
elif re_32.match(line):
More information about the Mercurial-devel
mailing list