tests/printrevset.py
author Gregory Szorc <gregory.szorc@gmail.com>
Sun, 28 Jul 2019 18:32:31 -0700
branchstable
changeset 42661 e91930d712e8
parent 39058 a271466cb53a
child 43076 2372284d9457
permissions -rw-r--r--
automation: execute powershell when connecting For some reason, the ability to execute PS scripts appears to come online after the ability to execute regular command scripts. This is creating race conditions when connecting to instances resulting in our wait_for_winrm() returning before PS is available leading to an exception being thrown in other code. Let's change the client connection code to execute a minimal PS script so we can try to trap the exception in wait_for_winrm().

from __future__ import absolute_import
from mercurial import (
  cmdutil,
  commands,
  extensions,
  logcmdutil,
  revsetlang,
  smartset,
)

from mercurial.utils import (
  stringutil,
)

def logrevset(repo, pats, opts):
    revs = logcmdutil._initialrevs(repo, opts)
    if not revs:
        return None
    match, pats, slowpath = logcmdutil._makematcher(repo, revs, pats, opts)
    return logcmdutil._makerevset(repo, match, pats, slowpath, opts)

def uisetup(ui):
    def printrevset(orig, repo, pats, opts):
        revs, filematcher = orig(repo, pats, opts)
        if opts.get(b'print_revset'):
            expr = logrevset(repo, pats, opts)
            if expr:
                tree = revsetlang.parse(expr)
                tree = revsetlang.analyze(tree)
            else:
                tree = []
            ui = repo.ui
            ui.write(b'%s\n' % stringutil.pprint(opts.get(b'rev', [])))
            ui.write(revsetlang.prettyformat(tree) + b'\n')
            ui.write(stringutil.prettyrepr(revs) + b'\n')
            revs = smartset.baseset()  # display no revisions
        return revs, filematcher
    extensions.wrapfunction(logcmdutil, 'getrevs', printrevset)
    aliases, entry = cmdutil.findcmd(b'log', commands.table)
    entry[1].append((b'', b'print-revset', False,
                     b'print generated revset and exit (DEPRECATED)'))