Add the capability to filter out files on try job with regexp.

By default, filters out 'ChangeLog'. A pain directly coming from Webkit.

TEST=none
BUG=none

Review URL: http://codereview.chromium.org/543012

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@36008 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/scm.py b/scm.py
index 7a6f664..0fc5cba 100644
--- a/scm.py
+++ b/scm.py
@@ -230,16 +230,21 @@
     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 @@
     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()