##// END OF EJS Templates
blackbox: prevent failed I/O from causing hg to abort...
Bryan O'Sullivan -
r18786:ed39a8f9 default
parent child Browse files
Show More
@@ -57,11 +57,20 b' def wrapui(ui):'
57 57 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
58 58 user = getpass.getuser()
59 59 formattedmsg = msg[0] % msg[1:]
60 blackbox.write('%s %s> %s' % (date, user, formattedmsg))
60 try:
61 blackbox.write('%s %s> %s' % (date, user, formattedmsg))
62 except IOError, err:
63 self.debug('warning: cannot write to blackbox.log: %s\n' %
64 err.strerror)
61 65 lastblackbox = blackbox
62 66
63 67 def setrepo(self, repo):
64 self._blackbox = repo.opener('blackbox.log', 'a')
68 try:
69 self._blackbox = repo.opener('blackbox.log', 'a')
70 except IOError, err:
71 self.debug('warning: cannot write to blackbox.log: %s\n' %
72 err.strerror)
73 self._blackbox = None
65 74
66 75 ui.__class__ = blackboxui
67 76
@@ -61,6 +61,48 b' clone, commit, pull'
61 61 1970/01/01 00:00:00 bob> 1 incoming changes - new heads: d02f48003e62
62 62 1970/01/01 00:00:00 bob> pull exited None after * seconds (glob)
63 63
64 we must not cause a failure if we cannot write to the log
65
66 $ hg rollback
67 repository tip rolled back to revision 1 (undo pull)
68 $ chmod 000 .hg/blackbox.log
69 $ hg --debug incoming
70 warning: cannot write to blackbox.log: Permission denied
71 comparing with $TESTTMP/blackboxtest
72 query 1; heads
73 searching for changes
74 all local heads known remotely
75 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
76 tag: tip
77 phase: draft
78 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
79 parent: -1:0000000000000000000000000000000000000000
80 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
81 user: test
82 date: Thu Jan 01 00:00:00 1970 +0000
83 files+: c
84 extra: branch=default
85 description:
86 c
87
88
89 $ hg pull
90 pulling from $TESTTMP/blackboxtest
91 searching for changes
92 adding changesets
93 adding manifests
94 adding file changes
95 added 1 changesets with 1 changes to 1 files
96 (run 'hg update' to get a working copy)
97
98 a failure reading from the log is fine
99
100 $ hg blackbox -l 3
101 abort: Permission denied: $TESTTMP/blackboxtest2/.hg/blackbox.log
102 [255]
103
104 $ chmod 600 .hg/blackbox.log
105
64 106 backup bundles get logged
65 107
66 108 $ touch d
General Comments 0
You need to be logged in to leave comments. Login now