comparison mercurial/commands.py @ 51592:a151fd01e98c

postincoming: move to cmdutil This looks like a good place for it to live.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 27 Mar 2024 17:29:48 +0000
parents f28d5d68b71a
children 15e680a44502
comparison
equal deleted inserted replaced
51591:f28d5d68b71a 51592:a151fd01e98c
5373 else: 5373 else:
5374 ui.warn(_(b'no phases changed\n')) 5374 ui.warn(_(b'no phases changed\n'))
5375 return ret 5375 return ret
5376 5376
5377 5377
5378 def postincoming(ui, repo, modheads, optupdate, checkout, brev):
5379 """Run after a changegroup has been added via pull/unbundle
5380
5381 This takes arguments below:
5382
5383 :modheads: change of heads by pull/unbundle
5384 :optupdate: updating working directory is needed or not
5385 :checkout: update destination revision (or None to default destination)
5386 :brev: a name, which might be a bookmark to be activated after updating
5387
5388 return True if update raise any conflict, False otherwise.
5389 """
5390 if modheads == 0:
5391 return False
5392 if optupdate:
5393 try:
5394 return hg.updatetotally(ui, repo, checkout, brev)
5395 except error.UpdateAbort as inst:
5396 msg = _(b"not updating: %s") % stringutil.forcebytestr(inst)
5397 hint = inst.hint
5398 raise error.UpdateAbort(msg, hint=hint)
5399 if ui.quiet:
5400 pass # we won't report anything so the other clause are useless.
5401 elif modheads is not None and modheads > 1:
5402 currentbranchheads = len(repo.branchheads())
5403 if currentbranchheads == modheads:
5404 ui.status(
5405 _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n")
5406 )
5407 elif currentbranchheads > 1:
5408 ui.status(
5409 _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n")
5410 )
5411 else:
5412 ui.status(_(b"(run 'hg heads' to see heads)\n"))
5413 elif not ui.configbool(b'commands', b'update.requiredest'):
5414 ui.status(_(b"(run 'hg update' to get a working copy)\n"))
5415 return False
5416
5417
5418 @command( 5378 @command(
5419 b'pull', 5379 b'pull',
5420 [ 5380 [
5421 ( 5381 (
5422 b'u', 5382 b'u',
5608 # XXX path: we are losing the `path` object here. Keeping it 5568 # XXX path: we are losing the `path` object here. Keeping it
5609 # would be valuable. For example as a "variant" as we do 5569 # would be valuable. For example as a "variant" as we do
5610 # for pushes. 5570 # for pushes.
5611 repo._subtoppath = path.loc 5571 repo._subtoppath = path.loc
5612 try: 5572 try:
5613 update_conflict = postincoming( 5573 update_conflict = cmdutil.postincoming(
5614 ui, repo, modheads, opts.get('update'), checkout, brev 5574 ui, repo, modheads, opts.get('update'), checkout, brev
5615 ) 5575 )
5616 except error.FilteredRepoLookupError as exc: 5576 except error.FilteredRepoLookupError as exc:
5617 msg = _(b'cannot update to target: %s') % exc.args[0] 5577 msg = _(b'cannot update to target: %s') % exc.args[0]
5618 exc.args = (msg,) + exc.args[1:] 5578 exc.args = (msg,) + exc.args[1:]
7775 b"information" 7735 b"information"
7776 ), 7736 ),
7777 ) 7737 )
7778 modheads = bundle2.combinechangegroupresults(op) 7738 modheads = bundle2.combinechangegroupresults(op)
7779 7739
7780 if postincoming(ui, repo, modheads, opts.get('update'), None, None): 7740 if cmdutil.postincoming(ui, repo, modheads, opts.get('update'), None, None):
7781 return 1 7741 return 1
7782 else: 7742 else:
7783 return 0 7743 return 0
7784 7744
7785 7745