Mercurial > python-hglib
view hglib/__init__.py @ 180:ff6efc1ab9e4
protocol: allow hglib user to get call backs for prompts, output and errors
setcbout(cbout), setcberr(cberr) and setcbprompt(cbprompt) are used to
set the call back function used by the hgclient class. cb stands for
call back.
cbout is a function that will be called with the stdout data of the
command as it runs. cbout is called with output as it is made available,
which can be as partial lines or multiple lines.
cberr is a function that will be called with the stderr data of the
command as it runs. cberr is called with output as it is made available,
which can be as partial lines or multiple lines.
Command that make remote connects can prompt for username and password
for HTTP/HTTPS connections.
cbprompt is called when hgclient need a response to a prompt from the
server. It receives the max number of bytes to return and the contents
of stdout received so far. The last text sent to either cbout or cberr
will contain the prompt text itself.
author | Barry A. Scott <barry@barrys-emacs.org> |
---|---|
date | Fri, 28 Oct 2016 11:33:20 +0100 |
parents | c1b966866ed7 |
children | 820d7c1e470a |
line wrap: on
line source
import subprocess from hglib import client, util, error HGPATH = 'hg' def open(path=None, encoding=None, configs=None): '''starts a cmdserver for the given path (or for a repository found in the cwd). HGENCODING is set to the given encoding. configs is a list of key, value, similar to those passed to hg --config. ''' return client.hgclient(path, encoding, configs) def init(dest=None, ssh=None, remotecmd=None, insecure=False, encoding=None, configs=None): args = util.cmdbuilder('init', dest, e=ssh, remotecmd=remotecmd, insecure=insecure) args.insert(0, HGPATH) proc = util.popen(args) out, err = proc.communicate() if proc.returncode: raise error.CommandError(args, proc.returncode, out, err) return client.hgclient(dest, encoding, configs, connect=False) def clone(source=None, dest=None, noupdate=False, updaterev=None, rev=None, branch=None, pull=False, uncompressed=False, ssh=None, remotecmd=None, insecure=False, encoding=None, configs=None): args = util.cmdbuilder('clone', source, dest, noupdate=noupdate, updaterev=updaterev, rev=rev, branch=branch, pull=pull, uncompresses=uncompressed, e=ssh, remotecmd=remotecmd, insecure=insecure) args.insert(0, HGPATH) proc = util.popen(args) out, err = proc.communicate() if proc.returncode: raise error.CommandError(args, proc.returncode, out, err) return client.hgclient(dest, encoding, configs, connect=False)