MCPcopy Create free account
hub / github.com/ActiveState/code / print_log

Function print_log

recipes/Python/576729_Simple_Version_Control/recipe-576729.py:44–73  ·  view source on GitHub ↗
(repo_fn, v=None)

Source from the content-addressed store, hash-verified

42 return ''.join(curr)
43
44def print_log(repo_fn, v=None):
45 # Print log entries. *v* is a specific version number or None to print all.
46 currver = 0
47 f = iter(open(repo_fn, 'r'))
48 line = next(f, '')
49 while line:
50
51 # Process mandatory .V line and optional .N msg lines
52 assert line.startswith('.V')
53 repo_fn, datetime, msg = vline(line).groups()
54 for line in f:
55 if line.startswith('.N'):
56 msg += '\n' + nline(line).group(1)
57 else:
58 break
59
60 currver += 1
61 if v is None:
62 print "%s %d %18s %s" % (repo_fn, currver, datetime, msg)
63 elif currver == v:
64 print "%s %d %18s %s" % (repo_fn, currver, datetime, msg)
65 return
66
67 # Skip through the .I and .C instructions
68 while line and line.startswith(('.I', '.C')):
69 if line.startswith('.I'):
70 n = int(iline(line).group(1))
71 for line in islice(f, n):
72 pass
73 line = next(f, '')
74
75def diff(repo_fn, vnum1=None, vnum2=None, context=False):
76 # vnum1 or vnum2 can be None to indicate last version in repository

Callers 1

mainFunction · 0.85

Calls 3

startswithMethod · 0.80
openFunction · 0.50
groupMethod · 0.45

Tested by

no test coverage detected