Add full_move flag to GIT.GenerateDiff and Factor out FindGclientRootDir into gclient_utils.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/501171
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@35154 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/scm.py b/scm.py
index 2e13555..db4711e 100644
--- a/scm.py
+++ b/scm.py
@@ -177,12 +177,17 @@
return upstream_branch
@staticmethod
- def GenerateDiff(cwd, branch=None):
- """Diffs against the upstream branch or optionally another branch."""
+ def GenerateDiff(cwd, branch=None, full_move=False):
+ """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)
- diff = GIT.Capture(['diff-tree', '-p', '--no-prefix', branch, 'HEAD'],
- cwd).splitlines(True)
+ command = ['diff-tree', '-p', '--no-prefix', branch, 'HEAD']
+ if not full_move:
+ command.append('-C')
+ 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
# file being added.
@@ -524,7 +529,9 @@
"""Diffs a single file.
Be sure to be in the appropriate directory before calling to have the
- expected relative path."""
+ expected relative path.
+ 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."""
# Use svn info output instead of os.path.isdir because the latter fails
# when the file is deleted.
if SVN.CaptureInfo(filename).get("Node Kind") == "directory":