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

Unified Diff: scm.py

Issue 543012: Add the capability to filter out files on try job with regexp. (Closed)
Patch Set: Created 10 years, 11 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') | trychange.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index 7a6f66422e7781cb7e6f05a460b4f9c5206283ea..0fc5cbae7a470bd2faff04fcb5e626a560de111a 100644
--- a/scm.py
+++ b/scm.py
@@ -230,16 +230,21 @@ class GIT(object):
return upstream_branch
@staticmethod
- def GenerateDiff(cwd, branch=None, full_move=False):
+ def GenerateDiff(cwd, branch=None, branch_head='HEAD', full_move=False,
+ files=None):
"""Diffs against the upstream branch or optionally another branch.
full_move means that move or copy operations should completely recreate the
files, usually in the prospect to apply the patch for a try job."""
if not branch:
branch = GIT.GetUpstream(cwd)
- command = ['diff-tree', '-p', '--no-prefix', branch, 'HEAD']
+ command = ['diff-tree', '-p', '--no-prefix', branch, branch_head]
if not full_move:
command.append('-C')
+ # TODO(maruel): --binary support.
+ if files:
+ command.append('--')
+ command.extend(files)
diff = GIT.Capture(command, cwd).splitlines(True)
for i in range(len(diff)):
# In the case of added files, replace /dev/null with the path to the
@@ -249,6 +254,14 @@ class GIT(object):
return ''.join(diff)
@staticmethod
+ def GetDifferentFiles(cwd, branch=None, branch_head='HEAD'):
+ """Returns the list of modified files between two branches."""
+ if not branch:
+ branch = GIT.GetUpstream(cwd)
+ command = ['diff', '--name-only', branch, branch_head]
+ return GIT.Capture(command, cwd).splitlines(False)
+
+ @staticmethod
def GetPatchName(cwd):
"""Constructs a name for this patch."""
short_sha = GIT.Capture(['rev-parse', '--short=4', 'HEAD'], cwd).strip()
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | trychange.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698