mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
git-cache: contains_revision returns False if sentient file exists
If git_cache.populate() gets interrupted midway, it can possibly leave a git mirror in a state where only some commits are available. Cloning such a repo results in an empty repository and causes subsequent git checkout to fail. If the sentient file exists, it indicates that the bootstrapping process was interrupted. This CL updates git_cache.contains_revision() such that it returns False if the sentient file exists. Then, the caller can call mirror.populate() to re-populate the repo/rev. Bug: 41488725 Change-Id: I24fd24e300f5a9f9349589496d6b5f3dacf71fd2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6491733 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Scott Lee <ddoman@chromium.org> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
This commit is contained in:
@@ -317,6 +317,14 @@ class Mirror(object):
|
||||
if not self.exists():
|
||||
return False
|
||||
|
||||
# If the cache population is in progress, this will raise LockError().
|
||||
with lockfile.lock(self.mirror_path, timeout=0):
|
||||
# If the sentinent file exists at this point, it indicates that
|
||||
# the bootstrapping process was interrupted, leaving the cache
|
||||
# entries in a bad state.
|
||||
if os.path.isfile(self._init_sentient_file):
|
||||
return False
|
||||
|
||||
if sys.platform.startswith('win'):
|
||||
# Windows .bat scripts use ^ as escape sequence, which means we have
|
||||
# to escape it with itself for every .bat invocation.
|
||||
|
||||
Reference in New Issue
Block a user