Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 35163:ee64e677c3cf
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 30 Nov 2017 15:48:42 -0500 |
parents | 3da4bd50103d 691524f0bbf6 |
children | 5cc14407a739 |
comparison
equal
deleted
inserted
replaced
35162:bdd2e18b54c5 | 35163:ee64e677c3cf |
---|---|
3164 if (opts.get('addremove') | 3164 if (opts.get('addremove') |
3165 and scmutil.addremove(repo, matcher, "", opts)): | 3165 and scmutil.addremove(repo, matcher, "", opts)): |
3166 raise error.Abort( | 3166 raise error.Abort( |
3167 _("failed to mark all new/missing files as added/removed")) | 3167 _("failed to mark all new/missing files as added/removed")) |
3168 | 3168 |
3169 # Check subrepos. This depends on in-place wctx._status update in | |
3170 # subrepo.precommit(). To minimize the risk of this hack, we do | |
3171 # nothing if .hgsub does not exist. | |
3172 if '.hgsub' in wctx or '.hgsub' in old: | |
3173 from . import subrepo # avoid cycle: cmdutil -> subrepo -> cmdutil | |
3174 subs, commitsubs, newsubstate = subrepo.precommit( | |
3175 ui, wctx, wctx._status, matcher) | |
3176 # amend should abort if commitsubrepos is enabled | |
3177 assert not commitsubs | |
3178 if subs: | |
3179 subrepo.writestate(repo, newsubstate) | |
3180 | |
3169 filestoamend = set(f for f in wctx.files() if matcher(f)) | 3181 filestoamend = set(f for f in wctx.files() if matcher(f)) |
3170 | 3182 |
3171 changes = (len(filestoamend) > 0) | 3183 changes = (len(filestoamend) > 0) |
3172 if changes: | 3184 if changes: |
3173 # Recompute copies (avoid recording a -> b -> a) | 3185 # Recompute copies (avoid recording a -> b -> a) |
3177 | 3189 |
3178 # Prune files which were reverted by the updates: if old | 3190 # Prune files which were reverted by the updates: if old |
3179 # introduced file X and the file was renamed in the working | 3191 # introduced file X and the file was renamed in the working |
3180 # copy, then those two files are the same and | 3192 # copy, then those two files are the same and |
3181 # we can discard X from our list of files. Likewise if X | 3193 # we can discard X from our list of files. Likewise if X |
3182 # was deleted, it's no longer relevant | 3194 # was removed, it's no longer relevant. If X is missing (aka |
3195 # deleted), old X must be preserved. | |
3183 files.update(filestoamend) | 3196 files.update(filestoamend) |
3184 files = [f for f in files if not samefile(f, wctx, base)] | 3197 files = [f for f in files if (not samefile(f, wctx, base) |
3198 or f in wctx.deleted())] | |
3185 | 3199 |
3186 def filectxfn(repo, ctx_, path): | 3200 def filectxfn(repo, ctx_, path): |
3187 try: | 3201 try: |
3188 # If the file being considered is not amongst the files | 3202 # If the file being considered is not amongst the files |
3189 # to be amended, we should return the file context from the | 3203 # to be amended, we should return the file context from the |
3191 # the working copy are being amended but there are also | 3205 # the working copy are being amended but there are also |
3192 # changes to other files from the old changeset. | 3206 # changes to other files from the old changeset. |
3193 if path not in filestoamend: | 3207 if path not in filestoamend: |
3194 return old.filectx(path) | 3208 return old.filectx(path) |
3195 | 3209 |
3210 # Return None for removed files. | |
3211 if path in wctx.removed(): | |
3212 return None | |
3213 | |
3196 fctx = wctx[path] | 3214 fctx = wctx[path] |
3197 | |
3198 # Return None for removed files. | |
3199 if not fctx.exists(): | |
3200 return None | |
3201 | |
3202 flags = fctx.flags() | 3215 flags = fctx.flags() |
3203 mctx = context.memfilectx(repo, | 3216 mctx = context.memfilectx(repo, |
3204 fctx.path(), fctx.data(), | 3217 fctx.path(), fctx.data(), |
3205 islink='l' in flags, | 3218 islink='l' in flags, |
3206 isexec='x' in flags, | 3219 isexec='x' in flags, |