comparison mercurial/cmdutil.py @ 33617:5ac845ca059a stable

commit: don't let failed commit with --addremove update dirstate (issue5645) Differential Revision: https://phab.mercurial-scm.org/D204
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 31 Jul 2017 14:54:57 -0700
parents 4cd4344a53c4
children 377e8ddaebef 86aca74a063b
comparison
equal deleted inserted replaced
33616:d84da82764e3 33617:5ac845ca059a
24 from . import ( 24 from . import (
25 bookmarks, 25 bookmarks,
26 changelog, 26 changelog,
27 copies, 27 copies,
28 crecord as crecordmod, 28 crecord as crecordmod,
29 dirstateguard,
29 encoding, 30 encoding,
30 error, 31 error,
31 formatter, 32 formatter,
32 graphmod, 33 graphmod,
33 match as matchmod, 34 match as matchmod,
2886 if date: 2887 if date:
2887 opts['date'] = util.parsedate(date) 2888 opts['date'] = util.parsedate(date)
2888 message = logmessage(ui, opts) 2889 message = logmessage(ui, opts)
2889 matcher = scmutil.match(repo[None], pats, opts) 2890 matcher = scmutil.match(repo[None], pats, opts)
2890 2891
2892 dsguard = None
2891 # extract addremove carefully -- this function can be called from a command 2893 # extract addremove carefully -- this function can be called from a command
2892 # that doesn't support addremove 2894 # that doesn't support addremove
2893 if opts.get('addremove'): 2895 try:
2894 if scmutil.addremove(repo, matcher, "", opts) != 0: 2896 if opts.get('addremove'):
2895 raise error.Abort( 2897 dsguard = dirstateguard.dirstateguard(repo, 'commit')
2896 _("failed to mark all new/missing files as added/removed")) 2898 if scmutil.addremove(repo, matcher, "", opts) != 0:
2897 2899 raise error.Abort(
2898 return commitfunc(ui, repo, message, matcher, opts) 2900 _("failed to mark all new/missing files as added/removed"))
2901
2902 r = commitfunc(ui, repo, message, matcher, opts)
2903 if dsguard:
2904 dsguard.close()
2905 return r
2906 finally:
2907 if dsguard:
2908 dsguard.release()
2899 2909
2900 def samefile(f, ctx1, ctx2): 2910 def samefile(f, ctx1, ctx2):
2901 if f in ctx1.manifest(): 2911 if f in ctx1.manifest():
2902 a = ctx1.filectx(f) 2912 a = ctx1.filectx(f)
2903 if f in ctx2.manifest(): 2913 if f in ctx2.manifest():