Welcome to hgapi’s documentation!

Contents:

hgapi Package

hgapi Module

exception hgapi.hgapi.HgException(msg, exit_code=None)

Exception class allowing a exit_code parameter and member to be used when calling Mercurial to return exit code

class hgapi.hgapi.Repo(path, user=None)[source]

A representation of a Mercurial repository

config(section, key)[source]

Return the value of a configuration variable

configbool(section, key)[source]

Return a config value as a boolean value. Empty values, the string ‘false’ (any capitalization), and ‘0’ are considered False, anything else True

configlist(section, key)[source]

Return a config value as a list; will try to create a list delimited by commas, or whitespace if no commas are present

get_branch_names()[source]

Returns a list of branch names from the repo.

get_branches()[source]

Returns a list of branches from the repo, including versions

hg_add(filepath)[source]

Add a file to the repo

hg_branch(branch_name=None)[source]

Creates a branch of branch_name isn’t None If not, returns the current branch name.

hg_command(*args)[source]

Run a hg command in path and return the result. Throws on error.

hg_commit(message, user=None, date=None, files=[], close_branch=False)[source]

Commit changes to the repository.

hg_diff(rev_a=None, rev_b=None, filenames=None)[source]

Get a unified diff as returned by ‘hg diff’ rev_a and rev_b are passed as -r <rev> arguments to the call, and filenames are expected to be an iterable of file names.

Returns a list of dicts where every dict has a ‘filename’ and ‘diff’ field, with diff being the complete diff for the file including header (diff -r xxxx -r xxx...).

hg_heads(short=False)[source]

Gets a list with the node id:s of all open heads. If short is given and is not False, return the short form of the node id

hg_id()[source]

Get the output of the hg id command (truncated node)

hg_init()[source]

Initialize a new repo

hg_log(identifier=None, limit=None, template=None, branch=None, **kwargs)[source]

Get repositiory log.

hg_merge(reference, preview=False)[source]

Merge reference to current, or with ‘preview’ set to True get a list of revision numbers containing all revisions that would have been merged

hg_node()[source]

Get the full node id of the current revision

hg_remove(filepath)[source]

Remove a file from the repo

hg_rev()[source]

Get the revision number of the current revision

hg_revert(all=False, *files)[source]

Revert repository

hg_status(empty=False, clean=False)[source]

Get repository status. Returns a dict containing a change char -> file list mapping, where change char is in:

A, M, R, !, ?

Example - added one.txt, modified a_folder/two.txt and three.txt:

{'A': ['one.txt'], 'M': ['a_folder/two.txt', 'three.txt'],
'!': [], '?': [], 'R': []}

If empty is set to non-False value, don’t add empty lists. If clean is set to non-False value, add clean files as well (-A)

hg_tag(*tags, **kwargs)[source]

Add one or more tags to the current revision, or revision given by passing ‘rev’ as a keyword argument:

>>> repo.hg_tag('mytag', rev=3)
hg_tags()[source]

Get all tags from the repo as a dict containing tag: shortnode mapping

hg_update(reference, clean=False)[source]

Update to the revision identified by reference

read_config()[source]

Read the configuration as seen with ‘hg showconfig’ Is called by __init__ - only needs to be called explicitly to reflect changes made since instantiation

revision(identifier)[source]

Get the identified revision as a Revision object

revisions(slice_)[source]

Retruns a list of Revision objects for the given slice

class hgapi.hgapi.Revision(json_log)[source]

A representation of a revision. Available fields are:

node, rev, author, branch, parents, date, tags, desc

A Revision object is equal to any other object with the same value for node

Indices and tables

Table Of Contents