mercurial/commands.py
changeset 35704 41ef02ba329b
parent 35684 1c929b4942a3
child 35711 35a0f6f31eef
equal deleted inserted replaced
35703:9a50ffd15b25 35704:41ef02ba329b
  3528 @command('^merge',
  3528 @command('^merge',
  3529     [('f', 'force', None,
  3529     [('f', 'force', None,
  3530       _('force a merge including outstanding changes (DEPRECATED)')),
  3530       _('force a merge including outstanding changes (DEPRECATED)')),
  3531     ('r', 'rev', '', _('revision to merge'), _('REV')),
  3531     ('r', 'rev', '', _('revision to merge'), _('REV')),
  3532     ('P', 'preview', None,
  3532     ('P', 'preview', None,
  3533      _('review revisions to merge (no merge is performed)'))
  3533      _('review revisions to merge (no merge is performed)')),
       
  3534     ('', 'abort', None, _('abort the ongoing merge')),
  3534      ] + mergetoolopts,
  3535      ] + mergetoolopts,
  3535     _('[-P] [[-r] REV]'))
  3536     _('[-P] [[-r] REV]'))
  3536 def merge(ui, repo, node=None, **opts):
  3537 def merge(ui, repo, node=None, **opts):
  3537     """merge another revision into working directory
  3538     """merge another revision into working directory
  3538 
  3539 
  3553     head, the other head is merged with by default. Otherwise, an
  3554     head, the other head is merged with by default. Otherwise, an
  3554     explicit revision with which to merge with must be provided.
  3555     explicit revision with which to merge with must be provided.
  3555 
  3556 
  3556     See :hg:`help resolve` for information on handling file conflicts.
  3557     See :hg:`help resolve` for information on handling file conflicts.
  3557 
  3558 
  3558     To undo an uncommitted merge, use :hg:`update --clean .` which
  3559     To undo an uncommitted merge, use :hg:`merge --abort` which
  3559     will check out a clean copy of the original merge parent, losing
  3560     will check out a clean copy of the original merge parent, losing
  3560     all changes.
  3561     all changes.
  3561 
  3562 
  3562     Returns 0 on success, 1 if there are unresolved files.
  3563     Returns 0 on success, 1 if there are unresolved files.
  3563     """
  3564     """
  3564 
  3565 
  3565     opts = pycompat.byteskwargs(opts)
  3566     opts = pycompat.byteskwargs(opts)
       
  3567     abort = opts.get('abort')
       
  3568     if abort and repo.dirstate.p2() == nullid:
       
  3569         cmdutil.wrongtooltocontinue(repo, _('merge'))
       
  3570     if abort:
       
  3571         if node:
       
  3572             raise error.Abort(_("cannot specify a node with --abort"))
       
  3573         if opts.get('rev'):
       
  3574             raise error.Abort(_("cannot specify both --rev and --abort"))
       
  3575         if opts.get('preview'):
       
  3576             raise error.Abort(_("cannot specify --preview with --abort"))
  3566     if opts.get('rev') and node:
  3577     if opts.get('rev') and node:
  3567         raise error.Abort(_("please specify just one revision"))
  3578         raise error.Abort(_("please specify just one revision"))
  3568     if not node:
  3579     if not node:
  3569         node = opts.get('rev')
  3580         node = opts.get('rev')
  3570 
  3581 
  3571     if node:
  3582     if node:
  3572         node = scmutil.revsingle(repo, node).node()
  3583         node = scmutil.revsingle(repo, node).node()
  3573 
  3584 
  3574     if not node:
  3585     if not node and not abort:
  3575         node = repo[destutil.destmerge(repo)].node()
  3586         node = repo[destutil.destmerge(repo)].node()
  3576 
  3587 
  3577     if opts.get('preview'):
  3588     if opts.get('preview'):
  3578         # find nodes that are ancestors of p2 but not of p1
  3589         # find nodes that are ancestors of p2 but not of p1
  3579         p1 = repo.lookup('.')
  3590         p1 = repo.lookup('.')
  3590         # ui.forcemerge is an internal variable, do not document
  3601         # ui.forcemerge is an internal variable, do not document
  3591         repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
  3602         repo.ui.setconfig('ui', 'forcemerge', opts.get('tool', ''), 'merge')
  3592         force = opts.get('force')
  3603         force = opts.get('force')
  3593         labels = ['working copy', 'merge rev']
  3604         labels = ['working copy', 'merge rev']
  3594         return hg.merge(repo, node, force=force, mergeforce=force,
  3605         return hg.merge(repo, node, force=force, mergeforce=force,
  3595                         labels=labels)
  3606                         labels=labels, abort=abort)
  3596     finally:
  3607     finally:
  3597         ui.setconfig('ui', 'forcemerge', '', 'merge')
  3608         ui.setconfig('ui', 'forcemerge', '', 'merge')
  3598 
  3609 
  3599 @command('outgoing|out',
  3610 @command('outgoing|out',
  3600     [('f', 'force', None, _('run even when the destination is unrelated')),
  3611     [('f', 'force', None, _('run even when the destination is unrelated')),