comparison mercurial/commands.py @ 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 17da326fd041
children db2392a4effc
comparison
equal deleted inserted replaced
21708:2668a78df8ba 21709:14560418856d
4925 raise util.Abort(_("can't specify --all and patterns")) 4925 raise util.Abort(_("can't specify --all and patterns"))
4926 if not (all or pats or show or mark or unmark): 4926 if not (all or pats or show or mark or unmark):
4927 raise util.Abort(_('no files or directories specified; ' 4927 raise util.Abort(_('no files or directories specified; '
4928 'use --all to remerge all files')) 4928 'use --all to remerge all files'))
4929 4929
4930 ms = mergemod.mergestate(repo) 4930 wlock = repo.wlock()
4931 m = scmutil.match(repo[None], pats, opts) 4931 try:
4932 ret = 0 4932 ms = mergemod.mergestate(repo)
4933 4933 m = scmutil.match(repo[None], pats, opts)
4934 for f in ms: 4934 ret = 0
4935 if m(f): 4935
4936 if show: 4936 for f in ms:
4937 if nostatus: 4937 if m(f):
4938 ui.write("%s\n" % f) 4938 if show:
4939 if nostatus:
4940 ui.write("%s\n" % f)
4941 else:
4942 ui.write("%s %s\n" % (ms[f].upper(), f),
4943 label='resolve.' +
4944 {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
4945 elif mark:
4946 ms.mark(f, "r")
4947 elif unmark:
4948 ms.mark(f, "u")
4939 else: 4949 else:
4940 ui.write("%s %s\n" % (ms[f].upper(), f), 4950 wctx = repo[None]
4941 label='resolve.' + 4951
4942 {'u': 'unresolved', 'r': 'resolved'}[ms[f]]) 4952 # backup pre-resolve (merge uses .orig for its own purposes)
4943 elif mark: 4953 a = repo.wjoin(f)
4944 ms.mark(f, "r") 4954 util.copyfile(a, a + ".resolve")
4945 elif unmark: 4955
4946 ms.mark(f, "u") 4956 try:
4947 else: 4957 # resolve file
4948 wctx = repo[None] 4958 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
4949 4959 'resolve')
4950 # backup pre-resolve (merge uses .orig for its own purposes) 4960 if ms.resolve(f, wctx):
4951 a = repo.wjoin(f) 4961 ret = 1
4952 util.copyfile(a, a + ".resolve") 4962 finally:
4953 4963 ui.setconfig('ui', 'forcemerge', '', 'resolve')
4954 try: 4964 ms.commit()
4955 # resolve file 4965
4956 ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 4966 # replace filemerge's .orig file with our resolve file
4957 'resolve') 4967 util.rename(a + ".resolve", a + ".orig")
4958 if ms.resolve(f, wctx): 4968
4959 ret = 1 4969 ms.commit()
4960 finally: 4970 finally:
4961 ui.setconfig('ui', 'forcemerge', '', 'resolve') 4971 wlock.release()
4962 ms.commit() 4972
4963
4964 # replace filemerge's .orig file with our resolve file
4965 util.rename(a + ".resolve", a + ".orig")
4966
4967 ms.commit()
4968 return ret 4973 return ret
4969 4974
4970 @command('revert', 4975 @command('revert',
4971 [('a', 'all', None, _('revert all changes when no arguments given')), 4976 [('a', 'all', None, _('revert all changes when no arguments given')),
4972 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')), 4977 ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),