|
@@ -481,17 +481,19 @@ class Mirror(object):
|
|
|
'%s and "git cache fetch" again.'
|
|
|
% os.path.join(self.mirror_path, 'config'))
|
|
|
|
|
|
- def _ensure_bootstrapped(self, depth, bootstrap, force=False):
|
|
|
+ def _ensure_bootstrapped(
|
|
|
+ self, depth, bootstrap, reset_fetch_config, force=False):
|
|
|
pack_dir = os.path.join(self.mirror_path, 'objects', 'pack')
|
|
|
pack_files = []
|
|
|
if os.path.isdir(pack_dir):
|
|
|
pack_files = [f for f in os.listdir(pack_dir) if f.endswith('.pack')]
|
|
|
- self.print('%s has %d .pack files, re-bootstrapping if >%d' %
|
|
|
+ self.print('%s has %d .pack files, re-bootstrapping if >%d or ==0' %
|
|
|
(self.mirror_path, len(pack_files), GC_AUTOPACKLIMIT))
|
|
|
|
|
|
should_bootstrap = (force or
|
|
|
not self.exists() or
|
|
|
- len(pack_files) > GC_AUTOPACKLIMIT)
|
|
|
+ len(pack_files) > GC_AUTOPACKLIMIT or
|
|
|
+ len(pack_files) == 0)
|
|
|
|
|
|
if not should_bootstrap:
|
|
|
if depth and os.path.exists(os.path.join(self.mirror_path, 'shallow')):
|
|
@@ -499,16 +501,16 @@ class Mirror(object):
|
|
|
'Shallow fetch requested, but repo cache already exists.')
|
|
|
return
|
|
|
|
|
|
- if self.exists():
|
|
|
- # Re-bootstrapping an existing mirror; preserve existing fetch spec.
|
|
|
- self._preserve_fetchspec()
|
|
|
- else:
|
|
|
+ if not self.exists():
|
|
|
if os.path.exists(self.mirror_path):
|
|
|
# If the mirror path exists but self.exists() returns false, we're
|
|
|
# in an unexpected state. Nuke the previous mirror directory and
|
|
|
# start fresh.
|
|
|
gclient_utils.rmtree(self.mirror_path)
|
|
|
os.mkdir(self.mirror_path)
|
|
|
+ elif not reset_fetch_config:
|
|
|
+ # Re-bootstrapping an existing mirror; preserve existing fetch spec.
|
|
|
+ self._preserve_fetchspec()
|
|
|
|
|
|
bootstrapped = (not depth and bootstrap and
|
|
|
self.bootstrap_repo(self.mirror_path))
|
|
@@ -571,16 +573,17 @@ class Mirror(object):
|
|
|
lockfile.lock()
|
|
|
|
|
|
try:
|
|
|
- self._ensure_bootstrapped(depth, bootstrap)
|
|
|
- self._fetch(self.mirror_path, verbose, depth, no_fetch_tags,
|
|
|
- reset_fetch_config)
|
|
|
+ self._ensure_bootstrapped(depth, bootstrap, reset_fetch_config)
|
|
|
+ self._fetch(
|
|
|
+ self.mirror_path, verbose, depth, no_fetch_tags, reset_fetch_config)
|
|
|
except ClobberNeeded:
|
|
|
# This is a major failure, we need to clean and force a bootstrap.
|
|
|
gclient_utils.rmtree(self.mirror_path)
|
|
|
self.print(GIT_CACHE_CORRUPT_MESSAGE)
|
|
|
- self._ensure_bootstrapped(depth, bootstrap, force=True)
|
|
|
- self._fetch(self.mirror_path, verbose, depth, no_fetch_tags,
|
|
|
- reset_fetch_config)
|
|
|
+ self._ensure_bootstrapped(
|
|
|
+ depth, bootstrap, reset_fetch_config, force=True)
|
|
|
+ self._fetch(
|
|
|
+ self.mirror_path, verbose, depth, no_fetch_tags, reset_fetch_config)
|
|
|
finally:
|
|
|
if not ignore_lock:
|
|
|
lockfile.unlock()
|