diff --git a/gclient.py b/gclient.py index 60346178f..2b5bedb0a 100755 --- a/gclient.py +++ b/gclient.py @@ -985,6 +985,7 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): patch_refs, # type: Mapping[str, str] target_branches, # type: Mapping[str, str] skip_sync_revisions, # type: Mapping[str, str] + applied_patches=None, # type: Set[str] ): # type: () -> None """Runs |command| then parse the DEPS file.""" @@ -1028,9 +1029,11 @@ class Dependency(gclient_utils.WorkItem, DependencySettings): if isinstance(self, GitDependency) and command == 'update': patch_repo = self.url.split('@')[0] - patch_ref = patch_refs.pop(self.FuzzyMatchUrl(patch_refs), None) - target_branch = target_branches.pop( - self.FuzzyMatchUrl(target_branches), None) + fuzzy_match = self.FuzzyMatchUrl(patch_refs) + patch_ref = patch_refs[fuzzy_match] if fuzzy_match else None + target_branch = target_branches[fuzzy_match] if fuzzy_match else None + if fuzzy_match and applied_patches is not None: + applied_patches.add(fuzzy_match) if patch_ref: latest_commit = self._used_scm.apply_patch_ref( patch_repo, patch_ref, target_branch, options, file_list) @@ -2000,6 +2003,7 @@ it or fix the checkout. patch_refs = {} target_branches = {} skip_sync_revisions = {} + applied_patches = set() # It's unnecessary to check for revision overrides for 'recurse'. # Save a few seconds by not calling _EnforceRevisions() in that case. if command not in ('diff', 'recurse', 'runhooks', 'status', 'revert', @@ -2044,13 +2048,14 @@ it or fix the checkout. options=self._options, patch_refs=patch_refs, target_branches=target_branches, - skip_sync_revisions=skip_sync_revisions) + skip_sync_revisions=skip_sync_revisions, + applied_patches=applied_patches) if revision_overrides: print('Please fix your script, having invalid --revision flags will soon ' 'be considered an error.', file=sys.stderr) - if patch_refs: + if patch_refs.keys() != applied_patches: raise gclient_utils.Error( 'The following --patch-ref flags were not used. Please fix it:\n%s' % ('\n'.join( @@ -2248,8 +2253,16 @@ class CipdDependency(Dependency): self._package_version = version #override - def run(self, revision_overrides, command, args, work_queue, options, - patch_refs, target_branches, skip_sync_revisions): + def run(self, + revision_overrides, + command, + args, + work_queue, + options, + patch_refs, + target_branches, + skip_sync_revisions, + applied_patches=None): """Runs |command| then parse the DEPS file.""" logging.info('CipdDependency(%s).run()' % self.name) if not self.should_process: