[stacked_changes] Add Changelist._PrepareChange() common func called before creating commits.
Bug: b/265929888
Change-Id: I18a0c5ba6757aef91e750b9703079c96b090dc1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4178920
Commit-Queue: Joanna Wang <jojwang@chromium.org>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
diff --git a/scm.py b/scm.py
index 4013a76..dce9ef7 100644
--- a/scm.py
+++ b/scm.py
@@ -119,16 +119,22 @@
return output.strip() if strip_out else output
@staticmethod
- def CaptureStatus(cwd, upstream_branch):
+ def CaptureStatus(cwd, upstream_branch, end_commit=None):
+ # type: (str, str, Optional[str]) -> Sequence[Tuple[str, str]]
"""Returns git status.
Returns an array of (status, file) tuples."""
+ if end_commit is None:
+ end_commit = ''
if upstream_branch is None:
upstream_branch = GIT.GetUpstreamBranch(cwd)
if upstream_branch is None:
raise gclient_utils.Error('Cannot determine upstream branch')
- command = ['-c', 'core.quotePath=false', 'diff',
- '--name-status', '--no-renames', '-r', '%s...' % upstream_branch]
+ command = [
+ '-c', 'core.quotePath=false', 'diff', '--name-status', '--no-renames',
+ '-r',
+ '%s...%s' % (upstream_branch, end_commit)
+ ]
status = GIT.Capture(command, cwd)
results = []
if status: