Mercurial > hg
changeset 21709:14560418856d stable
resolve: keep wlock while resolving
This will make resolve use correct locking and thus make it more safe.
Resolve is usually a long running command spending a lot of time waiting for
user input on hard problems. It is thus a real world scenario to start multiple
resolves at once or run other commands (such as up -C and merge) while resolve
is running. Proper locking prevents that.
author | Mads Kiilerich <madski at unity3d.com> |
---|---|
date | Mon, 26 May 2014 19:02:11 +0200 |
parents | 2668a78df8ba |
children | db2392a4effc 8da100383dc3 |
files | mercurial/commands.py |
diffstat | 1 files changed, 42 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu Jun 05 16:47:14 2014 +0900 +++ b/mercurial/commands.py Mon May 26 19:02:11 2014 +0200 @@ -4927,44 +4927,49 @@ raise util.Abort(_('no files or directories specified; ' 'use --all to remerge all files')) - ms = mergemod.mergestate(repo) - m = scmutil.match(repo[None], pats, opts) - ret = 0 - - for f in ms: - if m(f): - if show: - if nostatus: - ui.write("%s\n" % f) + wlock = repo.wlock() + try: + ms = mergemod.mergestate(repo) + m = scmutil.match(repo[None], pats, opts) + ret = 0 + + for f in ms: + if m(f): + if show: + if nostatus: + ui.write("%s\n" % f) + else: + ui.write("%s %s\n" % (ms[f].upper(), f), + label='resolve.' + + {'u': 'unresolved', 'r': 'resolved'}[ms[f]]) + elif mark: + ms.mark(f, "r") + elif unmark: + ms.mark(f, "u") else: - ui.write("%s %s\n" % (ms[f].upper(), f), - label='resolve.' + - {'u': 'unresolved', 'r': 'resolved'}[ms[f]]) - elif mark: - ms.mark(f, "r") - elif unmark: - ms.mark(f, "u") - else: - wctx = repo[None] - - # backup pre-resolve (merge uses .orig for its own purposes) - a = repo.wjoin(f) - util.copyfile(a, a + ".resolve") - - try: - # resolve file - ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), - 'resolve') - if ms.resolve(f, wctx): - ret = 1 - finally: - ui.setconfig('ui', 'forcemerge', '', 'resolve') - ms.commit() - - # replace filemerge's .orig file with our resolve file - util.rename(a + ".resolve", a + ".orig") - - ms.commit() + wctx = repo[None] + + # backup pre-resolve (merge uses .orig for its own purposes) + a = repo.wjoin(f) + util.copyfile(a, a + ".resolve") + + try: + # resolve file + ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), + 'resolve') + if ms.resolve(f, wctx): + ret = 1 + finally: + ui.setconfig('ui', 'forcemerge', '', 'resolve') + ms.commit() + + # replace filemerge's .orig file with our resolve file + util.rename(a + ".resolve", a + ".orig") + + ms.commit() + finally: + wlock.release() + return ret @command('revert',