| Index: presubmit_support.py
|
| diff --git a/presubmit_support.py b/presubmit_support.py
|
| index 2b01bc356401cea34d7634b6ab87d3ba120a893b..d8e2c5b79224c487fef697c877c4dcae6cf80264 100755
|
| --- a/presubmit_support.py
|
| +++ b/presubmit_support.py
|
| @@ -508,7 +508,7 @@ class InputApi(object):
|
|
|
| class _DiffCache(object):
|
| """Caches diffs retrieved from a particular SCM."""
|
| - def __init__(self, upstream=None):
|
| + def __init__(self, upstream=None, *args, **kwargs):
|
| """Stores the upstream revision against which all diffs will be computed."""
|
| self._upstream = upstream
|
|
|
| @@ -519,8 +519,8 @@ class _DiffCache(object):
|
|
|
| class _SvnDiffCache(_DiffCache):
|
| """DiffCache implementation for subversion."""
|
| - def __init__(self, *args, **kwargs):
|
| - super(_SvnDiffCache, self).__init__(*args, **kwargs)
|
| + def __init__(self, upstream=None, *args, **kwargs):
|
| + super(_SvnDiffCache, self).__init__(upstream, *args, **kwargs)
|
| self._diffs_by_file = {}
|
|
|
| def GetDiff(self, path, local_root):
|
| @@ -532,20 +532,22 @@ class _SvnDiffCache(_DiffCache):
|
|
|
| class _GitDiffCache(_DiffCache):
|
| """DiffCache implementation for git; gets all file diffs at once."""
|
| - def __init__(self, upstream):
|
| - super(_GitDiffCache, self).__init__(upstream=upstream)
|
| + def __init__(self, upstream=None, *args, **kwargs):
|
| + super(_GitDiffCache, self).__init__(upstream, *args, **kwargs)
|
| self._diffs_by_file = None
|
| + self._local_ref = kwargs.get('local_ref', 'HEAD')
|
|
|
| def GetDiff(self, path, local_root):
|
| if not self._diffs_by_file:
|
| - # Compute a single diff for all files and parse the output; should
|
| - # with git this is much faster than computing one diff for each file.
|
| + # Compute a single diff for all files and parse the output; with git
|
| + # this is much faster than computing one diff for each file.
|
| diffs = {}
|
|
|
| # Don't specify any filenames below, because there are command line length
|
| # limits on some platforms and GenerateDiff would fail.
|
| unified_diff = scm.GIT.GenerateDiff(local_root, files=[], full_move=True,
|
| - branch=self._upstream)
|
| + branch=self._upstream,
|
| + branch_head=self._local_ref)
|
|
|
| # This regex matches the path twice, separated by a space. Note that
|
| # filename itself may contain spaces.
|
| @@ -802,13 +804,14 @@ class Change(object):
|
|
|
| def __init__(
|
| self, name, description, local_root, files, issue, patchset, author,
|
| - upstream=None):
|
| + upstream=None, local_ref='HEAD'):
|
| if files is None:
|
| files = []
|
| self._name = name
|
| # Convert root into an absolute path.
|
| self._local_root = os.path.abspath(local_root)
|
| self._upstream = upstream
|
| + self._local_ref = local_ref
|
| self.issue = issue
|
| self.patchset = patchset
|
| self.author_email = author
|
| @@ -821,7 +824,8 @@ class Change(object):
|
| assert all(
|
| (isinstance(f, (list, tuple)) and len(f) == 2) for f in files), files
|
|
|
| - diff_cache = self._AFFECTED_FILES.DIFF_CACHE(self._upstream)
|
| + diff_cache = self._AFFECTED_FILES.DIFF_CACHE(self._upstream,
|
| + local_ref=self._local_ref)
|
| self._affected_files = [
|
| self._AFFECTED_FILES(path, action.strip(), self._local_root, diff_cache)
|
| for action, path in files
|
|
|