Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 24843:21b33f0460e0 stable
revert: apply normallookup on reverted file if size isn't changed (issue4583)
Before this patch, reverting a file to the revision other than the
parent doesn't update dirstate. This seems to expect that timestamp
and/or size will be changed by reverting.
But if (1) dirstate of file "f" is filled with timestamp before
reverting and (2) size and timestamp of file "f" isn't changed at
reverting, file "f" is recognized as CLEAN unexpectedly.
This patch applies "dirstate.normallookup()" on reverted file, if size
isn't changed.
Making "localrepository.wwrite()" return length of written data is
needed to avoid additional (and redundant) "lstat(2)" on the reverted
file. "filectx.size()" can't be used to know it, because data may be
decoded at being written out.
BTW, interactive reverting may cause similar problem, too. But this
patch doesn't focus on fixing it, because (1) interactive (maybe slow)
reverting changes one (or both) of size/timestamp of reverted files in
many usecases, and (2) changes to fix it seems not suitable for stable
branch.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 24 Apr 2015 23:52:41 +0900 |
parents | 7f9655f37163 |
children | e3a928bd1cd4 00d905a12bb6 |
comparison
equal
deleted
inserted
replaced
24842:ca1ad8ef38be | 24843:21b33f0460e0 |
---|---|
915 else: | 915 else: |
916 data = self.wvfs.read(filename) | 916 data = self.wvfs.read(filename) |
917 return self._filter(self._encodefilterpats, filename, data) | 917 return self._filter(self._encodefilterpats, filename, data) |
918 | 918 |
919 def wwrite(self, filename, data, flags): | 919 def wwrite(self, filename, data, flags): |
920 """write ``data`` into ``filename`` in the working directory | |
921 | |
922 This returns length of written (maybe decoded) data. | |
923 """ | |
920 data = self._filter(self._decodefilterpats, filename, data) | 924 data = self._filter(self._decodefilterpats, filename, data) |
921 if 'l' in flags: | 925 if 'l' in flags: |
922 self.wvfs.symlink(data, filename) | 926 self.wvfs.symlink(data, filename) |
923 else: | 927 else: |
924 self.wvfs.write(filename, data) | 928 self.wvfs.write(filename, data) |
925 if 'x' in flags: | 929 if 'x' in flags: |
926 self.wvfs.setflags(filename, False, True) | 930 self.wvfs.setflags(filename, False, True) |
931 return len(data) | |
927 | 932 |
928 def wwritedata(self, filename, data): | 933 def wwritedata(self, filename, data): |
929 return self._filter(self._decodefilterpats, filename, data) | 934 return self._filter(self._decodefilterpats, filename, data) |
930 | 935 |
931 def currenttransaction(self): | 936 def currenttransaction(self): |