def getstablerev(repo, subset, x): """Returns the "stable" revision. The script to run is set via config:: [stablerev] script = scripts/get_stable_rev.py The revset takes an optional "target" argument that is passed to the script (as `--target $TARGET`). This argumement can be made `optional`, `required`, or `forbidden`:: [stablerev] targetarg = forbidden The revset can automatically pull if the returned commit doesn't exist locally:: [stablerev] pullonmissing = False """ ui = repo.ui target = None args = getargsdict(x, "getstablerev", "target") if "target" in args: target = getstring(args["target"], _("target argument must be a string")) _validatetarget(ui, target) revspec = _executeandparse(ui, repo, target) trypull = ui.configbool("stablerev", "pullonmissing", False) commitctx = _lookup(ui, repo, revspec, trypull=trypull) return subset & baseset([commitctx.rev()])
def _localbranch(repo, subset, x): """``_localbranch(changectx)`` localbranch changesets Returns all commits within the same localbranch as the changeset(s). A local branch is all draft changesets that are connected, uninterupted by public changesets. Any draft commit within a branch, or a public commit at the base of the branch, can be used to identify localbranches. """ # executed on an filtered repo args = revset.getargsdict(x, "branchrevset", "changectx") revstring = revsetlang.getstring( args.get("changectx"), _("localbranch argument must be a changectx")) revs = repo.revs(revstring) # we assume that there is only a single rev if repo[revs.first()].phase() == phases.public: querystring = revsetlang.formatspec("(children(%d) & draft())::", revs.first()) else: querystring = revsetlang.formatspec("((::%ld) & draft())::", revs) return subset & smartset.baseset(repo.revs(querystring))
def _getargumentornone(x): try: return getstring(x, _("must pass a target")) except error.ParseError: return None