Commit 3bbf2943 authored by maruel@chromium.org's avatar maruel@chromium.org

Cache diff to speed up when the diff is processed multiple times

R=dpranke@chromium.org
BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@117040 0039d316-1c4b-4281-b951-d872f2087c98
parent 18878421
#!/usr/bin/env python #!/usr/bin/env python
# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
...@@ -558,6 +558,7 @@ class SvnAffectedFile(AffectedFile): ...@@ -558,6 +558,7 @@ class SvnAffectedFile(AffectedFile):
AffectedFile.__init__(self, *args, **kwargs) AffectedFile.__init__(self, *args, **kwargs)
self._server_path = None self._server_path = None
self._is_text_file = None self._is_text_file = None
self._diff = None
def ServerPath(self): def ServerPath(self):
if self._server_path is None: if self._server_path is None:
...@@ -598,8 +599,10 @@ class SvnAffectedFile(AffectedFile): ...@@ -598,8 +599,10 @@ class SvnAffectedFile(AffectedFile):
return self._is_text_file return self._is_text_file
def GenerateScmDiff(self): def GenerateScmDiff(self):
return scm.SVN.GenerateDiff( if self._diff is None:
[self.LocalPath()], self._local_root, False, None) self._diff = scm.SVN.GenerateDiff(
[self.LocalPath()], self._local_root, False, None)
return self._diff
class GitAffectedFile(AffectedFile): class GitAffectedFile(AffectedFile):
...@@ -611,6 +614,7 @@ class GitAffectedFile(AffectedFile): ...@@ -611,6 +614,7 @@ class GitAffectedFile(AffectedFile):
AffectedFile.__init__(self, *args, **kwargs) AffectedFile.__init__(self, *args, **kwargs)
self._server_path = None self._server_path = None
self._is_text_file = None self._is_text_file = None
self._diff = None
def ServerPath(self): def ServerPath(self):
if self._server_path is None: if self._server_path is None:
...@@ -645,7 +649,10 @@ class GitAffectedFile(AffectedFile): ...@@ -645,7 +649,10 @@ class GitAffectedFile(AffectedFile):
return self._is_text_file return self._is_text_file
def GenerateScmDiff(self): def GenerateScmDiff(self):
return scm.GIT.GenerateDiff(self._local_root, files=[self.LocalPath(),]) if self._diff is None:
self._diff = scm.GIT.GenerateDiff(
self._local_root, files=[self.LocalPath(),])
return self._diff
class Change(object): class Change(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment