Submitter | timeless@mozdev.org |
---|---|
Date | Feb. 3, 2016, 9:40 p.m. |
Message ID | <552c58b545c24037fcf0.1454535645@waste.org> |
Download | mbox | patch |
Permalink | /patch/12963/ |
State | Changes Requested |
Delegated to: | Yuya Nishihara |
Headers | show |
Comments
On Wed, 03 Feb 2016 15:40:45 -0600, timeless wrote: > # HG changeset patch > # User timeless <timeless@mozdev.org> > # Date 1454522670 0 > # Wed Feb 03 18:04:30 2016 +0000 > # Node ID 552c58b545c24037fcf09d4ca39c65628bd1c654 > # Parent 53190dfbd7ebb3fe6bc714ce08f8c1a7ae7ef16e > blackbox: make blackbox not abort if it cannot read > > The test claimed it was "fine", but the output was an abort. > This changes the output to match the behavior described by > the test instead of the output the test showed... > a failure reading from the log is fine > > $ hg blackbox -l 3 > - abort: *: $TESTTMP/blackboxtest2/.hg/blackbox.log (glob) Well, perhaps it means "a failure" is fine for reading, so do abort. Is there a benefit to not abort?
Yuya Nishihara wrote: >> a failure reading from the log is fine > Well, perhaps it means "a failure" is fine for reading, so do abort. > > Is there a benefit to not abort? I have no opinion. I can change the test to match the results instead.
Patch
diff --git a/hgext/blackbox.py b/hgext/blackbox.py --- a/hgext/blackbox.py +++ b/hgext/blackbox.py @@ -143,13 +143,16 @@ '''view the recent repository events ''' - if not os.path.exists(repo.join('blackbox.log')): + limit = opts.get('limit') + try: + blackbox = repo.vfs('blackbox.log', 'r') + lines = blackbox.read().split('\n') + except (IOError, OSError) as err: + ui.warn(_("could not open blackbox log file\n")) + ui.debug('warning: could not open blackbox.log: %s\n' % + err.strerror) return - limit = opts.get('limit') - blackbox = repo.vfs('blackbox.log', 'r') - lines = blackbox.read().split('\n') - count = 0 output = [] for line in reversed(lines): diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t --- a/tests/test-blackbox.t +++ b/tests/test-blackbox.t @@ -89,9 +89,11 @@ a failure reading from the log is fine $ hg blackbox -l 3 - abort: *: $TESTTMP/blackboxtest2/.hg/blackbox.log (glob) - [255] - + could not open blackbox log file + $ hg blackbox --debug + warning: cannot write to blackbox.log: * (glob) + could not open blackbox log file + warning: could not open blackbox.log: * (glob) $ rmdir .hg/blackbox.log $ mv .hg/blackbox.log- .hg/blackbox.log