[Python-checkins] python/dist/src/Tools/scripts logmerge.py,1.8,1.9
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Sat, 28 Sep 2002 21:37:38 -0700
Update of /cvsroot/python/python/dist/src/Tools/scripts
In directory usw-pr-cvs1:/tmp/cvs-serv15075
Modified Files:
logmerge.py
Log Message:
Added -b tag option to limit output to a specific branch only.
Use -b HEAD to limit output to the trunk (skip all branch revisions).
Index: logmerge.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/scripts/logmerge.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** logmerge.py 11 Sep 2002 20:36:01 -0000 1.8
--- logmerge.py 29 Sep 2002 04:37:36 -0000 1.9
***************
*** 20,23 ****
--- 20,32 ----
probably want everything *since* that tag.
+ The -r option reverses the output (oldest first; the default is oldest
+ last).
+
+ The -b tag option restricts the output to *only* checkin messages
+ belonging to the given branch tag. The form -b HEAD restricts the
+ output to checkin messages belonging to the CVS head (trunk). (It
+ produces some output if tag is a non-branch tag, but this output is
+ not very useful.)
+
XXX This code was created by reverse engineering CVS 1.9 and RCS 5.7
from their output.
***************
*** 25,29 ****
"""
! import os, sys, getopt, re
sep1 = '='*77 + '\n' # file separator
--- 34,38 ----
"""
! import os, sys, getopt
sep1 = '='*77 + '\n' # file separator
***************
*** 34,38 ****
truncate_last = 0
reverse = 0
! opts, args = getopt.getopt(sys.argv[1:], "tr")
for o, a in opts:
if o == '-t':
--- 43,48 ----
truncate_last = 0
reverse = 0
! branch = None
! opts, args = getopt.getopt(sys.argv[1:], "trb:")
for o, a in opts:
if o == '-t':
***************
*** 40,43 ****
--- 50,55 ----
elif o == '-r':
reverse = 1
+ elif o == '-b':
+ branch = a
database = []
while 1:
***************
*** 45,49 ****
if not chunk:
break
! records = digest_chunk(chunk)
if truncate_last:
del records[-1]
--- 57,61 ----
if not chunk:
break
! records = digest_chunk(chunk, branch)
if truncate_last:
del records[-1]
***************
*** 78,83 ****
return chunk
! def digest_chunk(chunk):
! """Digest a chunk -- extrach working file name and revisions"""
lines = chunk[0]
key = 'Working file:'
--- 90,95 ----
return chunk
! def digest_chunk(chunk, branch=None):
! """Digest a chunk -- extract working file name and revisions"""
lines = chunk[0]
key = 'Working file:'
***************
*** 89,92 ****
--- 101,124 ----
else:
working_file = None
+ if branch and branch != "HEAD":
+ revisions = {}
+ key = 'symbolic names:\n'
+ found = 0
+ for line in lines:
+ if line == key:
+ found = 1
+ elif found:
+ if line[0] in '\t ':
+ tag, rev = line.split()
+ if tag[-1] == ':':
+ tag = tag[:-1]
+ revisions[tag] = rev
+ else:
+ found = 0
+ rev = revisions.get(branch)
+ if rev:
+ if rev.find('.0.') >= 0:
+ rev = rev.replace('.0.', '.') + '.'
+ branch = rev or "<>" # <> to force a mismatch
records = []
for lines in chunk[1:]:
***************
*** 115,118 ****
--- 147,156 ----
rev = None
text.insert(0, revline)
+ if branch:
+ if branch == "HEAD":
+ if rev is not None and rev.count('.') > 1:
+ continue
+ elif rev is None or not rev.startswith(branch):
+ continue
records.append((date, working_file, rev, author, text))
return records