def decorated_function(*args, **kwargs): """This is the decorated function.""" from bzrlib import trace trace.mutter_callsite(4, "Deprecated function called") warn(deprecation_string(callable, deprecation_version), DeprecationWarning, stacklevel=2) return callable(*args, **kwargs)
def get_keys(self): if 'evil' in debug.debug_flags: from bzrlib import remote if isinstance(self._repo, remote.RemoteRepository): # warn developers (not users) not to do this trace.mutter_callsite( 2, "EverythingResult(RemoteRepository).get_keys() is slow.") return self._repo.all_revision_ids()
def test_mutter_callsite_2(self): """mutter_callsite can capture 2 levels of stack frame.""" mutter_callsite(2, "foo %s", "a string") log = self.get_log() # begin with the message self.assertLogStartsWith(log, 'foo a string\nCalled from:\n') # should show two frame: this frame and the one above self.assertContainsRe( log, 'test_trace.py", line \d+, in test_mutter_callsite_2\n') # this frame should be the final one self.assertEndsWith(log, ' "a string")\n')
def test_mutter_callsite_2(self): """mutter_callsite can capture 2 levels of stack frame.""" mutter_callsite(2, "foo %s", "a string") log = self._get_log(keep_log_file=True) # begin with the message self.assertLogStartsWith(log, 'foo a string\nCalled from:\n') # should show two frame: this frame and the one above self.assertContainsRe(log, 'test_trace.py", line \d+, in test_mutter_callsite_2\n') # this frame should be the final one self.assertEndsWith(log, ' "a string")\n')
def decorated_method(self, *args, **kwargs): """This is the decorated method.""" from bzrlib import trace if callable.__name__ == '__init__': symbol = "%s.%s" % (self.__class__.__module__, self.__class__.__name__, ) else: symbol = "%s.%s.%s" % (self.__class__.__module__, self.__class__.__name__, callable.__name__ ) trace.mutter_callsite(4, "Deprecated method called") warn(deprecation_version % symbol, DeprecationWarning, stacklevel=2) return callable(self, *args, **kwargs)
def _set_revision_history(self, rev_history): if 'evil' in debug.debug_flags: mutter_callsite(3, "set_revision_history scales with history.") check_not_reserved_id = _mod_revision.check_not_reserved_id for rev_id in rev_history: check_not_reserved_id(rev_id) if Branch.hooks['post_change_branch_tip']: # Don't calculate the last_revision_info() if there are no hooks # that will use it. old_revno, old_revid = self.last_revision_info() if len(rev_history) == 0: revid = _mod_revision.NULL_REVISION else: revid = rev_history[-1] self._run_pre_change_branch_tip_hooks(len(rev_history), revid) self._write_revision_history(rev_history) self._clear_cached_state() self._cache_revision_history(rev_history) if Branch.hooks['post_change_branch_tip']: self._run_post_change_branch_tip_hooks(old_revno, old_revid)
def _all_possible_ids(self): """Return all the possible revisions that we could find.""" if 'evil' in debug.debug_flags: trace.mutter_callsite( 3, "_all_possible_ids scales with size of history.") return [key[-1] for key in self.inventories.keys()]