##// END OF EJS Templates
blackbox: adds a 'blackbox' command for viewing recent logs...
Durham Goode -
r18673:f2759890 default
parent child Browse files
Show More
@@ -75,3 +75,31 b' def reposetup(ui, repo):'
75 return
75 return
76
76
77 ui.setrepo(repo)
77 ui.setrepo(repo)
78
79 @command('^blackbox',
80 [('l', 'limit', 10, _('the number of events to show')),
81 ],
82 _('hg blackbox [OPTION]...'))
83 def blackbox(ui, repo, *revs, **opts):
84 '''view the recent repository events
85 '''
86
87 if not os.path.exists(repo.join('blackbox.log')):
88 return
89
90 limit = opts.get('limit')
91 blackbox = repo.opener('blackbox.log', 'r')
92 lines = blackbox.read().split('\n')
93
94 count = 0
95 output = []
96 for line in reversed(lines):
97 if count >= limit:
98 break
99
100 # count the commands by matching lines like: 2013/01/23 19:13:36 root>
101 if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line):
102 count += 1
103 output.append(line)
104
105 ui.status('\n'.join(reversed(output)))
General Comments 0
You need to be logged in to leave comments. Login now