Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.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 | edf907bd8144 |
children | 8133494accf1 |
comparison
equal
deleted
inserted
replaced
24842:ca1ad8ef38be | 24843:21b33f0460e0 |
---|---|
3064 """ | 3064 """ |
3065 parent, p2 = parents | 3065 parent, p2 = parents |
3066 node = ctx.node() | 3066 node = ctx.node() |
3067 def checkout(f): | 3067 def checkout(f): |
3068 fc = ctx[f] | 3068 fc = ctx[f] |
3069 repo.wwrite(f, fc.data(), fc.flags()) | 3069 return repo.wwrite(f, fc.data(), fc.flags()) |
3070 | 3070 |
3071 audit_path = pathutil.pathauditor(repo.root) | 3071 audit_path = pathutil.pathauditor(repo.root) |
3072 for f in actions['forget'][0]: | 3072 for f in actions['forget'][0]: |
3073 repo.dirstate.drop(f) | 3073 repo.dirstate.drop(f) |
3074 for f in actions['remove'][0]: | 3074 for f in actions['remove'][0]: |
3112 except patch.PatchError, err: | 3112 except patch.PatchError, err: |
3113 raise util.Abort(str(err)) | 3113 raise util.Abort(str(err)) |
3114 del fp | 3114 del fp |
3115 else: | 3115 else: |
3116 for f in actions['revert'][0]: | 3116 for f in actions['revert'][0]: |
3117 checkout(f) | 3117 wsize = checkout(f) |
3118 if normal: | 3118 if normal: |
3119 normal(f) | 3119 normal(f) |
3120 elif wsize == repo.dirstate._map[f][2]: | |
3121 # changes may be overlooked without normallookup, | |
3122 # if size isn't changed at reverting | |
3123 repo.dirstate.normallookup(f) | |
3120 | 3124 |
3121 for f in actions['add'][0]: | 3125 for f in actions['add'][0]: |
3122 checkout(f) | 3126 checkout(f) |
3123 repo.dirstate.add(f) | 3127 repo.dirstate.add(f) |
3124 | 3128 |