| 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()
|
|
|