summaryrefslogtreecommitdiffstats
path: root/git_refs.py
diff options
context:
space:
mode:
authorJoanna Wang <jojwang@google.com>2022-11-03 16:51:19 -0400
committerJoanna Wang <jojwang@google.com>2022-11-03 21:07:07 +0000
commita6c52f566acfbff5b0f37158c0d33adf05d250e5 (patch)
treed79d55b872c3be39c54dcb6ef41749c40d39ccf2 /git_refs.py
parent0d130d2da0754c546f654ede99a79aac2b8e6c5f (diff)
downloadgit-repo-a6c52f566acfbff5b0f37158c0d33adf05d250e5.tar.gz
Set tracing to always on and save to .repo/TRACE_FILE.
- add `--trace_to_stderr` option so stderr will include trace outputs and any other errors that get sent to stderr - while TRACE_FILE will only include trace outputs piggy-backing on: https://gerrit-review.googlesource.com/c/git-repo/+/349154 Change-Id: I3895a84de4b2784f17fac4325521cd5e72e645e2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/350114 Reviewed-by: LaMont Jones <lamontjones@google.com> Tested-by: Joanna Wang <jojwang@google.com>
Diffstat (limited to 'git_refs.py')
-rw-r--r--git_refs.py57
1 files changed, 28 insertions, 29 deletions
diff --git a/git_refs.py b/git_refs.py
index 2d4a8090..300d2b30 100644
--- a/git_refs.py
+++ b/git_refs.py
@@ -67,38 +67,37 @@ class GitRefs(object):
67 self._LoadAll() 67 self._LoadAll()
68 68
69 def _NeedUpdate(self): 69 def _NeedUpdate(self):
70 Trace(': scan refs %s', self._gitdir) 70 with Trace(': scan refs %s', self._gitdir):
71 71 for name, mtime in self._mtime.items():
72 for name, mtime in self._mtime.items(): 72 try:
73 try: 73 if mtime != os.path.getmtime(os.path.join(self._gitdir, name)):
74 if mtime != os.path.getmtime(os.path.join(self._gitdir, name)): 74 return True
75 except OSError:
75 return True 76 return True
76 except OSError: 77 return False
77 return True
78 return False
79 78
80 def _LoadAll(self): 79 def _LoadAll(self):
81 Trace(': load refs %s', self._gitdir) 80 with Trace(': load refs %s', self._gitdir):
82 81
83 self._phyref = {} 82 self._phyref = {}
84 self._symref = {} 83 self._symref = {}
85 self._mtime = {} 84 self._mtime = {}
86 85
87 self._ReadPackedRefs() 86 self._ReadPackedRefs()
88 self._ReadLoose('refs/') 87 self._ReadLoose('refs/')
89 self._ReadLoose1(os.path.join(self._gitdir, HEAD), HEAD) 88 self._ReadLoose1(os.path.join(self._gitdir, HEAD), HEAD)
90 89
91 scan = self._symref 90 scan = self._symref
92 attempts = 0 91 attempts = 0
93 while scan and attempts < 5: 92 while scan and attempts < 5:
94 scan_next = {} 93 scan_next = {}
95 for name, dest in scan.items(): 94 for name, dest in scan.items():
96 if dest in self._phyref: 95 if dest in self._phyref:
97 self._phyref[name] = self._phyref[dest] 96 self._phyref[name] = self._phyref[dest]
98 else: 97 else:
99 scan_next[name] = dest 98 scan_next[name] = dest
100 scan = scan_next 99 scan = scan_next
101 attempts += 1 100 attempts += 1
102 101
103 def _ReadPackedRefs(self): 102 def _ReadPackedRefs(self):
104 path = os.path.join(self._gitdir, 'packed-refs') 103 path = os.path.join(self._gitdir, 'packed-refs')