##// END OF EJS Templates
context: add a fast-comparision for arbitraryfilectx and workingfilectx...
Phil Cohen -
r34686:6036e6e2 default
parent child Browse files
Show More
@@ -8,6 +8,7 b''
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import errno
10 import errno
11 import filecmp
11 import os
12 import os
12 import re
13 import re
13 import stat
14 import stat
@@ -2554,11 +2555,17 b' class arbitraryfilectx(object):'
2554 """Allows you to use filectx-like functions on a file in an arbitrary
2555 """Allows you to use filectx-like functions on a file in an arbitrary
2555 location on disk, possibly not in the working directory.
2556 location on disk, possibly not in the working directory.
2556 """
2557 """
2557 def __init__(self, path):
2558 def __init__(self, path, repo=None):
2559 # Repo is optional because contrib/simplemerge uses this class.
2560 self._repo = repo
2558 self._path = path
2561 self._path = path
2559
2562
2560 def cmp(self, otherfilectx):
2563 def cmp(self, fctx):
2561 return self.data() != otherfilectx.data()
2564 if isinstance(fctx, workingfilectx) and self._repo:
2565 # Add a fast-path for merge if both sides are disk-backed.
2566 # Note that filecmp uses the opposite return values as cmp.
2567 return not filecmp.cmp(self.path(), self._repo.wjoin(fctx.path()))
2568 return self.data() != fctx.data()
2562
2569
2563 def path(self):
2570 def path(self):
2564 return self._path
2571 return self._path
General Comments 0
You need to be logged in to leave comments. Login now