def perftestsuitecmd(ui, repo, *revs, **opts): """Runs an in-depth performance suite and logs results to a metrics framework. The rebase distance is configurable:: [perfsuite] rebase.masterdistance = 100 immrebase.masterdistance = 100 The metrics endpoint is configurable:: [ods] endpoint = https://somehost/metrics """ if opts["seed"]: random.seed(opts["seed"]) if opts["rev"]: ui.status(_("updating to %s...\n") % (opts["rev"])) commands.update(ui, repo, scmutil.revsingle(repo, opts["rev"]).hex()) suite = perftestsuite( repo, publish=opts["publish"], profile=opts["use_profile"], printout=opts["print"], ) suite.run()
def pull(orig, ui, repo, *args, **opts): """pull --rebase/--update are problematic without an explicit destination""" try: rebasemodule = extensions.find("rebase") except KeyError: rebasemodule = None rebase = opts.get("rebase") update = opts.get("update") isrebase = rebase or rebaseflag # Only use from the global rebasedest if _getrebasedest was called. If the # user isn't using remotenames, then rebasedest isn't set. if rebaseflag: dest = rebasedest else: dest = opts.get("dest") if (isrebase or update) and not dest: dest = ui.config("tweakdefaults", "defaultdest") if isrebase and update: mess = _("specify either rebase or update, not both") raise error.Abort(mess) if dest and not (isrebase or update): mess = _("only specify a destination if rebasing or updating") raise error.Abort(mess) if (isrebase or update) and not dest: if isrebase and repo._activebookmark: mess = ui.config("tweakdefaults", "bmnodestmsg") hint = ui.config("tweakdefaults", "bmnodesthint") elif isrebase: mess = ui.config("tweakdefaults", "nodestmsg") hint = ui.config("tweakdefaults", "nodesthint") else: # update mess = _("you must specify a destination for the update") hint = _("use `hg pull --update --dest <destination>`") raise error.Abort(mess, hint=hint) if "rebase" in opts: del opts["rebase"] tool = opts.pop("tool", "") if "update" in opts: del opts["update"] if "dest" in opts: del opts["dest"] ret = orig(ui, repo, *args, **opts) # NB: we use rebase and not isrebase on the next line because # remotenames may have already handled the rebase. if dest and rebase: ret = ret or rebaseorfastforward( rebasemodule.rebase, ui, repo, dest=dest, tool=tool ) if dest and update: ret = ret or commands.update(ui, repo, node=dest, check=True) return ret
def _moverelative(ui, repo, args, opts, reverse=False): """Update to a changeset relative to the current changeset. Implements both `hg previous` and `hg next`. Takes in a list of positional arguments and a dict of command line options. (See help for `hg previous` and `hg next` to see which arguments and flags are supported.) Moves forward through history by default -- the behavior of `hg next`. Setting reverse=True will change the behavior to that of `hg previous`. """ # Parse positional argument. try: n = int(args[0]) if args else 1 except ValueError: raise error.Abort(_("argument must be an integer")) if n <= 0: return if ui.configbool("amend", "alwaysnewest"): opts["newest"] = True # Check that the given combination of arguments is valid. if args: if opts.get("bookmark", False): raise error.Abort(_("cannot use both number and --bookmark")) if opts.get("top", False): raise error.Abort(_("cannot use both number and --top")) if opts.get("bottom", False): raise error.Abort(_("cannot use both number and --bottom")) if opts.get("bookmark", False): if opts.get("top", False): raise error.Abort(_("cannot use both --top and --bookmark")) if opts.get("bottom", False): raise error.Abort(_("cannot use both --bottom and --bookmark")) if opts.get("towards", False) and opts.get("top", False): raise error.Abort(_("cannot use both --top and --towards")) if opts.get("merge", False) and opts.get("rebase", False): raise error.Abort(_("cannot use both --merge and --rebase")) # Check if there is an outstanding operation or uncommited changes. cmdutil.checkunfinished(repo) if not opts.get("clean", False) and not opts.get("merge", False): try: cmdutil.bailifchanged(repo) except error.Abort as e: e.hint = _("use --clean to discard uncommitted changes " "or --merge to bring them along") raise # If we have both --clean and --rebase, we need to discard any outstanding # changes now before we attempt to perform any rebases. if opts.get("clean") and opts.get("rebase"): commands.update(ui, repo, rev=repo["."].hex(), clean=True) with repo.wlock(), repo.lock(): # Record the active bookmark, if any. bookmark = repo._activebookmark noactivate = opts.get("no_activate_bookmark", False) movebookmark = opts.get("move_bookmark", False) with repo.transaction("moverelative") as tr: # Find the desired changeset. May potentially perform rebase. try: target = _findtarget(ui, repo, n, opts, reverse) except error.InterventionRequired: # Rebase failed. Need to manually close transaction to allow # `hg rebase --continue` to work correctly. tr.close() raise # Move the active bookmark if necessary. Needs to happen before # we update to avoid getting a 'leaving bookmark X' message. if movebookmark and bookmark is not None: _setbookmark(repo, tr, bookmark, target) # Update to the target changeset. commands.update( ui, repo, rev=hex(target), clean=opts.get("clean", False), merge=opts.get("merge", False), ) # Print out the changeset we landed on. _showchangesets(ui, repo, nodes=[target]) # Activate the bookmark on the new changeset. if not noactivate and not movebookmark: _activate(ui, repo, target)