Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 25259:5b05f10c5024
revert: fix edition of newly added file during --interactive
Before this patch: editing hunks of newly added file when performing a revert
--interactive had no effect: the edits were discarded.
After this patch, the edits are taken into account.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Thu, 21 May 2015 14:34:24 -0700 |
parents | f37a69ec3f47 |
children | 1b1eaf1885df |
comparison
equal
deleted
inserted
replaced
25258:f37a69ec3f47 | 25259:5b05f10c5024 |
---|---|
3121 if p2 != nullid: | 3121 if p2 != nullid: |
3122 normal = repo.dirstate.normallookup | 3122 normal = repo.dirstate.normallookup |
3123 else: | 3123 else: |
3124 normal = repo.dirstate.normal | 3124 normal = repo.dirstate.normal |
3125 | 3125 |
3126 newlyaddedandmodifiedfiles = set() | |
3126 if interactive: | 3127 if interactive: |
3127 # Prompt the user for changes to revert | 3128 # Prompt the user for changes to revert |
3128 torevert = [repo.wjoin(f) for f in actions['revert'][0]] | 3129 torevert = [repo.wjoin(f) for f in actions['revert'][0]] |
3129 m = scmutil.match(ctx, torevert, {}) | 3130 m = scmutil.match(ctx, torevert, {}) |
3130 diffopts = patch.difffeatureopts(repo.ui, whitespace=True) | 3131 diffopts = patch.difffeatureopts(repo.ui, whitespace=True) |
3135 try: | 3136 try: |
3136 chunks = recordfilter(repo.ui, originalchunks) | 3137 chunks = recordfilter(repo.ui, originalchunks) |
3137 except patch.PatchError, err: | 3138 except patch.PatchError, err: |
3138 raise util.Abort(_('error parsing patch: %s') % err) | 3139 raise util.Abort(_('error parsing patch: %s') % err) |
3139 | 3140 |
3141 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) | |
3140 # Apply changes | 3142 # Apply changes |
3141 fp = cStringIO.StringIO() | 3143 fp = cStringIO.StringIO() |
3142 for c in chunks: | 3144 for c in chunks: |
3143 c.write(fp) | 3145 c.write(fp) |
3144 dopatch = fp.tell() | 3146 dopatch = fp.tell() |
3158 # changes may be overlooked without normallookup, | 3160 # changes may be overlooked without normallookup, |
3159 # if size isn't changed at reverting | 3161 # if size isn't changed at reverting |
3160 repo.dirstate.normallookup(f) | 3162 repo.dirstate.normallookup(f) |
3161 | 3163 |
3162 for f in actions['add'][0]: | 3164 for f in actions['add'][0]: |
3163 checkout(f) | 3165 # Don't checkout modified files, they are already created by the diff |
3164 repo.dirstate.add(f) | 3166 if f not in newlyaddedandmodifiedfiles: |
3167 checkout(f) | |
3168 repo.dirstate.add(f) | |
3165 | 3169 |
3166 normal = repo.dirstate.normallookup | 3170 normal = repo.dirstate.normallookup |
3167 if node == parent and p2 == nullid: | 3171 if node == parent and p2 == nullid: |
3168 normal = repo.dirstate.normal | 3172 normal = repo.dirstate.normal |
3169 for f in actions['undelete'][0]: | 3173 for f in actions['undelete'][0]: |