Module hgflow
[hide private]
[frames] | no frames]

Module hgflow

source code

commands to support generalized Driessen's branching model

Classes [hide private]
  AbortFlow
Throw an instance of this exception whenever we have to abort the flow command.
  AbnormalStream
Throw an instance of this exception if the stream does not belong to any one of <master>, <develop>, <feature>, <release>, <hotfix>, and <support>.
  Commands
Wrapper class of mercurial.commands with ability of recording command history.
  Stream
  Branch
  Flow
  Help
Online help system We define all help topics within this class.
Functions [hide private]
 
_print(ui, *arg, **kwarg)
Customized print function
source code
 
_warn(ui, *arg, **kwarg)
Print messages to stderr.
source code
 
_error(ui, *arg, **kwarg)
Print messages to stderr.
source code
 
_note(ui, *arg, **kwarg)
Print messages to stout.
source code
 
flow_cmd(ui, repo, cmd=None, *arg, **kwarg)
Flow is a Mercurial extension to support the generalized Driessen's branching model.
source code
 
_getopt(ui, key, opt)
Return user-specified options.
source code
Variables [hide private]
  VERSION = '0.9.6'
  CONFIG_BASENAME = '.hgflow'
  OLD_CONFIG_BASENAME = '.flow'
  CONFIG_SECTION_BRANCHNAME = 'branchname'
  STRIP_CHARS = '\'"'
  colortable = {'flow.error': 'red bold', 'flow.help.code': 'gre...
  commands = Commands()
  STREAM = {}
  OPT_FILTER = {'abort': ('erase', 'message', 'stamp', 'onstream...
  OPT_CONFLICT = {'closed': ('-c', False), 'commit': ('-c', Fals...
  cmdtable = {'flow': (<function flow_cmd at 0x101525488>, [('',...
  __package__ = None
Function Details [hide private]

_print(ui, *arg, **kwarg)

source code 

Customized print function

This function prints messages with the prefix: flow: . Multiple messages can be printed in one call. See Example I below.

Parameters:
  • ui (mercurial.ui) - Mercurial user interface object
  • warning (bool) - If set to true, messages will be written to stderr using the ui.warn function.
  • note (bool) - If set to true, messages will be written to stdout using the ui.note function. The messages will be visible only when user turns on --verbose. By default, both warning and note are set to false, and messages will be written to stdout.
  • prefix (None or str) - Add a customized prefix before every message. See Example II.
  • newline (bool) - If set to false, each message will be written without newline suffix. Default value is true.

    Example I:

    >>> _print( ui, "message1", "message2" )
    flow: message1
    flow: message2

    Example II:

    >>> _print( ui, "message1", "message2", prefix = "warning: " )
    flow: warning: message1
    flow: warning: message2

    Example III:

    >>> _print( ui, "message1", "message2", inline = False )
    flow: message1message2

_warn(ui, *arg, **kwarg)

source code 

Print messages to stderr. Each message will be prefixed with flow: warning: .

This function is a thin wrapper of _print. See document of the later for usage detail.

Customized prefix will be appended after flow: warning: .

Example:

>>> _warn( ui, "message1", "message2", prefix = "prefix_" )
flow: warning: prefix_message1
flow: warning: prefix_message2

_error(ui, *arg, **kwarg)

source code 

Print messages to stderr. Each message will be prefixed with flow: error: .

This function is a thin wrapper of _print. See document of the later for usage detail.

Customized prefix will be appended after flow: error: .

Example:

>>> _error( ui, "message1", "message2", prefix = "prefix_" )
flow: error: prefix_message1
flow: error: prefix_message2

_note(ui, *arg, **kwarg)

source code 

Print messages to stout. Each message will be prefixed with flow: note: . The messages will be displayed only when user turns on --verbose. If you want to print message without --verbose, include an argument via_quiet = True in the call to this function.

This function is a thin wrapper of _print. See document of the later for usage detail.

Customized prefix will be appended after flow: note: .

Example:

>>> _note( ui, "message1", "message2", prefix = "prefix_" )
flow: note: prefix_message1
flow: note: prefix_message2

flow_cmd(ui, repo, cmd=None, *arg, **kwarg)

source code 
Flow is a Mercurial extension to support the generalized Driessen's branching model.

actions:

- start    Open a new branch in the stream.
- finish   Close workspace branch and merge it to destination stream(s).
- push     Push workspace branch to the remote repository.
- publish  Same as `push`
- pull     Pull from the remote repository and update workspace branch.
- list     List all open branches in the stream.
- log      Show revision history of branch.
- promote  Merge workspace to other branches. (not closing any branches.)
- rebase   Rebase workspace branch to its parent branch.
- abort    Abort branch. Close branch without merging.

If no action is specified by user, the action will default to `list`. If a
branch name (instead of action) is given after the stream name, Flow will
switch the current workspace to the branch.

commands:

- init     Initialize flow.
- unshelve Unshelve the previously shelved changes for workspace branch.
- upgrade  Upgrade the configuration file to v0.9.5 or later.
- help     Show help for a specific topic. Example: `hg flow help @help`
- version  Show flow's version number.

_getopt(ui, key, opt)

source code 

Return user-specified options.

We cannot separate options for different subcommands because of the design of the cmdtable. So ambiguity exists for some options. For example, the -d option, it means dest for rebase and date for finish. For either of the two actions, the value of the -d option could be saved in dest or date. In general, we don't know which one.

We have to do a bit of parsing to resolve potential ambiguity. This function is here for that purpose. opt is the raw option dict from hg. We will reparse it a bit for a particular command or action given by key. The function returns a dict that contains the option's name and its value. N.B.: (1) If the value of an option evaluates to false, the option will be absent in the returned dict object. (2) This function will mutate and return opt.

Parameters:
  • ui (mercurial.ui) - Mercurial user interface object
  • key (str) - Command or action for which you are getting the options
  • opt (dict) - Raw options
Raises:
  • AbortFlow - AbortFlow exception will be raised if there is option error.

Variables Details [hide private]

colortable

Value:
{'flow.error': 'red bold',
 'flow.help.code': 'green bold',
 'flow.help.topic': 'yellow',
 'flow.note': 'cyan',
 'flow.warn': 'magenta bold'}

OPT_FILTER

Value:
{'abort': ('erase', 'message', 'stamp', 'onstream'),
 'finish': ('commit',
            'message',
            'stamp',
            'date',
            'user',
            'erase',
            'onstream'),
...

OPT_CONFLICT

Value:
{'closed': ('-c', False),
 'commit': ('-c', False),
 'date': ('-d', ''),
 'default': ('-d', False),
 'dest': ('-d', ''),
 'patch': ('-p', False),
 'stamp': ('-p', '')}

cmdtable

Value:
{'flow': (<function flow_cmd at 0x101525488>,
          [('',
            'history',
            False,
            'Print history of hg commands used in this workflow.'),
           ('',
            'dry-run',
            None,
...