comparison mercurial/localrepo.py @ 24747:bef8b17443a3

develwarn: refactor the developer warning logic The logic is currently duplicated and we plan to make it a bit smarter. So we move it into a function first to make the update more robust and simple.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Sun, 12 Apr 2015 14:24:28 -0400
parents e0c810d0ab69
children d6caadff4779
comparison
equal deleted inserted replaced
24746:e0c810d0ab69 24747:bef8b17443a3
924 def transaction(self, desc, report=None): 924 def transaction(self, desc, report=None):
925 if (self.ui.configbool('devel', 'all') 925 if (self.ui.configbool('devel', 'all')
926 or self.ui.configbool('devel', 'check-locks')): 926 or self.ui.configbool('devel', 'check-locks')):
927 l = self._lockref and self._lockref() 927 l = self._lockref and self._lockref()
928 if l is None or not l.held: 928 if l is None or not l.held:
929 msg = 'transaction with no lock\n' 929 scmutil.develwarn(self.ui, 'transaction with no lock\n')
930 if self.ui.tracebackflag:
931 util.debugstacktrace(msg, 1)
932 else:
933 self.ui.write_err(msg)
934 tr = self.currenttransaction() 930 tr = self.currenttransaction()
935 if tr is not None: 931 if tr is not None:
936 return tr.nest() 932 return tr.nest()
937 933
938 # abort here if the journal already exists 934 # abort here if the journal already exists
1218 1214
1219 if (self.ui.configbool('devel', 'all') 1215 if (self.ui.configbool('devel', 'all')
1220 or self.ui.configbool('devel', 'check-locks')): 1216 or self.ui.configbool('devel', 'check-locks')):
1221 l = self._lockref and self._lockref() 1217 l = self._lockref and self._lockref()
1222 if l is not None and l.held: 1218 if l is not None and l.held:
1223 msg = '"wlock" acquired after "lock"\n' 1219 scmutil.develwarn(self.ui, '"wlock" acquired after "lock"\n')
1224 if self.ui.tracebackflag:
1225 util.debugstacktrace(msg, 1)
1226 else:
1227 self.ui.write_err(msg)
1228 1220
1229 def unlock(): 1221 def unlock():
1230 if self.dirstate.pendingparentchange(): 1222 if self.dirstate.pendingparentchange():
1231 self.dirstate.invalidate() 1223 self.dirstate.invalidate()
1232 else: 1224 else: