comparison mercurial/context.py @ 11702:eb07fbc21e9c

filectx: use cmp(self, fctx) instead of cmp(self, text) This allows more flexibility in implementation, and in particular, lets the context decide if revision text has to be loaded or not.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Tue, 27 Jul 2010 23:40:46 +0900
parents ce95d8b87d22
children 55a2af02e45c
comparison
equal deleted inserted replaced
11701:84fb29f5e0d2 11702:eb07fbc21e9c
350 def path(self): 350 def path(self):
351 return self._path 351 return self._path
352 def size(self): 352 def size(self):
353 return self._filelog.size(self._filerev) 353 return self._filelog.size(self._filerev)
354 354
355 def cmp(self, text): 355 def cmp(self, fctx):
356 """compare text with stored file revision 356 """compare with other file context
357 357
358 returns True if text is different than what is stored. 358 returns True if different than fctx.
359 """ 359 """
360 return self._filelog.cmp(self._filenode, text) 360 return self._filelog.cmp(self._filenode, fctx.data())
361 361
362 def renamed(self): 362 def renamed(self):
363 """check if file was actually renamed in this changeset revision 363 """check if file was actually renamed in this changeset revision
364 364
365 If rename logged in file revision, we report copy for changeset only 365 If rename logged in file revision, we report copy for changeset only
933 except OSError, err: 933 except OSError, err:
934 if err.errno != errno.ENOENT: 934 if err.errno != errno.ENOENT:
935 raise 935 raise
936 return (t, tz) 936 return (t, tz)
937 937
938 def cmp(self, text): 938 def cmp(self, fctx):
939 """compare text with disk content 939 """compare with other file context
940 940
941 returns True if text is different than what is on disk. 941 returns True if different than fctx.
942 """ 942 """
943 return self._repo.wread(self._path) != text 943 return self._repo.wread(self._path) != fctx.data()
944 944
945 class memctx(object): 945 class memctx(object):
946 """Use memctx to perform in-memory commits via localrepo.commitctx(). 946 """Use memctx to perform in-memory commits via localrepo.commitctx().
947 947
948 Revision information is supplied at initialization time while 948 Revision information is supplied at initialization time while