From b81ac9e65444d0f54d2b6dd24d20b74945c9a36a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 17 Apr 2009 20:44:26 -0700 Subject: Enable tracing of ref scans and config unpickling These are not as expensive as spawning a git command, but they are not free either. We want to keep track of how many times we wind up calling them on any particular operation. Signed-off-by: Shawn O. Pearce --- git_config.py | 4 +++- git_refs.py | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/git_config.py b/git_config.py index c87d5bed..f65a0353 100644 --- a/git_config.py +++ b/git_config.py @@ -19,7 +19,7 @@ import re import sys from urllib2 import urlopen, HTTPError from error import GitError, UploadError -from git_command import GitCommand +from git_command import GitCommand, TRACE R_HEADS = 'refs/heads/' R_TAGS = 'refs/tags/' @@ -189,6 +189,8 @@ class GitConfig(object): except OSError: return None try: + if TRACE: + print >>sys.stderr, ': unpickle %s' % self.file return cPickle.load(open(self._pickle, 'r')) except IOError: os.remove(self._pickle) diff --git a/git_refs.py b/git_refs.py index b91abc28..be8d271b 100644 --- a/git_refs.py +++ b/git_refs.py @@ -14,6 +14,8 @@ # limitations under the License. import os +import sys +from git_command import TRACE HEAD = 'HEAD' R_HEADS = 'refs/heads/' @@ -63,6 +65,8 @@ class GitRefs(object): self._LoadAll() def _NeedUpdate(self): + if TRACE: + print >>sys.stderr, ': scan refs %s' % self._gitdir for name, mtime in self._mtime.iteritems(): try: if mtime != os.path.getmtime(os.path.join(self._gitdir, name)): @@ -72,6 +76,8 @@ class GitRefs(object): return False def _LoadAll(self): + if TRACE: + print >>sys.stderr, ': load refs %s' % self._gitdir self._phyref = {} self._symref = {} self._mtime = {} -- cgit v1.2.3-54-g00ecf