Submitter | Durham Goode |
---|---|
Date | Feb. 10, 2013, 11:07 a.m. |
Message ID | <4192cc153d6f8d529723.1360494441@dev350.prn1.facebook.com> |
Download | mbox | patch |
Permalink | /patch/922/ |
State | Superseded |
Commit | f27598902007f6176a01f12f91505e75d496ccb0 |
Headers | show |
Comments
On Sun, Feb 10, 2013 at 11:07 AM, Durham Goode <durham@fb.com> wrote: > # HG changeset patch > # User Durham Goode <durham@fb.com> > # Date 1360429786 28800 > # Node ID 4192cc153d6f8d529723c9df20255693b73e723a > # Parent ee0ffe8ee86585a9842c841f7c389b037f118282 > blackbox: adds a 'blackbox' command for viewing recent logs > > Adds a 'hg blackbox' command for viewing the latest entries in the blackbox log. > By default it shows the last 10 entries, but -l allows the user to specify. > > diff --git a/hgext/blackbox.py b/hgext/blackbox.py > --- a/hgext/blackbox.py > +++ b/hgext/blackbox.py > @@ -66,3 +66,31 @@ > return > > ui.setrepo(repo) > + > +@command('^blackbox|bb', I don't think this command warrants a short alias like bb. Will it be run that often? > + [('l', 'limit', 10, _('the number of events to show')), > + ], > + _('hg blackbox [OPTION]...')) > +def blackbox(ui, repo, *revs, **opts): > + '''view the recent repository events > + ''' > + > + if not os.path.exists(repo.join('blackbox.log')): > + return > + > + limit = opts.get('limit') > + blackbox = repo.opener('blackbox.log', 'r') > + lines = blackbox.read().split('\n') > + > + count = 0 > + output = [] > + for line in reversed(lines): > + if count >= limit: > + break > + > + # count the commands by matching lines like: 2013/01/23 19:13:36 root> > + if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line): > + count = count + 1 This should be "count += 1". > + output.append(line) > + > + ui.status('\n'.join(reversed(output))) > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
On Sun, Feb 10, 2013 at 12:13:38PM +0000, Brodie Rao wrote: > On Sun, Feb 10, 2013 at 11:07 AM, Durham Goode <durham@fb.com> wrote: > > # HG changeset patch > > # User Durham Goode <durham@fb.com> > > # Date 1360429786 28800 > > # Node ID 4192cc153d6f8d529723c9df20255693b73e723a > > # Parent ee0ffe8ee86585a9842c841f7c389b037f118282 > > blackbox: adds a 'blackbox' command for viewing recent logs > > > > Adds a 'hg blackbox' command for viewing the latest entries in the blackbox log. > > By default it shows the last 10 entries, but -l allows the user to specify. > > > > diff --git a/hgext/blackbox.py b/hgext/blackbox.py > > --- a/hgext/blackbox.py > > +++ b/hgext/blackbox.py > > @@ -66,3 +66,31 @@ > > return > > > > ui.setrepo(repo) > > + > > +@command('^blackbox|bb', > > I don't think this command warrants a short alias like bb. Will it be > run that often? -1 for bb alias too. User can always defines it themself. For my part, I'm likely to use bb for a bickbucket related operation.
Patch
diff --git a/hgext/blackbox.py b/hgext/blackbox.py --- a/hgext/blackbox.py +++ b/hgext/blackbox.py @@ -66,3 +66,31 @@ return ui.setrepo(repo) + +@command('^blackbox|bb', + [('l', 'limit', 10, _('the number of events to show')), + ], + _('hg blackbox [OPTION]...')) +def blackbox(ui, repo, *revs, **opts): + '''view the recent repository events + ''' + + if not os.path.exists(repo.join('blackbox.log')): + return + + limit = opts.get('limit') + blackbox = repo.opener('blackbox.log', 'r') + lines = blackbox.read().split('\n') + + count = 0 + output = [] + for line in reversed(lines): + if count >= limit: + break + + # count the commands by matching lines like: 2013/01/23 19:13:36 root> + if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line): + count = count + 1 + output.append(line) + + ui.status('\n'.join(reversed(output)))