comparison hgext/blackbox.py @ 34299:b1d4ac068961

blackbox: do not prevent 'chg init' from working Previously, blackbox always appends to blackbox.log and creates the directory for that file on demand. That could be an issue if: 1. chg starts from `$REPO` directory, so `ui._bbrepo` is set. 2. `rm -rf $REPO`. 3. `chg init $REPO`, blackbox writes something and `init` will fail because `$REPO` directory is non-empty. This patch fixes that by verifying whether vfs exists before re-using it. Differential Revision: https://phab.mercurial-scm.org/D768
author Jun Wu <quark@fb.com>
date Thu, 21 Sep 2017 11:03:37 -0700
parents b90bd9a98c8b
children e6723c939344
comparison
equal deleted inserted replaced
34298:25e1a8876cc0 34299:b1d4ac068961
75 75
76 def wrapui(ui): 76 def wrapui(ui):
77 class blackboxui(ui.__class__): 77 class blackboxui(ui.__class__):
78 @property 78 @property
79 def _bbvfs(self): 79 def _bbvfs(self):
80 vfs = None
80 repo = getattr(self, '_bbrepo', None) 81 repo = getattr(self, '_bbrepo', None)
81 if repo: 82 if repo:
82 return repo.vfs 83 vfs = repo.vfs
84 if not vfs.isdir('.'):
85 vfs = None
86 return vfs
83 87
84 @util.propertycache 88 @util.propertycache
85 def track(self): 89 def track(self):
86 return self.configlist('blackbox', 'track', ['*']) 90 return self.configlist('blackbox', 'track', ['*'])
87 91
134 # was seen. 138 # was seen.
135 ui = lastui 139 ui = lastui
136 140
137 if not ui: 141 if not ui:
138 return 142 return
143 vfs = ui._bbvfs
144 if not vfs:
145 return
146
139 repo = getattr(ui, '_bbrepo', None) 147 repo = getattr(ui, '_bbrepo', None)
140 if not lastui or repo: 148 if not lastui or repo:
141 lastui = ui 149 lastui = ui
142 if getattr(ui, '_bbinlog', False): 150 if getattr(ui, '_bbinlog', False):
143 # recursion and failure guard 151 # recursion and failure guard