Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.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 | f15cb5111a1e |
children | 15e680a44502 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Mar 27 17:21:46 2024 +0000 +++ b/mercurial/cmdutil.py Wed Mar 27 17:29:48 2024 +0000 @@ -4135,3 +4135,46 @@ with repo.wlock(): graftstate = statemod.cmdstate(repo, b'graftstate') return abortgraft(ui, repo, graftstate) + + +def postincoming(ui, repo, modheads, optupdate, checkout, brev): + """Run after a changegroup has been added via pull/unbundle + + This takes arguments below: + + :modheads: change of heads by pull/unbundle + :optupdate: updating working directory is needed or not + :checkout: update destination revision (or None to default destination) + :brev: a name, which might be a bookmark to be activated after updating + + return True if update raise any conflict, False otherwise. + """ + if modheads == 0: + return False + if optupdate: + # avoid circular import + from . import hg + + try: + return hg.updatetotally(ui, repo, checkout, brev) + except error.UpdateAbort as inst: + msg = _(b"not updating: %s") % stringutil.forcebytestr(inst) + hint = inst.hint + raise error.UpdateAbort(msg, hint=hint) + if ui.quiet: + pass # we won't report anything so the other clause are useless. + elif modheads is not None and modheads > 1: + currentbranchheads = len(repo.branchheads()) + if currentbranchheads == modheads: + ui.status( + _(b"(run 'hg heads' to see heads, 'hg merge' to merge)\n") + ) + elif currentbranchheads > 1: + ui.status( + _(b"(run 'hg heads .' to see heads, 'hg merge' to merge)\n") + ) + else: + ui.status(_(b"(run 'hg heads' to see heads)\n")) + elif not ui.configbool(b'commands', b'update.requiredest'): + ui.status(_(b"(run 'hg update' to get a working copy)\n")) + return False