From f35a9ebe8ad53ecc6fc5f3635586b147acc6a12f Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Thu, 17 Nov 2022 18:34:36 +0000 Subject: [PATCH] Don't prompt unsignificant external changes Description changes shouldn't prompt. Changes like these that don't change code or the merge base won't get overriden anyway. Bug: 1382528 Change-Id: Ie1947a28ea97a8383a791e76738a2ad20c349878 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4033329 Reviewed-by: Aravind Vasudevan Commit-Queue: Gavin Mak --- git_cl.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/git_cl.py b/git_cl.py index 6e07ff878..4b26d5ead 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1913,6 +1913,23 @@ class Changelist(object): self.SetPatchset(patchset) return patchset + def _IsPatchsetRangeSignificant(self, lower, upper): + """Returns True if the inclusive range of patchsets contains any reworks or + rebases.""" + if not self.GetIssue(): + return False + + data = self._GetChangeDetail(['ALL_REVISIONS']) + ps_kind = {} + for rev_info in data.get('revisions', {}).values(): + ps_kind[rev_info['_number']] = rev_info.get('kind', '') + + for ps in range(lower, upper + 1): + assert ps in ps_kind, 'expected patchset %d in change detail' % ps + if ps_kind[ps] not in ('NO_CHANGE', 'NO_CODE_CHANGE'): + return True + return False + def GetMostRecentDryRunPatchset(self): """Get patchsets equivalent to the most recent patchset and return the patchset with the latest dry run. If none have been dry run, return @@ -2739,7 +2756,8 @@ class Changelist(object): return external_ps = self.GetMostRecentPatchset(update=False) - if external_ps is None or local_ps == external_ps: + if external_ps is None or local_ps == external_ps or \ + not self._IsPatchsetRangeSignificant(local_ps + 1, external_ps): return num_changes = external_ps - local_ps