mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
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 <sop@google.com>
This commit is contained in:
parent
0f3dd233ec
commit
b81ac9e654
@ -19,7 +19,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
from urllib2 import urlopen, HTTPError
|
from urllib2 import urlopen, HTTPError
|
||||||
from error import GitError, UploadError
|
from error import GitError, UploadError
|
||||||
from git_command import GitCommand
|
from git_command import GitCommand, TRACE
|
||||||
|
|
||||||
R_HEADS = 'refs/heads/'
|
R_HEADS = 'refs/heads/'
|
||||||
R_TAGS = 'refs/tags/'
|
R_TAGS = 'refs/tags/'
|
||||||
@ -189,6 +189,8 @@ class GitConfig(object):
|
|||||||
except OSError:
|
except OSError:
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
|
if TRACE:
|
||||||
|
print >>sys.stderr, ': unpickle %s' % self.file
|
||||||
return cPickle.load(open(self._pickle, 'r'))
|
return cPickle.load(open(self._pickle, 'r'))
|
||||||
except IOError:
|
except IOError:
|
||||||
os.remove(self._pickle)
|
os.remove(self._pickle)
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
from git_command import TRACE
|
||||||
|
|
||||||
HEAD = 'HEAD'
|
HEAD = 'HEAD'
|
||||||
R_HEADS = 'refs/heads/'
|
R_HEADS = 'refs/heads/'
|
||||||
@ -63,6 +65,8 @@ class GitRefs(object):
|
|||||||
self._LoadAll()
|
self._LoadAll()
|
||||||
|
|
||||||
def _NeedUpdate(self):
|
def _NeedUpdate(self):
|
||||||
|
if TRACE:
|
||||||
|
print >>sys.stderr, ': scan refs %s' % self._gitdir
|
||||||
for name, mtime in self._mtime.iteritems():
|
for name, mtime in self._mtime.iteritems():
|
||||||
try:
|
try:
|
||||||
if mtime != os.path.getmtime(os.path.join(self._gitdir, name)):
|
if mtime != os.path.getmtime(os.path.join(self._gitdir, name)):
|
||||||
@ -72,6 +76,8 @@ class GitRefs(object):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def _LoadAll(self):
|
def _LoadAll(self):
|
||||||
|
if TRACE:
|
||||||
|
print >>sys.stderr, ': load refs %s' % self._gitdir
|
||||||
self._phyref = {}
|
self._phyref = {}
|
||||||
self._symref = {}
|
self._symref = {}
|
||||||
self._mtime = {}
|
self._mtime = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user