Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2547)

Unified Diff: gclient_scm.py

Issue 743083002: Make gclient ready for the Blink (DEPS to main project) transition (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Fix tests Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient.py ('k') | scm.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index e42f6716387fb720a263392290191d9ea7f56456..583a263d39e77b0252998b9f6364cd280033a97d 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -390,6 +390,20 @@ class GitWrapper(SCMWrapper):
if mirror:
url = mirror.mirror_path
+ # If we are going to introduce a new project, there is a possibility that
+ # we are syncing back to a state where the project was originally a
+ # sub-project rolled by DEPS (realistic case: crossing the Blink merge point
+ # syncing backwards, when Blink was a DEPS entry and not part of src.git).
+ # In such case, we might have a backup of the former .git folder, which can
+ # be used to avoid re-fetching the entire repo again (useful for bisects).
+ backup_dir = self.GetGitBackupDirPath()
+ target_dir = os.path.join(self.checkout_path, '.git')
+ if os.path.exists(backup_dir) and not os.path.exists(target_dir):
+ gclient_utils.safe_makedirs(self.checkout_path)
+ os.rename(backup_dir, target_dir)
+ # Reset to a clean state
+ self._Run(['reset', '--hard', 'HEAD'], options)
+
if (not os.path.exists(self.checkout_path) or
(os.path.isdir(self.checkout_path) and
not os.path.exists(os.path.join(self.checkout_path, '.git')))):
@@ -800,6 +814,12 @@ class GitWrapper(SCMWrapper):
base_url = self.url
return base_url[:base_url.rfind('/')] + url
+ def GetGitBackupDirPath(self):
+ """Returns the path where the .git folder for the current project can be
+ staged/restored. Use case: subproject moved from DEPS <-> outer project."""
+ return os.path.join(self._root_dir,
+ 'old_' + self.relpath.replace(os.sep, '_')) + '.git'
+
def _GetMirror(self, url, options):
"""Get a git_cache.Mirror object for the argument url."""
if not git_cache.Mirror.GetCachePath():
« no previous file with comments | « gclient.py ('k') | scm.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698