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

Unified Diff: gclient_scm.py

Issue 195913002: gclient: in managed mode, warn if .gclient has a mismatched URL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix smoketests Created 6 years, 9 months 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') | tests/gclient_test.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 e8ab1409a9dcb23b1a160311b308fbfd0a3d974c..76b4d8dd22bd5c360b2a603a8f91a655ab296182 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -8,6 +8,7 @@ import logging
import os
import posixpath
import re
+import shlex
import sys
import tempfile
import traceback
@@ -139,6 +140,34 @@ class SCMWrapper(object):
return getattr(self, command)(options, args, file_list)
+ def GetActualRemoteURL(self):
+ """Attempt to determine the remote URL for this SCMWrapper."""
+ try:
+ return shlex.split(scm.GIT.Capture(
ahe 2014/03/24 15:07:37 I have a layout where a Subversion directory is ne
+ ['config', '--local', '--get-regexp', r'remote.*.url'],
+ self.checkout_path))[1]
+ except Exception:
+ pass
+ try:
+ return scm.SVN.CaptureLocalInfo([], self.checkout_path)['URL']
+ except Exception:
+ pass
+ return None
+
+ def DoesRemoteURLMatch(self):
+ """Determine whether the remote URL of this checkout is the expected URL."""
+ if not os.path.exists(self.checkout_path):
+ # A checkout which doesn't exist can't be broken.
+ return True
+
+ actual_remote_url = self.GetActualRemoteURL()
+ if actual_remote_url:
+ return actual_remote_url.rstrip('/') == self.url.rstrip('/')
+ else:
+ # This may occur if the self.checkout_path exists but does not contain a
+ # valid git or svn checkout.
+ return False
+
class GitWrapper(SCMWrapper):
"""Wrapper for Git"""
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698