4504 @command('resolve', |
4504 @command('resolve', |
4505 [('a', 'all', None, _('select all unresolved files')), |
4505 [('a', 'all', None, _('select all unresolved files')), |
4506 ('l', 'list', None, _('list state of files needing merge')), |
4506 ('l', 'list', None, _('list state of files needing merge')), |
4507 ('m', 'mark', None, _('mark files as resolved')), |
4507 ('m', 'mark', None, _('mark files as resolved')), |
4508 ('u', 'unmark', None, _('mark files as unresolved')), |
4508 ('u', 'unmark', None, _('mark files as unresolved')), |
4509 ('n', 'no-status', None, _('hide status prefix'))] |
4509 ('n', 'no-status', None, _('hide status prefix')), |
|
4510 ('', 're-merge', None, _('re-merge files'))] |
4510 + mergetoolopts + walkopts + formatteropts, |
4511 + mergetoolopts + walkopts + formatteropts, |
4511 _('[OPTION]... [FILE]...'), |
4512 _('[OPTION]... [FILE]...'), |
4512 inferrepo=True) |
4513 inferrepo=True) |
4513 def resolve(ui, repo, *pats, **opts): |
4514 def resolve(ui, repo, *pats, **opts): |
4514 """redo merges or set/view the merge status of files |
4515 """redo merges or set/view the merge status of files |
4521 working directory must have two parents). See :hg:`help |
4522 working directory must have two parents). See :hg:`help |
4522 merge-tools` for information on configuring merge tools. |
4523 merge-tools` for information on configuring merge tools. |
4523 |
4524 |
4524 The resolve command can be used in the following ways: |
4525 The resolve command can be used in the following ways: |
4525 |
4526 |
4526 - :hg:`resolve [--tool TOOL] FILE...`: attempt to re-merge the specified |
4527 - :hg:`resolve [--re-merge] [--tool TOOL] FILE...`: attempt to re-merge |
4527 files, discarding any previous merge attempts. Re-merging is not |
4528 the specified files, discarding any previous merge attempts. Re-merging |
4528 performed for files already marked as resolved. Use ``--all/-a`` |
4529 is not performed for files already marked as resolved. Use ``--all/-a`` |
4529 to select all unresolved files. ``--tool`` can be used to specify |
4530 to select all unresolved files. ``--tool`` can be used to specify |
4530 the merge tool used for the given files. It overrides the HGMERGE |
4531 the merge tool used for the given files. It overrides the HGMERGE |
4531 environment variable and your configuration files. Previous file |
4532 environment variable and your configuration files. Previous file |
4532 contents are saved with a ``.orig`` suffix. |
4533 contents are saved with a ``.orig`` suffix. |
4533 |
4534 |
4552 Returns 0 on success, 1 if any files fail a resolve attempt. |
4553 Returns 0 on success, 1 if any files fail a resolve attempt. |
4553 """ |
4554 """ |
4554 |
4555 |
4555 opts = pycompat.byteskwargs(opts) |
4556 opts = pycompat.byteskwargs(opts) |
4556 confirm = ui.configbool('commands', 'resolve.confirm') |
4557 confirm = ui.configbool('commands', 'resolve.confirm') |
4557 flaglist = 'all mark unmark list no_status'.split() |
4558 flaglist = 'all mark unmark list no_status re_merge'.split() |
4558 all, mark, unmark, show, nostatus = \ |
4559 all, mark, unmark, show, nostatus, remerge = \ |
4559 [opts.get(o) for o in flaglist] |
4560 [opts.get(o) for o in flaglist] |
4560 |
4561 |
4561 if len(list(filter(None, [show, mark, unmark]))) > 1: |
4562 if len(list(filter(None, [show, mark, unmark, remerge]))) > 1: |
4562 raise error.Abort(_("too many options specified")) |
4563 raise error.Abort(_("too many options specified")) |
4563 if pats and all: |
4564 if pats and all: |
4564 raise error.Abort(_("can't specify --all and patterns")) |
4565 raise error.Abort(_("can't specify --all and patterns")) |
4565 if not (all or pats or show or mark or unmark): |
4566 if not (all or pats or show or mark or unmark): |
4566 raise error.Abort(_('no files or directories specified'), |
4567 raise error.Abort(_('no files or directories specified'), |
4750 pats = ['path:%s' % p for p in pats] |
4751 pats = ['path:%s' % p for p in pats] |
4751 m = scmutil.match(wctx, pats, opts) |
4752 m = scmutil.match(wctx, pats, opts) |
4752 for f in ms: |
4753 for f in ms: |
4753 if not m(f): |
4754 if not m(f): |
4754 continue |
4755 continue |
4755 flags = ''.join(['-%s ' % o[0:1] for o in flaglist |
4756 def flag(o): |
4756 if opts.get(o)]) |
4757 if o == 're_merge': |
|
4758 return '--re-merge ' |
|
4759 return '-%s ' % o[0:1] |
|
4760 flags = ''.join([flag(o) for o in flaglist if opts.get(o)]) |
4757 hint = _("(try: hg resolve %s%s)\n") % ( |
4761 hint = _("(try: hg resolve %s%s)\n") % ( |
4758 flags, |
4762 flags, |
4759 ' '.join(pats)) |
4763 ' '.join(pats)) |
4760 break |
4764 break |
4761 ui.warn(_("arguments do not match paths that need resolving\n")) |
4765 ui.warn(_("arguments do not match paths that need resolving\n")) |