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

Unified Diff: gclient_scm.py

Issue 12301002: Make safesync w/ git hash work when lkgr is ahead of clone. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@fix_user
Patch Set: Created 7 years, 10 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 | « no previous file | tests/gclient_scm_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 dfbcb172b99e19094b979929f287042f0d59aa80..c64a3b646f66db2122f52ff2ab60e2defeeaab9b 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -33,8 +33,8 @@ class DiffFiltererWrapper(object):
def SetCurrentFile(self, current_file):
self._current_file = current_file
- @property
- def _replacement_file(self):
+ @property
+ def _replacement_file(self):
return posixpath.join(self._relpath, self._current_file)
def _Replace(self, line):
@@ -567,15 +567,18 @@ class GitWrapper(SCMWrapper):
If SCM is git-svn and the head revision is less than |rev|, git svn fetch
will be called on the source."""
sha1 = None
- # Handles an SVN rev. As an optimization, only verify an SVN revision as
- # [0-9]{1,6} for now to avoid making a network request.
- if rev.isdigit() and len(rev) < 7:
- # If the content of the safesync_url appears to be an SVN rev and the
- # URL of the source appears to be git, we can only attempt to find out
- # if a revision is useful after we've cloned the original URL, so just
- # ignore for now.
- if (os.path.isdir(self.checkout_path) and
- scm.GIT.IsGitSvn(cwd=self.checkout_path)):
+ if not os.path.isdir(self.checkout_path):
M-A Ruel 2013/02/19 19:07:44 Why are you breaking svn users? It's not necessary
iannucci 2013/02/19 19:18:33 I'm not, this was in the second if statement in th
M-A Ruel 2013/02/19 19:21:42 Oh right, this is only for git checkouts, ok fine.
+ raise gclient_utils.Error(
+ ( 'We could not find a valid hash for safesync_url response "%s".\n'
+ 'Safesync URLs with a git checkout currently require the repo to\n'
+ 'be cloned without a safesync_url before adding the safesync_url.\n'
+ 'For more info, see: '
+ 'http://code.google.com/p/chromium/wiki/UsingNewGit'
+ '#Initial_checkout' ) % rev)
+ elif rev.isdigit() and len(rev) < 7:
+ # Handles an SVN rev. As an optimization, only verify an SVN revision as
+ # [0-9]{1,6} for now to avoid making a network request.
+ if scm.GIT.IsGitSvn(cwd=self.checkout_path):
local_head = scm.GIT.GetGitSvnHeadRev(cwd=self.checkout_path)
if not local_head or local_head < int(rev):
try:
@@ -604,8 +607,15 @@ class GitWrapper(SCMWrapper):
'configured or the revision in your safesync_url is\n'
'higher than git-svn remote\'s HEAD as we couldn\'t find a\n'
'corresponding git hash for SVN rev %s.' ) % rev)
- elif scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
- sha1 = rev
+ else:
+ if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
+ sha1 = rev
+ else:
+ # May exist in origin, but we don't have it yet, so fetch and look
+ # again.
+ scm.GIT.Capture(['fetch', 'origin'], cwd=self.checkout_path)
+ if scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=rev):
+ sha1 = rev
if not sha1:
raise gclient_utils.Error(
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698