summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index eaca50c9..3fa6efa5 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -1866,6 +1866,14 @@ later is required to fix a server side protocol bug.
1866 mp.config.GetSyncAnalysisStateData(), "current_sync_state" 1866 mp.config.GetSyncAnalysisStateData(), "current_sync_state"
1867 ) 1867 )
1868 1868
1869 self._local_sync_state.PruneRemovedProjects()
1870 if self._local_sync_state.IsPartiallySynced():
1871 print(
1872 "warning: Partial syncs are not supported. For the best "
1873 "experience, sync the entire tree.",
1874 file=sys.stderr,
1875 )
1876
1869 if not opt.quiet: 1877 if not opt.quiet:
1870 print("repo sync has finished successfully.") 1878 print("repo sync has finished successfully.")
1871 1879
@@ -1975,7 +1983,10 @@ class _LocalSyncState(object):
1975 _LAST_CHECKOUT = "last_checkout" 1983 _LAST_CHECKOUT = "last_checkout"
1976 1984
1977 def __init__(self, manifest): 1985 def __init__(self, manifest):
1978 self._path = os.path.join(manifest.repodir, ".repo_localsyncstate.json") 1986 self._manifest = manifest
1987 self._path = os.path.join(
1988 self._manifest.repodir, ".repo_localsyncstate.json"
1989 )
1979 self._time = time.time() 1990 self._time = time.time()
1980 self._state = None 1991 self._state = None
1981 self._Load() 1992 self._Load()
@@ -2023,6 +2034,34 @@ class _LocalSyncState(object):
2023 except (IOError, TypeError): 2034 except (IOError, TypeError):
2024 platform_utils.remove(self._path, missing_ok=True) 2035 platform_utils.remove(self._path, missing_ok=True)
2025 2036
2037 def PruneRemovedProjects(self):
2038 """Remove entries don't exist on disk and save."""
2039 if not self._state:
2040 return
2041 delete = set()
2042 for path in self._state:
2043 gitdir = os.path.join(self._manifest.topdir, path, ".git")
2044 if not os.path.exists(gitdir):
2045 delete.add(path)
2046 if not delete:
2047 return
2048 for path in delete:
2049 del self._state[path]
2050 self.Save()
2051
2052 def IsPartiallySynced(self):
2053 """Return whether a partial sync state is detected."""
2054 self._Load()
2055 prev_checkout_t = None
2056 for data in self._state.values():
2057 checkout_t = data.get(self._LAST_CHECKOUT)
2058 if not checkout_t:
2059 return True
2060 prev_checkout_t = prev_checkout_t or checkout_t
2061 if prev_checkout_t != checkout_t:
2062 return True
2063 return False
2064
2026 2065
2027# This is a replacement for xmlrpc.client.Transport using urllib2 2066# This is a replacement for xmlrpc.client.Transport using urllib2
2028# and supporting persistent-http[s]. It cannot change hosts from 2067# and supporting persistent-http[s]. It cannot change hosts from