Reland "gclient: Require a target ref when applying patches."
This is a reland of 1d6478a5ffed7d272a7910d678e0a35d2f9fd69b
Original change's description:
> gclient: Require a target ref when applying patches.
>
> Bug: 956807
> Change-Id: Icfffe965f9f4651f22e8ba32c60133a5620bb350
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1616804
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Bug: 956807
Change-Id: I3de8475a091ce6a2a14ff7dcfb92507a205ef78c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1623594
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/gclient_scm.py b/gclient_scm.py
index ef7dbae..72a5dd5 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -351,28 +351,6 @@
self.Print('FAILED to break lock: %s: %s' % (to_break, ex))
raise
- # TODO(ehmaldonado): Remove after bot_update is modified to pass the patch's
- # branch.
- def _GetTargetBranchForCommit(self, commit):
- """Get the remote branch a commit is part of."""
- _WELL_KNOWN_BRANCHES = [
- 'refs/remotes/origin/master',
- 'refs/remotes/origin/infra/config',
- 'refs/remotes/origin/lkgr',
- ]
- for branch in _WELL_KNOWN_BRANCHES:
- if scm.GIT.IsAncestor(self.checkout_path, commit, branch):
- return branch
- remote_refs = self._Capture(
- ['for-each-ref', 'refs/remotes/%s' % self.remote,
- '--format=%(refname)']).splitlines()
- for ref in sorted(remote_refs, reverse=True):
- if scm.GIT.IsAncestor(self.checkout_path, commit, ref):
- return ref
- self.Print('Failed to find a remote ref that contains %s. '
- 'Candidate refs were %s.' % (commit, remote_refs))
- return None
-
def apply_patch_ref(self, patch_repo, patch_rev, target_rev, options,
file_list):
"""Apply a patch on top of the revision we're synced at.
@@ -419,8 +397,7 @@
base_rev = self._Capture(['rev-parse', 'HEAD'])
if not target_rev:
- # TODO(ehmaldonado): Raise an error once |target_rev| is mandatory.
- target_rev = self._GetTargetBranchForCommit(base_rev) or base_rev
+ raise gclient_utils.Error('A target revision for the patch must be given')
elif target_rev.startswith('refs/heads/'):
# If |target_rev| is in refs/heads/**, try first to find the corresponding
# remote ref for it, since |target_rev| might point to a local ref which