.hgext/hgflow.py

Sat, 28 Jun 2014 04:42:06 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 28 Jun 2014 04:42:06 -0400
changeset 90
45bee996b0e4
parent 8
ba72a71f23e6
child 253
a1accbd675a0
permissions
-rw-r--r--

Move theme to proper path

8
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 """commands to support generalized Driessen's branching model
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 # License GPL 2.0
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 # hgflow.py - Mercurial extension to support generalized Driessen's branching model
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 # Copyright (C) 2011-2012, Yujie Wu
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 # This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 # as published by the Free Software Foundation; either version 2 of the License or any later version.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 import os
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17 import sys
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 import copy
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 import difflib
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 import mercurial
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 from mercurial import util, extensions, error, config
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 from mercurial.node import short
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 from mercurial.i18n import _
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28 ###############################################################################################################################
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29 # Let's use 128 char width.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30 # It is silly to stick to the 80-char rule.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33 # Terminologies <== Read before you got confused
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
34 # - branch type
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35 # We distinguish the following types of branches: master, develop, feature, release, hotfix, support.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36 # We should assume any branch is of one of these types.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38 # - stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39 # The entire set of branches of the same type. Stream is not branch, it is a set. Stream is not a type, it is a set.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
40 # Stream is a set of branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
41 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
42 # - substream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
43 # A subset of branches in a stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
44 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
45 # - trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
46 # Trunk is a special branch. A stream can optionally have a trunk, but only one trunk at most. For example, master and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
47 # develop streams each has a trunk, whereas feature, release, hotfix, and support streams don't.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
48 # If a stream has a trunk, all branches in the stream normally should diverge from the trunk and later merge to the trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
49 # when the branches are closed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
50 # Trunk is a relative concept. A trunk of a stream may be a regular branch of another stream. (The former stream will be
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
51 # a substream of the latter.)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
52 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
53 # - source
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
54 # Source is an attribute of stream. The source of a stream refers to the parent stream where branches in the current stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
55 # are created from. Most commonly, source of a stream is the stream itself. But this is not always the case, for example,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
56 # the sources of release and feature streams are the develop stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
57 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
58 # - destin
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
59 # Destin is another attribute of stream. The destin of a stream refers to the stream(s) where branches in the current
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
60 # stream will merge to. Most commonly, destin of a stream is the stream itself. But this is not always the case, for
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
61 # example, the destin of release is the develop and the master streams.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
62 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
63 # - branch name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
64 # Use this term carefully since it is potentially ambiguious.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
65 # Try using this term to refer to fullname (see below).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
66 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
67 # - fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
68 # Branch name as recognized by the SCM, e.g., feature/enhance_log.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
69 # Prefer this term to 'branch name'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
70 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
71 # - basename
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
72 # Branch name recognized by flow, but not necessarily by SCM, e.g., enhanced_log (with prefix 'feature/' dropped).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
73 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
74 # - name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
75 # Use this term carefully since it is potentially ambiguious.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
76 # This term should be a synonym of basename (see above). Try using it only as place holders, such as
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
77 # <hotfix-prefix>/<name>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
78 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
79 # - flow action
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
80 # Refer to action on a specified stream, e.g., hg flow feature start, where 'start' is an action.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
81 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
82 # - flow command
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
83 # Refer to other actions than those on a stream, e.g., hg flow unshelve, where 'unshelve' is a command.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
84 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
85 # - hg command
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
86 # Refer to command not from flow extension.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
87 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
88 # - workflow
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
89 # Refer to the process of executing a sequence of hg commands.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
90 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
91 # - history
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
92 # Refer to a sequence of hg commands that has been executed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
93 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
94 # Notations
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
95 # - <stream>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
96 # Examples: <feature>, <hotfix>. These denote the corresponding streams. When you refer to a stream, e.g., feature stream,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
97 # use '<feature>' (or more verbosely 'feature stream'), instead of '<feature> stream', because '<feature>' already means
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
98 # stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
99 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
100 # - <stream> branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
101 # Example: a <feature> branch. This phrase refers a branch in <feature>. Do not use 'a feature branch' to mean a branch in
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
102 # <feature> because the word 'feature' there should take its usual meaning as in English, which doesn't necessarily mean
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
103 # the feature stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
104 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
105 # - `text`
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
106 # Example, `hg flow feature start <name>`. The text wrapped by the ` (apostrophe) symbols should be a piece of code or
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
107 # shell command, which could contain placeholders to be replaced by actual values.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
108 #
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
109 # - 'text' or "text"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
110 # Refer to an exact string.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
111 ###############################################################################################################################
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
112
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
113
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
114
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
115 VERSION = "0.9.7"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
116 CONFIG_BASENAME = ".hgflow"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
117 OLD_CONFIG_BASENAME = ".flow"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
118 CONFIG_SECTION_BRANCHNAME = "branchname"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
119 STRIP_CHARS = '\'"'
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
120
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
121
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
122 colortable = {"flow.error" : "red bold",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
123 "flow.warn" : "magenta bold",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
124 "flow.note" : "cyan",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
125 "flow.help.topic" : "yellow",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
126 "flow.help.code" : "green bold",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
127 }
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
128
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
129
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
130
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
131 def _print( ui, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
132 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
133 Customized print function
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
134
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
135 This function prints messages with the prefix: C{flow: }. Multiple messages can be printed in one call.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
136 See I{Example I} below.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
137
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
138 @type ui: C{mercurial.ui}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
139 @param ui: Mercurial user interface object
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
140 @type warning: C{bool}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
141 @param warning: If set to true, messages will be written to C{stderr} using the C{ui.warn} function.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
142 @type note: C{bool}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
143 @param note: If set to true, messages will be written to C{stdout} using the C{ui.note} function. The messages will be
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
144 visible only when user turns on C{--verbose}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
145 By default, both L{warning} and L{note} are set to false, and messages will be written to C{stdout}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
146 @type prefix: C{None} or C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
147 @param prefix: Add a customized prefix before every message. See I{Example II}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
148 @type newline: C{bool}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
149 @param newline: If set to false, each message will be written without newline suffix. Default value is true.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
150
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
151 I{Example I}:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
152
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
153 >>> _print( ui, "message1", "message2" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
154 flow: message1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
155 flow: message2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
156
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
157 I{Example II}:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
158
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
159 >>> _print( ui, "message1", "message2", prefix = "warning: " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
160 flow: warning: message1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
161 flow: warning: message2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
162
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
163 I{Example III}:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
164
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
165 >>> _print( ui, "message1", "message2", inline = False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
166 flow: message1message2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
167 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
168 printer = ui.warn if (kwarg.get( "warning" )) else (ui.note if (kwarg.get( "note" )) else ui.write)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
169 indent = kwarg.get( "indent", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
170 prefix = kwarg.get( "prefix", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
171 newline = kwarg.get( "newline" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
172 newline = "\n" if (newline or newline is None) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
173 for e in arg :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
174 printer( ui.config( "flow", "prefix", "flow: " ).strip( STRIP_CHARS ) + prefix + indent )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
175 printer( e + newline, label = kwarg.get( "label", "" ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
176
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
177
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
178
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
179 def _warn( ui, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
180 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
181 Print messages to C{stderr}. Each message will be prefixed with C{flow: warning: }.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
182
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
183 This function is a thin wrapper of L{_print}. See document of the later for usage detail.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
184
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
185 Customized prefix will be appended after C{flow: warning: }.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
186
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
187 I{Example}:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
188
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
189 >>> _warn( ui, "message1", "message2", prefix = "prefix_" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
190 flow: warning: prefix_message1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
191 flow: warning: prefix_message2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
192 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
193 kwarg["warn" ] = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
194 kwarg["label" ] = kwarg.get( "label", "flow.warn" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
195 kwarg["prefix"] = "warning: " + kwarg.get( "prefix", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
196 _print( ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
197
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
198
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
199
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
200 def _error( ui, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
201 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
202 Print messages to C{stderr}. Each message will be prefixed with C{flow: error: }.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
203
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
204 This function is a thin wrapper of L{_print}. See document of the later for usage detail.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
205
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
206 Customized prefix will be appended after C{flow: error: }.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
207
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
208 I{Example}:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
209
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
210 >>> _error( ui, "message1", "message2", prefix = "prefix_" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
211 flow: error: prefix_message1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
212 flow: error: prefix_message2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
213 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
214 kwarg["warn" ] = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
215 kwarg["label" ] = kwarg.get( "label", "flow.error" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
216 kwarg["prefix"] = "error: " + kwarg.get( "prefix", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
217 _print( ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
218
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
219
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
220
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
221 def _note( ui, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
222 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
223 Print messages to C{stout}. Each message will be prefixed with C{flow: note: }. The messages will be displayed only when
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
224 user turns on C{--verbose}. If you want to print message without C{--verbose}, include an argument C{via_quiet = True} in
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
225 the call to this function.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
226
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
227 This function is a thin wrapper of L{_print}. See document of the later for usage detail.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
228
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
229 Customized prefix will be appended after C{flow: note: }.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
230
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
231 I{Example}:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
232
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
233 >>> _note( ui, "message1", "message2", prefix = "prefix_" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
234 flow: note: prefix_message1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
235 flow: note: prefix_message2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
236 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
237 if (kwarg.get( "via_quiet")) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
238 kwarg["note"] = not kwarg["via_quiet"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
239 del kwarg["via_quiet"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
240 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
241 kwarg["note"] = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
242 kwarg["label" ] = kwarg.get( "label", "flow.note" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
243 kwarg["prefix"] = "note: " + kwarg.get( "prefix", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
244 _print( ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
245
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
246
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
247
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
248 class AbortFlow( Exception ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
249 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
250 Throw an instance of this exception whenever we have to abort the flow command.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
251 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
252 def __init__( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
253 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
254 Accept one or more error messages in C{str} as the arguments.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
255 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
256 Exception.__init__( self, "Aborted hg flow command." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
257 self._msg = arg
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
258 for k in kwarg :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
259 self.__dict__[k] = kwarg[k]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
260
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
261
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
262
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
263 def error_message( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
264 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
265 Returns a list of error messages in C{str}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
266 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
267 return self._msg
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
268
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
269
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
270
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
271 class AbnormalStream( Exception ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
272 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
273 Throw an instance of this exception if the stream does not belong to any one of C{<master>}, C{<develop>}, C{<feature>},
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
274 C{<release>}, C{<hotfix>}, and C{<support>}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
275 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
276 def __init__( self, message = "", stream = None ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
277 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
278 Accept one error message. You can also pass the C{Stream} object, which can be retrieved later via the C{stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
279 method.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
280 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
281 Exception.__init__( self, message )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
282 self._stream = stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
283
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
284
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
285
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
286 def stream( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
287 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
288 Return the C{Stream} object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
289 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
290 return self._stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
291
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
292
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
293
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
294 class Commands( object ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
295 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
296 Wrapper class of C{mercurial.commands} with ability of recording command history.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
297
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
298 I{Example:}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
299
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
300 >>> commands = Commands()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
301 >>> commands.commit( ui, repo, ... )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
302 >>> commands.update( ui, repo, ... )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
303 >>> commands.print_history()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
304 flow: note: Hg command history:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
305 flow: note: hg commit --message "flow: Closed release 0.7." --close_branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
306 flow: note: hg update default
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
307 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
308
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
309 def __init__( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
310 self.ui = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
311 self._cmd = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
312 self._cmd_history = []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
313 self._via_quiet = False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
314 self._dryrun = False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
315 self._common_opts = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
316 self._opt_mutator = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
317
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
318
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
319
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
320 def __getattr__( self, name ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
321 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
322 Typical invocation of mercurial commands is in the form: commands.name( ... ).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
323 We only need to save the command name here, leaving execution of the command to the L{__call__} function.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
324 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
325 if (name[0] != "_") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
326 self._cmd = name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
327 return self
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
328
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
329
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
330
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
331 def __call__( self, ui, repo, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
332 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
333 Invoke the mercurial command and save it as a string into the history.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
334 @raise AbortFlow: Throw exception if the return code of hg command (except C{commit} and C{rebase}) is nonzero.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
335 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
336 self.ui = ui
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
337 cmd_str = "hg " + (self._cmd[:-1] if (self._cmd[-1] == "_") else self._cmd)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
338 arg = self._branch2str( arg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
339 kwarg = self._branch2str( kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
340 cmd = self._cmd
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
341
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
342 if (cmd[0] == "q") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
343 where = extensions.find( "mq" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
344 cmd = cmd[1:]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
345 elif (cmd == "strip" ) : where = extensions.find( "mq" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
346 elif (cmd == "rebase") : where = extensions.find( "rebase" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
347 else : where = mercurial.commands
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
348
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
349 kwarg = self._mutate_options( where, self._cmd, kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
350
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
351 for key, value in kwarg.items() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
352 if (value in [None, ""]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
353 continue
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
354
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
355 # If the command is `hg commit --message <commit-hint> --force-editor [other-options...]`, we will drop the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
356 # `--message <commit-hint> --force-editor` part from the command string because `--force-editor` is not a command
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
357 # option (it avails only programmatically).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
358 if (cmd == "commit" and (key in ["message", "force_editor",]) and "force_editor" in kwarg) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
359 continue
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
360
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
361 new_key = ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
362 for e in key :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
363 new_key += "-" if (e == "_") else e
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
364 key = new_key
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
365 value = [self._add_quotes( e ) for e in value] if (isinstance( value, list )) else self._add_quotes( value )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
366
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
367 if (isinstance( value, bool )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
368 cmd_str = "%s --%s" % (cmd_str, key,)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
369 elif (isinstance( value, list )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
370 for e in value :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
371 cmd_str = "%s --%s %s" % (cmd_str, key, str( e ),)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
372 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
373 cmd_str = "%s --%s %s" % (cmd_str, key, str( value ),)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
374 for e in arg :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
375 cmd_str = '%s %s ' % (cmd_str, self._add_quotes( str( e ) ),)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
376
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
377 self._cmd_history.append( cmd_str )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
378
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
379 if (self._dryrun) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
380 return
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
381
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
382 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
383 # Ever since 2.8 the "strip" command has been moved out of the "mq" module to a new module of its own. Issue#56
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
384 if ("strip" == cmd) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
385 from mercurial import __version__
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
386 if (__version__.version > "2.8") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
387 where = extensions.find( "strip" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
388 cmd = "stripcmd"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
389
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
390 ret = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
391 ret = getattr( where, cmd )( ui, repo, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
392 except Exception, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
393 raise AbortFlow( "Hg command failed: %s" % cmd_str, "abort: %s\n" % str( e ), traceback = sys.exc_info() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
394
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
395 if (ret and cmd not in ["commit", "rebase",]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
396 # We have to make some exceptions, where nonzero return codes don't mean error. Issue#55
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
397 if ((ret, cmd,) not in [(1, "push",),]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
398 raise AbortFlow( "Hg command failed: %s" % cmd_str, "abort: Nonzero return code from hg command\n" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
399
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
400
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
401
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
402 def _add_quotes( self, value ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
403 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
404 If value is a string that contains space, slash, double quote, and parenthesis (viz: '(' or ')'), then wrap the value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
405 with double quotes and properly escape double-quotes and slashes in the string, returning the treated value.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
406 Otherwise, return the value as is.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
407 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
408 if (isinstance( value, str ) and (1 in [c in value for c in " ()\\\""])) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
409 new_value = ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
410 for c in value :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
411 if (c == "\\") : new_value += "\\\\"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
412 elif (c == '"' ) : new_value += "\""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
413 else : new_value += c
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
414 value = '"%s"' % new_value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
415 return value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
416
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
417
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
418
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
419 def _branch2str( self, value ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
420 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
421 If C{value} is a C{Branch} object, return its fullname (C{str}); if it is not, return the object itself. Do this
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
422 recursively if C{value} is a C{tuple}, or C{list}, or C{dict} object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
423 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
424 if (isinstance( value, Branch )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
425 return value.fullname()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
426 if (isinstance( value, (list, tuple,) )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
427 new_value = []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
428 for e in value :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
429 new_value.append( self._branch2str( e ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
430 return new_value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
431 if (isinstance( value, dict )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
432 new_value = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
433 for k, v in value.items() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
434 new_value[k] = self._branch2str( v )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
435 return new_value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
436 return value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
437
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
438
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
439
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
440 def _filter_common_options( self, where, cmd ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
441 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
442 If any common options are valid options of the command, return these options.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
443
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
444 @type where: module
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
445 @param where: Should be `mercurial.commands', or a Mercurial's plugin object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
446 @type cmd : C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
447 @param cmd : command name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
448 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
449 ret = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
450 if (self._common_opts != {}) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
451 if (cmd[-1] == "_") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
452 cmd = cmd[:-1]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
453 junk, table = mercurial.cmdutil.findcmd( cmd, where.table if hasattr( where, "table" ) else where.cmdtable )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
454 opts = [e[1] for e in table[1]]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
455 for e in self._common_opts :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
456 if (e in opts) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
457 ret[e] = self._common_opts[e]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
458 return ret
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
459
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
460
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
461
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
462 def _mutate_options( self, where, cmd, opts ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
463 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
464
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
465 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
466 common_opts = self._filter_common_options( where, cmd )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
467 common_opts.update( opts )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
468 opts = common_opts
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
469 mutator = self._opt_mutator.get( cmd )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
470 if (mutator) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
471 opts = mutator( opts )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
472
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
473 return opts
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
474
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
475
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
476
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
477 def use_quiet_channel( self, via_quiet = True ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
478 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
479 Print the history to the I{quiet} channel, where text will be displayed even when user does not specify the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
480 C{--verbose} option.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
481 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
482 self._via_quiet = via_quiet
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
483
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
484
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
485
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
486 def use_verbose_channel( self, via_verbose = True ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
487 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
488 Print the history to the I{verbose} channel, where text will be display only when user specify the C{--verbose} option.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
489 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
490 self._via_quiet = not via_verbose
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
491
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
492
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
493
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
494 def reg_common_options( self, opts ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
495 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
496 Register common options.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
497
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
498 @type opts: C{dict}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
499 @param opts: Common options. Key = option's flag, value = option's value.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
500 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
501 self._common_opts.update( opts )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
502
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
503
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
504
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
505 def reg_option_mutator( self, cmd, mutator ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
506 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
507 Register common options.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
508
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
509 @type opts: C{dict}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
510 @param opts: Common options. Key = option's flag, value = option's value.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
511 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
512 self._opt_mutator[cmd] = mutator
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
513
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
514
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
515
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
516 def dryrun( self, switch = None ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
517 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
518 Switch the dry-run mode.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
519
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
520 @type switch: C{boolean} or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
521 @param switch: Switch on dry-run mode if C{switch = True}, off if C{switch = False}. If C{switch} is C{None}, just
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
522 return the current state of dry-run mode.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
523 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
524 if (switch is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
525 return self._dryrun
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
526 self._dryrun = switch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
527
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
528
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
529
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
530 def print_history( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
531 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
532 Print the command history using the L{_note} function.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
533 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
534 if (self.ui) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
535 _note( self.ui, "Hg command history:", via_quiet = self._via_quiet )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
536 for e in self._cmd_history :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
537 _note( self.ui, e, prefix = " ", via_quiet = self._via_quiet )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
538
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
539
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
540
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
541 class Stream( object ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
542 @staticmethod
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
543 def gen( ui, repo, name, check = False ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
544 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
545 Given the name of a stream, return a C{Stream} object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
546 If the name is that of one of the standard streams: master, develop, feature, release, hotfix, and support, return the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
547 same object as in C{STREAM}. If not, create and return a new C{stream} object. If the new object is not in the standard
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
548 streams, an C{AbnormalStream} exception will be thrown. One can catch the exception and call its C{stream} method to
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
549 get the object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
550
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
551 @type name : C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
552 @param name : Name of the stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
553 @type check: C{boolean}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
554 @param check: If true and the stream is not a standard one, the function will check if the trunk of the stream exists
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
555 or not and (if exists) open or not.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
556
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
557 @raise AbortFlow : When C{check} is true and the trunk of the stream doesn't exist or is closed
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
558 @raise AbnormalStream: When the stream is not in any of the standard streams
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
559 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
560 for e in STREAM.values() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
561 if (name == e.name()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
562 return e
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
563
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
564 rootstream_name = name.split( '/', 1 )[0]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
565 is_normalstream = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
566 if (rootstream_name in STREAM) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
567 trunk = name.replace( rootstream_name + '/', STREAM[rootstream_name].prefix(), 1 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
568 stream = Stream( ui, repo, name, trunk = trunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
569 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
570 stream = Stream( ui, repo, name, trunk = name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
571 is_normalstream = False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
572 if (check) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
573 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
574 trunk = stream.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
575 except error.RepoLookupError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
576 misspelling = difflib.get_close_matches( stream.name(), STREAM.keys(), 3, 0.7 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
577 note = "Did you mean: %s?" % " or ".join( misspelling ) if (misspelling) else None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
578 raise AbortFlow( "Stream not found: %s" % stream, note = note )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
579 if (trunk.is_closed()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
580 raise AbortFlow( "%s has been closed." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
581 if (not is_normalstream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
582 raise AbnormalStream( stream = Stream( ui, repo, name ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
583 return stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
584
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
585
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
586
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
587 def __init__( self, ui, repo, name, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
588 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
589 Create a new C{Stream} object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
590
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
591 @type name : C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
592 @param name : Name of the new stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
593 @type trunk : C{str} or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
594 @param trunk : Fullname of the trunk of the stream, or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
595 @type prefix: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
596 @param prefix: Name prefix of branches in this stream. If not specified, it will default to C{trunk + '/'} (if C{trunk}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
597 is not C{None}), or C{name + '/'} if (C{trunk} is C{None}).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
598 @type source: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
599 @param source: Stream where branches in this stream will be created from
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
600 @type destin: C{list} of C{Stream} objects
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
601 @param destin: Streams where branches in this stream will merge to when being finished
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
602 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
603 self.ui = ui
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
604 self.repo = repo
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
605
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
606 self._name = name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
607 self._trunk = kwarg.get( "trunk" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
608 self._prefix = kwarg.get( "prefix" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
609 self._source = kwarg.get( "source", self )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
610 self._destin = kwarg.get( "destin", [self._source,] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
611 self._tcache = None # Caches `Branch' object of the trunk because construction of a `Branch' object is very slow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
612
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
613 if (self._prefix is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
614 if (self._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
615 self._prefix = self._trunk + '/'
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
616 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
617 self._prefix = self._name + '/'
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
618
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
619
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
620
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
621 def __str__( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
622 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
623 Return a string: '<stream-name>'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
624 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
625 return "<%s>" % self._name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
626
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
627
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
628
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
629 def __cmp__( self, rhs ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
630 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
631 Compare streams by comparing their names as strings.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
632 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
633 lhs = self._name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
634 rhs = rhs ._name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
635 return -1 if (lhs < rhs) else (1 if (lhs > rhs) else 0)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
636
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
637
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
638
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
639 def __contains__( self, stranch ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
640 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
641 Return true if the C{stanch} is in this stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
642
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
643 @type stranch: C{Stream} or C{Branch}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
644 @param srranch: Stream or branch which you want to test if it is in this stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
645 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
646 if (isinstance( stranch, Branch )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
647 if (stranch._fullname == self._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
648 return True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
649 return stranch._fullname.startswith( self.prefix() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
650 elif (isinstance( stranch, Stream )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
651 return stranch.prefix().startswith( self.prefix() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
652 return str( stranch ).startswith( self.prefix() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
653
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
654
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
655
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
656 def name( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
657 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
658 Return the name of this stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
659 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
660 return self._name
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
661
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
662
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
663
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
664 def trunk( self, trace = False ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
665 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
666 Return the trunk of this stream. If it has no trunk, return C{None} or the trunk of the source stream depending on the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
667 C{trace} parameter.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
668
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
669 @type trace: C{boolean}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
670 @param trace: If true and this stream has no trunk, return the trunk of the source stream, and do this recursively
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
671 until a trunk is found. If false, this function will return C{None}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
672
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
673 @return: A C{Branch} object or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
674 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
675 if (self._tcache) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
676 return self._tcache
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
677
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
678 trunk = Branch( self.ui, self.repo, self._trunk ) if (self._trunk) else None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
679 if (not trunk and trace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
680 return self.source().trunk( True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
681 self._tcache = trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
682 return trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
683
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
684
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
685
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
686 def prefix( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
687 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
688 Return the branch name prefix of this stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
689
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
690 @return: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
691 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
692 return self._prefix
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
693
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
694
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
695
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
696 def source( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
697 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
698 Return the source stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
699
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
700 @return: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
701 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
702 return self._source
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
703
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
704
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
705
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
706 def destin( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
707 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
708 Return a list of streams where branches in this stream will merge to when finished.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
709
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
710 @return: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
711 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
712 return self._destin
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
713
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
714
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
715
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
716 def get_fullname( self, branch_basename ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
717 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
718 Return the fullname of a branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
719
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
720 @type branch_basename: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
721 @param branch_basename: Basename of a branch in this stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
722
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
723 @return: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
724 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
725 return self._prefix + branch_basename
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
726
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
727
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
728
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
729 def get_branch( self, branch_basename ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
730 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
731 Create and return a new C{Branch} object with the given basename.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
732
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
733 @type branch_basename: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
734 @param branch_basename: Basename of a branch in this stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
735
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
736 @return: C{Branch}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
737 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
738 return Branch( self.ui, self.repo, self.get_fullname( branch_basename ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
739
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
740
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
741
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
742 def branches( self, openclosed = "open" ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
743 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
744 Return a list of branches in this stream. The list does not include the trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
745 The returned list is sorted per branch name.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
746
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
747 @type openclosed: C{str}, must be one of "open", "closed", and "all".
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
748 @param openclosed: If the value is C{"open"}, return all open branches in this stream; if C{"closed"}, return all
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
749 closed branches in this stream; if C{"all"}, returns all open and closed branches in this stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
750 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
751 if (openclosed not in ["open", "closed", "all",]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
752 raise ValueError( "Invalid value for `openclosed` parameter: %s" % openclosed )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
753
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
754 if (openclosed == "open") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
755 all_branches = [Branch( self.ui, self.repo, head[0] ) for branch_fullname, head in self.repo.branchmap().items()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
756 if (not self.repo[head[0]].extra().get( "close", False ) )]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
757 elif (openclosed == "closed") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
758 all_branches = [Branch( self.ui, self.repo, head[0] ) for branch_fullname, head in self.repo.branchmap().items()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
759 if (self.repo[head[0]].extra().get( "close", False ) )]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
760 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
761 all_branches = [Branch( self.ui, self.repo, head[0] ) for branch_fullname, head in self.repo.branchmap().items()]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
762
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
763 return sorted( [e for e in all_branches if (e in self)] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
764
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
765
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
766
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
767 class Branch( object ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
768 def __init__( self, ui, repo, rev = None ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
769 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
770 Create a C{Branch} object with the given C{rev}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
771 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
772 self.ui = ui
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
773 self.repo = repo
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
774 self.ctx = repo[rev] # `repo[rev]' is slow when there are tens of thousands of named branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
775
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
776 self._fullname = str( self.ctx.branch() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
777
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
778
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
779
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
780 def __str__( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
781 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
782 Return the fullname of this branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
783 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
784 return self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
785
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
786
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
787
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
788 def __cmp__( self, rhs ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
789 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
790 Compare two C{Branch} object by comparing their fullnames.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
791 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
792 if (rhs is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
793 return 1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
794 lhs = self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
795 rhs = rhs ._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
796 return -1 if (lhs < rhs) else (1 if (lhs > rhs) else 0)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
797
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
798
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
799
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
800 def fullname( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
801 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
802 Return the fullname of this branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
803 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
804 return self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
805
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
806
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
807
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
808 def basename( self, stream = None, should_quote = False ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
809 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
810 Return the basename relative to the C{stream}. If C{stream} is C{None}, return the shortest possible basename (will
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
811 not contain any '/'s).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
812 Return the string "trunk" if this branch is the trunk of the C{stream}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
813
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
814 @type stream: C{Stream} or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
815 @param stream: Stream to which the basename is relative
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
816 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
817 if (stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
818 if (self._fullname == stream._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
819 return "trunk"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
820 ret = self._fullname[len( stream.prefix() ):]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
821 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
822 ret = self._fullname.rsplit( '/', 1 )[-1]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
823 if (should_quote) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
824 ret = "'%s'" % ret
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
825 return ret
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
826
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
827
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
828
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
829 def is_closed( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
830 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
831 Return true if this branch is closed; or false if it is open.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
832 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
833 extra = self.ctx.extra()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
834 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
835 return extra["close"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
836 except KeyError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
837 return False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
838
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
839
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
840
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
841 def is_open( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
842 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
843 Return true if this branch is open; or false if it is closed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
844 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
845 return not self.is_closed()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
846
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
847
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
848
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
849 def is_develop_trunk( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
850 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
851 Return true if this branch is the trunk of C{<develop>}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
852 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
853 return STREAM["develop"]._trunk == self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
854
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
855
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
856
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
857 def is_master_trunk( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
858 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
859 Return true if this branch is the trunk of C{<master>}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
860 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
861 return STREAM["master"]._trunk == self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
862
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
863
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
864
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
865 def is_trunk( self, stream ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
866 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
867 Return true if this branch is the trunk of the C{stream}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
868 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
869 return stream._trunk == self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
870
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
871
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
872
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
873 def stream( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
874 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
875 Return the stream that this branch belongs to.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
876 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
877 name = self._fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
878 for stream in STREAM.values() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
879 if (name == stream._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
880 return stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
881 if (name.startswith( stream.prefix() )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
882 name = name.replace( stream.prefix(), stream.name() + '/' )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
883 break
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
884 return Stream.gen( self.ui, self.repo, name.rsplit( '/', 1 )[0] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
885
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
886
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
887
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
888 commands = Commands()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
889 STREAM = {} # key = stream name, value = `Stream` object. Will be set by `Flow.__init__`.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
890
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
891
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
892
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
893 class Flow( object ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
894 def __init__( self, ui, repo, init = False ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
895 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
896 Construct a C{Flow} instance that will execute the workflow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
897 Construction will fail if the C{flow} extension has not been initialized for the repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
898 A warning message will be issued if the repository has uncommitted changes.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
899
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
900 @type init: C{boolean}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
901 @param init: If true, a C{Flow} object will be constructed for initialization of hgflow. Such constructed object does
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
902 not supply all functionalities and is only meant to execute the `hg flow init` command.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
903 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
904 self.ui = ui
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
905 self.repo = repo
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
906
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
907 self.autoshelve = False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
908 self.warn_uncommitted = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
909 self.msg_prefix = "flow: "
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
910 self.version_prefix = "v"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
911 self.orig_workspace = Branch( ui, repo )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
912 self.curr_workspace = self.orig_workspace # May be changed whenever `hg update` command is executed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
913 self.orig_dir = os.getcwd()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
914 self._dryrun_shelve = set()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
915
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
916 if (init) : return
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
917
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
918 config_fname = os.path.join( self.repo.root, CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
919 if (os.path.isfile( config_fname )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
920 cfg = config.config()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
921 cfg.read( config_fname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
922 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
923 master = cfg.get( CONFIG_SECTION_BRANCHNAME, "master" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
924 develop = cfg.get( CONFIG_SECTION_BRANCHNAME, "develop" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
925 feature = cfg.get( CONFIG_SECTION_BRANCHNAME, "feature" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
926 release = cfg.get( CONFIG_SECTION_BRANCHNAME, "release" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
927 hotfix = cfg.get( CONFIG_SECTION_BRANCHNAME, "hotfix" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
928 support = cfg.get( CONFIG_SECTION_BRANCHNAME, "support" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
929 except Exception, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
930 self._error( str( e ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
931 self._error( "Flow has not been initialized properly for this repository." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
932 self._note ( "You can use command `hg flow init -f` to reinitialize for this repository.", via_quiet = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
933 sys.exit( 1 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
934 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
935 old_config_fname = os.path.join( self.repo.root, OLD_CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
936 if (os.path.isfile( old_config_fname )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
937 cfg = config.config()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
938 cfg.read( old_config_fname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
939 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
940 master = cfg.get( CONFIG_SECTION_BRANCHNAME, "master" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
941 develop = cfg.get( CONFIG_SECTION_BRANCHNAME, "develop" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
942 feature = cfg.get( CONFIG_SECTION_BRANCHNAME, "feature" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
943 release = cfg.get( CONFIG_SECTION_BRANCHNAME, "release" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
944 hotfix = cfg.get( CONFIG_SECTION_BRANCHNAME, "hotfix" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
945 support = cfg.get( CONFIG_SECTION_BRANCHNAME, "support" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
946 except Exception, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
947 self._error( str( e ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
948 self._error( "Flow has not been initialized properly for this repository." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
949 self._note ( "You can use command `hg flow init -f` to reinitialize for this repository.", via_quiet = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
950 sys.exit( 1 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
951 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
952 self._error( "Flow has not been initialized for this repository: %s file is missing." % CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
953 self._note ( "You can use command `hg flow init` to initialize for this repository.", via_quiet = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
954 sys.exit( 1 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
955
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
956 global STREAM
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
957 STREAM["master" ] = Stream( ui, repo, "master", trunk = master )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
958 STREAM["develop"] = Stream( ui, repo, "develop", trunk = develop )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
959 STREAM["feature"] = Stream( ui, repo, "feature", prefix = feature, source = STREAM["develop"] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
960 STREAM["release"] = Stream( ui, repo, "release", prefix = release, source = STREAM["develop"] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
961 STREAM["hotfix" ] = Stream( ui, repo, "hotfix", prefix = hotfix, source = STREAM["master" ] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
962 STREAM["support"] = Stream( ui, repo, "support", prefix = support, source = STREAM["master" ], destin = [] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
963
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
964 STREAM["develop"]._destin.append( STREAM["release"] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
965 STREAM["release"]._destin.append( STREAM["master" ] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
966 STREAM["hotfix" ]._destin.append( STREAM["develop"] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
967
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
968 if (ui.has_section( "hgflow" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
969 self._warn( "The [hgflow] section in hg configuration file is deprecated." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
970 self._warn( "Please replace the section name from [hgflow] to [flow]." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
971 self.autoshelve = ui.configbool( "hgflow", "autoshelve", self.autoshelve )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
972 self.warn_uncommitted = ui.configbool( "hgflow", "warn_uncommitted", self.warn_uncommitted )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
973 if (ui.has_section( "flow" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
974 self.autoshelve = ui.configbool( "flow", "autoshelve", self.autoshelve )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
975 self.warn_uncommitted = ui.configbool( "flow", "warn_uncommitted", self.warn_uncommitted )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
976 self.msg_prefix = ui.config ( "flow", "prefix", self.msg_prefix ).strip( STRIP_CHARS )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
977 self.version_prefix = ui.config ( "flow", "version_prefix", self.version_prefix ).strip( STRIP_CHARS )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
978 if (self._has_uncommitted_changes() and self.warn_uncommitted) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
979 self._warn( "Your workspace has uncommitted changes." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
980
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
981 # We'd better temporarily change the current directory to the root of the repository at the beginning.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
982 # This is to avoid the problem that the CWD might be gone after switching to a different branch. (Issue#14)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
983 # We will change it back to the original directory when the hgflow command exits.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
984 os.chdir( self.repo.root )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
985 # __init__
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
986
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
987
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
988
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
989 def __getattr__( self, name ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
990 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
991 Execute mercurial command of name C{name[1:]}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
992
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
993 @type name: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
994 @param name: Should be a mercurial command name prefixed with one underscore. For example, to call C{commit} command,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
995 use C{self._commit}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
996 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
997 if (name[0] == "_") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
998 cmd = getattr( commands, name[1:] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
999 def func( *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1000 cmd( self.ui, self.repo, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1001 return func
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1002 raise AttributeError( "%s instance has no attribute '%s'" % (self.__class__, name,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1003
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1004
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1005
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1006 def _update( self, rev, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1007 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1008 Intercept the call to `hg update` command. We need to keep track of the branch of the workspace.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1009
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1010 @type rev: C{str} or C{mercurial.changectx}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1011 @param rev: Revision to which the workspace will update
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1012 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1013 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1014 old_workspace_ctx = self.curr_workspace.ctx
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1015 self.curr_workspace = rev if (isinstance( rev, Branch )) else Branch( self.ui, self.repo, rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1016 except error.RepoLookupError, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1017 if (commands.dryrun()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1018 commands.update( self.ui, self.repo, rev, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1019 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1020 raise e
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1021
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1022 if (old_workspace_ctx != self.curr_workspace.ctx) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1023 commands.update( self.ui, self.repo, rev, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1024
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1025
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1026
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1027 def _print( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1028 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1029 Thin wrapper of the global C{_print} function
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1030 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1031 _print( self.ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1032
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1033
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1034
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1035 def _warn( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1036 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1037 Thin wrapper of the global C{_warn} function
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1038 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1039 _warn( self.ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1040
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1041
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1042
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1043 def _error( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1044 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1045 Thin wrapper of the global C{_error} function
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1046 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1047 _error( self.ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1048
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1049
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1050
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1051 def _note( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1052 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1053 Thin wrapper of the global C{_note} function
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1054 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1055 _note( self.ui, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1056
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1057
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1058
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1059 def _check_rebase( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1060 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1061 Check if 'rebase' extension is activated. If not, raise an 'AbortFlow' exception.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1062
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1063 @raise AbortFlow: When 'rebase' extension is not found
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1064 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1065 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1066 extensions.find( "rebase" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1067 except KeyError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1068 raise AbortFlow( "Cannot rebase without 'rebase' extension." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1069
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1070
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1071
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1072 def _check_mq( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1073 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1074 Check if 'mq' extension is activated. If not, raise an 'AbortFlow' exception.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1075
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1076 @raise AbortFlow: When 'mq' extension is not found
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1077 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1078 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1079 extensions.find( "mq" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1080 except KeyError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1081 raise AbortFlow( "Cannot shelve/unshelve changes without 'mq' extension." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1082
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1083
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1084
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1085 def _check_strip( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1086 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1087 The 'strip' command comes with the 'mq' extension.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1088 Check if 'mq' extension is activated. If not, raise an 'AbortFlow' exception.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1089
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1090 @raise AbortFlow: When 'mq' extension is not found
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1091 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1092 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1093 extensions.find( "mq" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1094 except KeyError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1095 raise AbortFlow( "Cannot use 'strip' command without 'mq' extension." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1096
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1097
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1098
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1099 def _is_shelved( self, branch ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1100 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1101 Return true if the given branch has been shelved.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1102
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1103 @type branch: C{Branch}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1104 @param branch: Branch to test if it has shelved changes
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1105 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1106 shelve_name = "flow/" + branch.fullname() + ".pch"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1107 patch_fname = self.repo.join( "patches/" + shelve_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1108 return os.path.isfile( patch_fname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1109
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1110
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1111
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1112 def _shelve( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1113 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1114 Shelve workspace if C{self.autoshelve} is C{True}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1115
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1116 This function utilizes the C{mq} extension to achieve shelving. Bascially, it calls the following C{mq} commands:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1117 C{hg qnew <patchname> --currentuser --currentdate -m "Shelved changes"}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1118 C{hg qpop}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1119 where <patchname> follows the pattern: flow/<branch_fullname>.pch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1120 The two commands will give us a patch file that later will be used to unshelve the change.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1121 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1122 if (self.autoshelve or kwarg.get( "force" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1123 if (self._has_uncommitted_changes()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1124 shelve_name = "flow/" + self.curr_workspace.fullname() + ".pch"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1125 if (commands.dryrun()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1126 # For dry run, adds the name of the shelved item into `self._dryrun_shelve'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1127 # This is for generating correct dry run history for the unshelving operation.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1128 self._dryrun_shelve.add( shelve_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1129 self._check_mq()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1130 self._qnew( shelve_name, currentuser = True, currentdate = True, message = "Shelved changes" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1131 self._qpop()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1132
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1133
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1134
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1135 def _unshelve( self, basename = None, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1136 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1137 Unshelve the previously shelved changes to the workspace if C{self.autoshelve} is C{True}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1138
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1139 This function needs the C{mq} extension to achieve unshelving. Bascially, it calls the following commands:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1140 C{hg import <patch_filename> --no-commit}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1141 C{hg qdelete <patchname>}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1142 where <patchname> follows the pattern: flow/<branch_fullname>.pch, which was previously created by flow's shelving.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1143
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1144 @type basename: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1145 @param basename: Base name of the shelved patch file. Default is the name of current workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1146 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1147 if (self.autoshelve or kwarg.get( "force" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1148 basename = basename if (basename) else self.curr_workspace.fullname()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1149 shelve_name = "flow/" + basename + ".pch"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1150 patch_fname = self.repo.join( "patches/" + shelve_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1151 if (os.path.isfile( patch_fname ) or (shelve_name in self._dryrun_shelve)) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1152 self._check_mq()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1153 self._import_( patch_fname, no_commit = True, base = "", strip = 1 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1154 self._qdelete( shelve_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1155 if (commands.dryrun()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1156 self._dryrun_shelve.discard( shelve_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1157
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1158
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1159
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1160 def _has_uncommitted_changes( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1161 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1162 Return true if any tracked file is modified, or added, or removed, or deleted.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1163 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1164 return any( self.repo.status() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1165
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1166
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1167
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1168 def _branches( self, openclosed = "open" ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1169 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1170 Return a list of branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1171
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1172 @type openclosed: C{str}, "open", "closed", and "all"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1173 @param openclosed: If C{"open"}, return all open branches; if C{"closed"}, return all closed branches; if C{"all"},
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1174 return all branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1175 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1176 if (openclosed not in ["open", "closed", "all",]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1177 raise ValueError( "Invalid value for openclosed parameter: %s" % openclosed )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1178 if (openclosed == "open") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1179 all_branches = [Branch( self.ui, self.repo, head[0] ) for branch_fullname, head in self.repo.branchmap().items()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1180 if (not self.repo[head[0]].extra().get( "close", False ) )]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1181 elif (openclosed == "closed") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1182 all_branches = [Branch( self.ui, self.repo, head[0] ) for branch_fullname, head in self.repo.branchmap().items()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1183 if (self.repo[head[0]].extra().get( "close", False ))]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1184 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1185 all_branches = [Branch( self.ui, self.repo, head[0] ) for branch_fullname, head in self.repo.branchmap().items()]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1186 return all_branches
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1187
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1188
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1189
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1190 def _find_branch( self, fullname ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1191 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1192 Return true if a branch C{fullname} is open.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1193
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1194 @type fullname: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1195 @param fullname: Fullname of branch that you want to know whether it is open
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1196 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1197 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1198 Branch( self.ui, self.repo, fullname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1199 return True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1200 except error.RepoLookupError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1201 return False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1202
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1203
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1204
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1205 def latest_master_tags( self ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1206 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1207 Return the latest tag of C{<master>} branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1208 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1209 trunk = STREAM["master"].trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1210 trunk_fullname = trunk.fullname()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1211 master_context = trunk.ctx
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1212 while (master_context) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1213 tags = master_context.tags()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1214 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1215 tags.remove( "tip" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1216 except ValueError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1217 pass
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1218 if (tags) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1219 return tags
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1220 parents = master_context.parents()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1221 master_context = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1222 for e in parents :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1223 if (trunk_fullname == e.branch()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1224 master_context = e
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1225 break
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1226 return []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1227
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1228
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1229
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1230 def _create_branch( self, fullname, message, from_branch = None, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1231 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1232 Create a new branch and commit the change.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1233
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1234 @type fullname: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1235 @param fullname: Fullname of the new branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1236 @type message: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1237 @param message: Commit message
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1238 @type from_branch: C{Branch}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1239 @param from_branch: Parent branch of the new branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1240 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1241 if (from_branch and self.curr_workspace != from_branch) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1242 self._update( from_branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1243 self._branch( fullname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1244 self._commit( message = message, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1245 if (commands.dryrun()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1246 # Makes a fake new branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1247 self.curr_workspace = Branch( self.ui, self.repo )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1248 self.curr_workspace._fullname = fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1249 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1250 self.curr_workspace = Branch( self.ui, self.repo, fullname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1251
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1252
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1253
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1254 def _action_start( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1255 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1256 Conduct the I{start} action for the given stream. A new branch in the stream will be created.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1257
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1258 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1259 @param stream: Stream where you want to start a new branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1260 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1261 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1262 basename = arg[1]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1263 except IndexError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1264 raise AbortFlow( "You must specify a name for the new branch to start." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1265
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1266 rev = kwarg.pop( "rev", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1267 msg = kwarg.pop( "message", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1268 dirty = kwarg.pop( "dirty", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1269 fullname = stream.get_fullname( basename )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1270 if (self._find_branch( fullname )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1271 self._warn( "An open branch named '%s' already exists in %s." % (basename, stream,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1272 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1273 shelvedpatch_basename = self.curr_workspace.fullname()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1274 if (rev is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1275 from_branch = stream.source().trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1276 self._shelve( force = dirty )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1277 self._update( from_branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1278 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1279 from_branch = Branch( self.ui, self.repo, rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1280 if (from_branch._fullname != stream.source()._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1281 raise AbortFlow( "Revision %s is not in the source stream of %s." % (rev, stream,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1282 self._shelve( force = dirty )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1283 self._update( rev = rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1284 if (msg) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1285 msg = "%s\n" % msg
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1286 self._create_branch( fullname, "%s%sCreated branch '%s'." % (msg, self.msg_prefix, fullname,), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1287 if (dirty) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1288 self._unshelve( shelvedpatch_basename, force = dirty )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1289
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1290
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1291
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1292 def _action_push( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1293 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1294 Conduct the I{push} action for the given stream. The workspace branch will be pushed to the remote repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1295
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1296 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1297 @param stream: Stream where you want to push the workspace branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1298 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1299 if (self.curr_workspace in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1300 self._push( new_branch = True, branch = [self.curr_workspace.fullname(),] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1301 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1302 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (self.curr_workspace, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1303 "To push a %s branch, you must first update to it." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1304
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1305
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1306
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1307 def _action_pull( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1308 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1309 Conduct the I{pull} action for the given stream. The workspace branch will be updated with changes pulled from the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1310 remote repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1311
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1312 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1313 @param stream: Stream where you want to pull for the workspace branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1314 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1315 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1316 branch = stream.get_fullname( arg[1] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1317 except IndexError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1318 branch = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1319 if (branch not in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1320 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (branch, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1321 "To pull a %s branch, you must first update to it." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1322
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1323 self._pull( update = True, branch = [branch,] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1324
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1325
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1326
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1327 def _action_list( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1328 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1329 Print all open branches in the given stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1330
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1331 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1332 @param stream: Stream of which you want to display open branches
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1333 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1334 # Lists all open branches in this stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1335 open_branches = stream.branches()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1336 trunk = stream.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1337 if (trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1338 tags = ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1339 if (stream == STREAM["master"]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1340 tags = self.latest_master_tags()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1341 tags = (", latest tags: %s" % ", ".join( tags )) if (tags) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1342 self._print( "%s trunk: %s%s" % (stream, trunk, tags,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1343 if (open_branches) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1344 self._print( "Open %s branches:" % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1345 for e in open_branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1346 marker = "#" if (self._is_shelved( e ) ) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1347 marker += "*" if (e == self.curr_workspace) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1348 self._print( str( e ) + marker, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1349 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1350 self._print( "No open %s branches" % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1351 if (kwarg.get( "closed" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1352 closed_branches = stream.branches( "closed" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1353 if (closed_branches) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1354 self._print( "Closed %s branches:" % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1355 closed_branches.sort( lambda x, y : y.ctx.rev() - x.ctx.rev() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1356 for e in closed_branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1357 self.ui.write( "%-31s" % e.basename( stream ), label = "branches.closed" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1358 self.ui.write( " %5s:%s" % (e.ctx.rev(), short( e.ctx.node() ),), label = "log.changeset" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1359 self.ui.write( " %s\n" % util.datestr( e.ctx.date(), format = "%Y-%m-%d %a %H:%M %1" ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1360 label = "log.date" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1361 bn = str( e )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1362 p1 = e.ctx
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1363 while (p1.branch() == bn) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1364 e = p1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1365 p1 = e.p1()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1366 description = e.description()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1367 msg_prefix = ("flow: ", "hgflow: ", "hg flow,", self.msg_prefix or "#@$(&*^$",)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1368 if (not (description.startswith( msg_prefix ))) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1369 lines = [e.strip() for e in description.split( "\n" )]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1370 self.ui.note( " description: %s\n" % lines[0] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1371 for line in lines[1:] :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1372 if (not (line.startswith( msg_prefix ))) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1373 self.ui.note( " %s\n" % lines[0] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1374 self.ui.note( "\n" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1375 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1376 self._print( "No closed %s branches" % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1377
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1378
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1379
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1380 def _action_log( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1381 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1382 Show revision history of the specified branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1383
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1384 @type stream: C{Stream},
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1385 @param stream: Stream where the specified branch is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1386 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1387 # User may specify a file with a relative path name. Since CWD has changed to the repository's root dir when the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1388 # `Flow' object was constructed, we need to restore the original dir to get the correct path name of the file.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1389 os.chdir( self.orig_dir )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1390 filenames = kwarg.pop( "file", [] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1391 onstream = kwarg.pop( "onstream", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1392 closed = kwarg.pop( "closed", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1393 if (onstream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1394 filenames.extend( arg[1:] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1395 branches = stream.branches( "all" if (closed) else "open" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1396 if (stream._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1397 branches.append( stream._trunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1398 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1399 # Case 1: hg flow <stream> log <basename>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1400 # - Shows the log of the "<stream>/<basename>" branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1401 # Case 2: hg flow <stream> log
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1402 # - Case 2a: <stream> does not have a trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1403 # - Shows the log of the current workspace, which should be a branch in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1404 # - Case 2b: <stream> has a trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1405 # - Case 2b1: Current workspace is a branch in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1406 # - Shows the log of the current workspace.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1407 # - Case 2b2: Current workspace is not a branch in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1408 # - Shows the log of <stream>'s trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1409 # Case 3: hg flow <stream> log <filename>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1410 # - This case can be overriden by Case 1. Namely, if the <filename> happens to be the same as the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1411 # <basename>, the latter will take precedence.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1412 # - Case 3a: The current workspace is in <stream>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1413 # - Show the log of <filename> in the current workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1414 # - Case 3b: The current workspace is not in <stream>, and <stream> has a trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1415 # - Show the log of <filename> in <stream>'s trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1416 # - Case 3c: The current workspace is not in <stream>, and <stream> has no trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1417 # - Error
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1418 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1419 branch = stream.get_branch( arg[1] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1420 # Case 1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1421 except error.RepoLookupError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1422 filenames.append( arg[1] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1423 if (self.curr_workspace in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1424 # Case 3a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1425 branch = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1426 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1427 branch = stream.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1428 if (not branch) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1429 # Case 3c
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1430 raise AbortFlow( "Cannot determine branch in %s. Please be more specific." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1431 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1432 # Case 3b
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1433 # Just be clear that we have covered Case 2b2.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1434 pass
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1435 except IndexError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1436 branch = stream.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1437 if (not branch) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1438 # Case 2a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1439 branch = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1440 if (branch not in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1441 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (branch, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1442 "To show log of a %s branch, you must also specify its name." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1443 elif (self.curr_workspace in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1444 # Case 2b1
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1445 branch = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1446 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1447 # Case 2b2
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1448 # Just be clear that we have covered Case 2b2.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1449 pass
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1450 # At this point, `branch` must be existent.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1451 branches = [branch,]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1452
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1453 # OK. We have to explicitly specify the date, rev, and user arguments to prevent mercurial python APIs from crashing.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1454 opts = {"date" : None, "rev" : None, "user" : None, "branch" : branches,}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1455 opts.update( kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1456 self._log( *filenames, **opts )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1457
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1458
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1459
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1460 def _action_abort( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1461 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1462 Abort the workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1463
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1464 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1465 @param stream: Stream where the branch which you want to abort is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1466 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1467 msg = kwarg.pop( "message", "" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1468 should_erase = kwarg.pop( "erase", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1469 onstream = kwarg.pop( "onstream", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1470 curr_workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1471 if (msg) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1472 msg = "%s\n" % msg
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1473 if (curr_workspace.is_develop_trunk()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1474 raise AbortFlow( "You cannot abort the <develop> trunk." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1475 if (onstream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1476 branches = stream.branches()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1477 if (stream == STREAM["develop"]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1478 branches.remove( stream.trunk() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1479 elif (stream._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1480 branches.append( stream.trunk() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1481 for branch in branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1482 if (should_erase) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1483 self._strip( rev = ["branch('%s')" % branch,] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1484 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1485 self._update( branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1486 self._commit( close_branch = True, message = "%s%sAborted %s %s." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1487 (msg, self.msg_prefix, stream, branch.basename( stream, should_quote = True ),) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1488 if (self.curr_workspace != self.orig_workspace and self._orig_workspace not in branches) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1489 self._update( self.orig_workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1490 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1491 if (curr_workspace.is_trunk( stream )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1492 curr_stream = curr_workspace.stream()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1493 raise AbortFlow( "You cannot abort a trunk.",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1494 "To abort '%s' as a branch, use `hg flow %s abort`." % (curr_workspace, curr_stream.name(),)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1495 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1496 if (curr_workspace not in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1497 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (curr_workspace, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1498 "To abort a %s branch, you must first update to it." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1499 if (should_erase) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1500 self._strip( rev = ["branch('%s')" % curr_workspace,] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1501 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1502 self._commit( close_branch = True, message = "%s%sAborted %s '%s'." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1503 (msg, self.msg_prefix, stream, curr_workspace.basename( stream ),) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1504 self._update( stream.trunk( trace = True ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1505 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1506
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1507
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1508
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1509 def _action_promote( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1510 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1511 Promote the workspace branch to its destination stream(s). If there are uncommitted changes in the current branch,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1512 they will be automatically shelved before rebasing and unshelved afterwards.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1513
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1514 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1515 @param stream: Stream where the branch which you want to rebase is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1516 @type rev: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1517 @param rev: If provided, promote this revision instead of the head. The specified revision must be in the workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1518 branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1519 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1520 rev = kwarg.pop( "rev", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1521 tag_name = kwarg.pop( "tag", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1522 message = kwarg.pop( "message", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1523 message = (message + "\n") if (message) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1524 orig_workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1525 has_shelved = False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1526
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1527 if (orig_workspace not in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1528 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (orig_workspace, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1529 "To promote a %s branch, you must first update to it." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1530
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1531 if (rev) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1532 # Ensures `rev` is in workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1533 promoted_branch = Branch( self.ui, self.repo, rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1534 promoted_rev = rev
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1535 promoted_node = promoted_branch.ctx.node()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1536 if (promoted_branch != orig_workspace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1537 raise AbortFlow( "Revision %s is not in workspace branch." % rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1538 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1539 promoted_branch = orig_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1540 promoted_rev = orig_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1541 promoted_ctx = promoted_branch.ctx
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1542 promoted_node = promoted_ctx.node()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1543 # `promoted_node' is `None' if the `promote_ctx' is an instance of `workingctx'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1544 while (promoted_node is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1545 promoted_ctx = promoted_ctx._parents[0]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1546 promoted_node = promoted_ctx.node()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1547
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1548 if (arg[1:]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1549 if (not has_shelved) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1550 self._shelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1551 has_shelved = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1552 for dest in arg[1:] :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1553 self._update( dest )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1554 self._merge ( promoted_rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1555 self._commit( message = message + ("%sPromoted %s '%s' (%s) to '%s'." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1556 (self.msg_prefix, stream, promoted_branch.basename( stream ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1557 short( promoted_node ), dest,)), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1558 if (tag_name) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1559 self._tag( tag_name, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1560 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1561 destin = [STREAM["master"],] if (STREAM["develop"] == stream) else stream.destin()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1562 for s in destin :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1563 if (s == stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1564 continue
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1565 trunk = s.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1566 if (trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1567 if (not has_shelved) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1568 self._shelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1569 has_shelved = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1570 self._update( trunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1571 self._merge ( promoted_rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1572 self._commit( message = message + ("%sPromoted %s '%s' (%s) to '%s'." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1573 (self.msg_prefix, stream, promoted_branch.basename( stream ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1574 short( promoted_node ), trunk,)), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1575 if (tag_name) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1576 self._tag( tag_name, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1577 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1578 self._error( "Cannot determine promote destination." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1579 return
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1580 if (orig_workspace != self.curr_workspace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1581 self._update( orig_workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1582 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1583
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1584
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1585
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1586 def _action_rebase( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1587 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1588 Rebase the workspace branch to its parent branch. If there are uncommitted changes in the current branch, they will be
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1589 automatically shelved before rebasing and unshelved afterwards.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1590
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1591 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1592 @param stream: Stream where the branch which you want to rebase is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1593 @type dest: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1594 @param dest: If provided, use its value as the destination of rebasing. The value must be a changeset of the parent
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1595 branch, otherwise it will trigger an error. If not provided, use the tip of the parent branch as the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1596 destination of rebasing.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1597 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1598 dest = kwarg.get( "dest" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1599 onstream = kwarg.pop( "onstream", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1600 if (onstream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1601 if (not dest) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1602 dest = stream.source().trunk( trace = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1603 branches = stream.branches()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1604 if (stream == STREAM["develop"]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1605 branches.remove( stream.trunk() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1606 elif (stream._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1607 branches.append( stream.trunk() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1608 self._check_rebase()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1609 self._shelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1610 for branch in branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1611 if (dest != branch) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1612 self._rebase( base = branch, dest = dest, keepbranches = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1613 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1614 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1615 curr_workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1616 if (not dest) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1617 dest = stream.trunk( trace = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1618 if (curr_workspace not in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1619 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (curr_workspace, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1620 "To rebase a %s branch, you must first update to it." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1621 if (curr_workspace.is_develop_trunk()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1622 raise AbortFlow( "You cannot rebase the <develop> trunk." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1623 if (dest == curr_workspace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1624 self._warn( "No effects from rebasing a branch to itself" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1625 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1626 self._check_rebase()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1627 self._shelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1628 self._rebase( base = curr_workspace, dest = dest, keepbranches = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1629 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1630
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1631
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1632
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1633 def _update_workspace( self, stream, branch, verbose = True ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1634 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1635 Update the workspace to the given branch. Shelving and unshelving will be conducted automatically.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1636
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1637 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1638 @param stream: Stream where the branch which you are updating the workspace to is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1639 @type branch: C{Branch} or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1640 @param branch: Branch to update the workspace to. No effects if it is C{None}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1641 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1642 if (not branch) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1643 return
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1644
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1645 if (branch == self.curr_workspace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1646 if (verbose) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1647 self._print( "You are already in %s %s." % (stream, branch.basename( stream, should_quote = True ),) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1648 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1649 self._print( "Update workspace to %s %s." % (stream, branch.basename( stream, should_quote = True ),) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1650 self._shelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1651 self._update( branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1652 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1653
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1654
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1655
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1656 def _action_other( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1657 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1658 If the action is the name of a branch in the given stream, we will update workspace to that branch; otherwise, the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1659 action is considered as an error.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1660
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1661 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1662 @param stream: Stream where the branch that we will switch to is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1663 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1664 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1665 name = arg[0]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1666 branch = stream.get_branch( name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1667 if (branch.is_closed()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1668 self._warn( "%s '%s' has been closed." % (stream, name,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1669 self._update_workspace( stream, branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1670 except error.RepoLookupError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1671 misspelling = difflib.get_close_matches( name, ["start", "finish", "push", "publish", "pull",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1672 "list", "log", "abort", "promote", "rebase",], 3, 0.7 )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1673 note = ("Did you mean: %s?" % " or ".join( misspelling )) if (misspelling ) else None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1674 note = ("Did you mean: finish or abort?") if ("close" == name) else note
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1675 note = ("If you meant to create a new branch called '%s' in %s" % (name, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1676 "try command:", " hg flow %s start %s" % (stream.name(), name,),) if (not note) else note
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1677 raise AbortFlow( "Invalid action or unknown branch in %s: '%s'" % (stream, name,), note = note )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1678
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1679
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1680
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1681 def _commit_change( self, opt, commit_hint, is_erasing = False ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1682 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1683 Commit the changes in the workspace.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1684 Note that this method can potentially mutate C{opt}. Specifically, it will delete the C{commit} and C{message} keys if
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1685 they present in C{opt}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1686
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1687 @type opt: C{dict}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1688 @param opt: Option dictionary. Recognizable keys are C{commit} and C{message}. The value of C{commit} should be a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1689 boolean, indicating whether or not to perform committing. The value of C{message} should be a string, which
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1690 will be used as the commit message. It is OK for both of the options to be missing. But it would trigger
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1691 an error if C{message} is given without C{commit} set to true. There is no special treatment on other
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1692 keys, and they will be passed to the C{hg commit} command as is.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1693
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1694 @rtype : C{bool}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1695 @return: Return `True' if committing was successfully done, or `False' if it was not.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1696 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1697 if (opt.get( "commit" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1698 del opt["commit"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1699 msg = opt.get( "message" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1700 if (msg is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1701 opt["force_editor"] = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1702 opt["message"] = "\n\nHG: flow: %s" % commit_hint
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1703 self._commit( **opt )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1704 del opt["message"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1705 if (msg is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1706 del opt["force_editor"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1707 return True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1708 elif (opt.get( "message" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1709 if (is_erasing) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1710 del opt["message"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1711 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1712 raise AbortFlow( "Cannot use the specified commit message.", "Did you forget to specify the -c option?" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1713 return False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1714
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1715
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1716
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1717 def _action_finish( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1718 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1719 Finish a branch in the given stream. The current workspace must be in the branch to be finished, otherwise an error
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1720 will be triggered. The default behavior of finish action is the following:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1721 1. close the branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1722 2. merge the branch to the C{destin} streams.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1723
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1724 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1725 @param stream: Stream where the branch that we will finish is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1726 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1727 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1728 tag_name = arg[1]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1729 self._warn( "You just specified the <tag-name> using the deprecated syntax:" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1730 self._warn( " hg flow <stream> finish <tag-name> [<options>]" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1731 self._warn( "Try using the new syntax to do that in the future: hg flow <stream> finish -t <tag-name>" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1732 self._warn( "Note that hgflow intentionally forbids finishing a non-workspace branch." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1733 except IndexError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1734 tag_name = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1735
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1736 message = kwarg.get( "message", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1737 tag_name = kwarg.pop( "tag", tag_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1738 onstream = kwarg.pop( "onstream", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1739 should_erase = kwarg.pop( "erase", False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1740 curr_workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1741 curr_stream = curr_workspace.stream()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1742 name = curr_workspace.basename( stream, should_quote = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1743 tag_name = tag_name if (tag_name) else (self.version_prefix + name[1:-1])
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1744 develop_stream = STREAM["develop"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1745
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1746 if (should_erase) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1747 if (onstream ) : raise AbortFlow( "'--erase' cannot be used together with '--onstream'." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1748 if (message is None) : raise AbortFlow( "'--message' is required when '--erase' is used." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1749 self._check_strip()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1750
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1751 if (onstream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1752 if (stream in [develop_stream, STREAM["support"], STREAM["hotfix"], STREAM["release"],]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1753 raise AbortFlow( "You cannot finish %s." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1754 branches = stream.branches()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1755 if (stream._trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1756 substream = Stream.gen( self.ui, self.repo, stream.name() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1757 for branch in branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1758 self._update( branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1759 self._action_finish( substream, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1760 self._update( stream.trunk() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1761 self._action_finish( stream, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1762 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1763 for branch in branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1764 self._update( branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1765 self._action_finish( stream, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1766 return
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1767
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1768 if (curr_workspace.is_develop_trunk()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1769 raise AbortFlow( "You cannot finish the <develop> trunk." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1770 elif (curr_workspace not in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1771 raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (curr_workspace, stream,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1772 "To finish a %s branch, you must first update to it." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1773
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1774 # Merges the workspace to its `destin` streams.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1775 destin_with_trunk = []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1776 destin_without_trunk = []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1777 final_branch = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1778 for s in stream.destin() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1779 trunk = s.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1780 if (trunk == curr_workspace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1781 pass
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1782 elif (trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1783 destin_with_trunk.append( s )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1784 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1785 destin_without_trunk.append( s )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1786
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1787 if (should_erase) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1788 if (len( destin_with_trunk + destin_without_trunk ) > 1) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1789 raise AbortFlow( "'--erase' cannot be applied to branches with multiple merge destinations." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1790
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1791 # Commits changes (if any) in the current branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1792 is_commit_done = self._commit_change( kwarg, "Finishing '%s' branch" % curr_workspace, should_erase )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1793
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1794 # If the commit was done successfully, we don't check against uncommitted changes.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1795 # This is particularly needed for dry run.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1796 if (not is_commit_done and self._has_uncommitted_changes()) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1797 raise AbortFlow( "Cannot finish '%s' branch because it has uncommitted changes." % curr_workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1798
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1799 # For destin streams without trunks, we need to create a branch in each of these destin streams.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1800 # Each newly created branch will be named after the pattern: <stream-prefix>/<current-branch-basename> and will be from
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1801 # the current branch. The current branch will be closed. Note that there is no need to merge the current branch because
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1802 # a new branch has been created from it.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1803 for s in destin_without_trunk :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1804 trunk = s.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1805 so_name = "" if ("trunk" == curr_workspace.basename( stream )) else ("/" + curr_workspace.basename( stream ))
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1806 so = Stream( self.ui, self.repo, stream.name() + so_name, trunk = curr_workspace.fullname() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1807 so = "%s:%s" % (so.name(), s.name(),)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1808 basename = curr_workspace.basename()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1809 self.action( so, "start", basename )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1810 final_branch = s.get_fullname( basename )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1811
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1812 if (destin_with_trunk or destin_without_trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1813 # If either list is not empty.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1814 self._update( curr_workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1815 self._commit( close_branch = True, message = "%sClosed %s %s." % (self.msg_prefix, stream, name,), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1816 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1817 # If both lists are empty.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1818 if (stream == STREAM["support"]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1819 self._update( curr_workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1820 self._commit( close_branch = True, message = "%sClosed %s %s." % (self.msg_prefix, stream, name,), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1821 final_branch = STREAM["master"].trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1822 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1823 self._print( "All open branches in %s are finished and merged to its trunk." % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1824 for s in destin_with_trunk :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1825 trunk = s.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1826 self._update( trunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1827 self._merge ( curr_workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1828 self._commit( message = "%sMerged %s %s to %s ('%s')." % (self.msg_prefix, stream, name, s, trunk,), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1829 if (s == STREAM["master"]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1830 self._tag( tag_name )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1831 elif (s in develop_stream and s is not develop_stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1832 tr_stream = trunk.stream()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1833 for ss in tr_stream.destin() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1834 if (ss == develop_stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1835 dvtrunk = develop_stream.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1836 tr_name = trunk.basename( ss )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1837 self._update( dvtrunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1838 self._merge ( trunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1839 self._commit( message = "%sMerged <develop/%s:%s> %s to %s ('%s')." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1840 (self.msg_prefix, tr_name, stream.name(), name, ss, dvtrunk,), **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1841 if (final_branch) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1842 self._update( final_branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1843 if (should_erase) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1844 rev = "p1(.)"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1845 rev = mercurial.scmutil.revsingle( self.repo, rev ).rev()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1846 self._update( "tip" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1847 self._update( rev )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1848 self._revert( rev = "-1", all = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1849 self._strip ( rev = ["branch('%s')" % curr_workspace,] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1850 self._commit( message = message, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1851 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1852
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1853
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1854
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1855 def _execute_action( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1856 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1857 Execute an action on the given stream. If no action is specified, the action will default to I{list}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1858 (see L{_action_list}). The default behavior of an action is defined by the C{_action_*} methods. Custom action behavior
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1859 can be given through the C{action_func} parameter.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1860
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1861 @type stream: C{Stream}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1862 @param stream: Stream where we will execute the action
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1863 @type action_func: C{dict}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1864 @param action_func: Custom action methods. Key (C{str}) is action name, and value is a function that define the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1865 behavior of the custom action.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1866 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1867 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1868 action = arg[0]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1869 except IndexError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1870 action = "list"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1871
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1872 action_func = {
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1873 "start" : self._action_start,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1874 "finish" : self._action_finish,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1875 "push" : self._action_push,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1876 "publish" : self._action_push,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1877 "pull" : self._action_pull,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1878 "list" : self._action_list,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1879 "log" : self._action_log,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1880 "abort" : self._action_abort,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1881 "promote" : self._action_promote,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1882 "rebase" : self._action_rebase,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1883 "other" : self._action_other,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1884 }
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1885
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1886 custom_action_func = kwarg.pop( "action_func", {} )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1887 action_func.update( custom_action_func )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1888
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1889 return action_func.get( action, self._action_other )( stream, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1890
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1891
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1892
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1893 def action( self, stream, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1894 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1895 Execute action on the stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1896 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1897 if (len( arg ) > 0) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1898 action = arg[0]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1899 if (stream == STREAM["master"]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1900 if (action in ["start", "finish", "abort", "rebase",]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1901 raise AbortFlow( "Invalid action for <master>" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1902 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1903 self._update_workspace( stream, stream.trunk(), verbose = False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1904 self._execute_action( stream, *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1905
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1906
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1907
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1908 def print_version( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1909 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1910 Print flow's version and then quit.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1911 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1912 self._print( "version %s" % VERSION )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1913
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1914
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1915
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1916 def unshelve( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1917 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1918 Unshelve the previously shelved changes.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1919 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1920 self.autoshelve = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1921 self._unshelve( *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1922
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1923
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1924
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1925 def print_open_branches( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1926 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1927 Print open branches in each stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1928
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1929 The currently active branch will be marked with a * symbol. Branches where there are shelved changes will be marked
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1930 with a # symbol.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1931 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1932 self._print( "Currently open branches:" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1933 curr_workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1934 stream_names = ["master", "develop", "feature", "release", "hotfix", "support",]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1935 all_branches = self._branches()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1936 for sn in stream_names :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1937 stream = STREAM[sn]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1938 trunk = stream.trunk()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1939 open_branches_in_stream = []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1940 remaining_branches = []
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1941 for e in all_branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1942 if (e in stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1943 open_branches_in_stream.append( e )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1944 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1945 remaining_branches.append( e )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1946 all_branches = remaining_branches
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1947 if (trunk is None and not open_branches_in_stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1948 continue
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1949 self._print( "%-9s: " % stream, newline = False )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1950 if (trunk) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1951 marker = "#" if (self._is_shelved( trunk )) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1952 marker += "*" if (trunk == curr_workspace ) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1953 self.ui.write( "%s%s " % (trunk, marker,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1954 if (trunk in open_branches_in_stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1955 # We need this check because the `trunk' could be closed. See Issue#34.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1956 open_branches_in_stream.remove( trunk )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1957 if (open_branches_in_stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1958 for e in open_branches_in_stream :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1959 marker = "#" if (self._is_shelved( e )) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1960 marker += "*" if (e == curr_workspace ) else ""
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1961 self.ui.write( "%s%s " % (e, marker,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1962 self.ui.write( "\n" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1963
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1964
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1965
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1966 def init( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1967 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1968 Initialize flow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1969 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1970 config_fname = os.path.join( self.repo.root, CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1971 master_stream = "default"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1972 hotfix_stream = "hotfix/"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1973 develop_stream = "develop"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1974 feature_stream = "feature/"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1975 release_stream = "release/"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1976 support_stream = "support/"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1977 has_goodconfig = False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1978
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1979 # Fetches existing condition
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1980 if (os.path.isfile( config_fname )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1981 self._print( "Flow was already initialized for workspace:" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1982 cfg = config.config()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1983 cfg.read( config_fname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1984 SECTION = CONFIG_SECTION_BRANCHNAME
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1985 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1986 master_stream = cfg.get( SECTION, "master" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1987 develop_stream = cfg.get( SECTION, "develop" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1988 feature_stream = cfg.get( SECTION, "feature" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1989 release_stream = cfg.get( SECTION, "release" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1990 hotfix_stream = cfg.get( SECTION, "hotfix" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1991 support_stream = cfg.get( SECTION, "support" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1992 has_goodconfig = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1993 except ConfigParser.NoSectionError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1994 self._error( "Section [%s] not found in configuration file: %s" % (SECTION, config_fname,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1995 self._error( "Your configuration file is probably in old format or corrupt." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1996 except ConfigParser.NoOptionError, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1997 self._error( "%s" % e )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1998 self._error( "Your configuration file is probably corrupt." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1999
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2000 if (has_goodconfig) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2001 self._print( "Repository-specific configuration:" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2002 self._print( "<master> trunk: '%s'" % master_stream, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2003 self._print( "<develop> trunk: '%s'" % develop_stream, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2004 self._print( "<feature> branch prefix: '%s'" % feature_stream, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2005 self._print( "<release> branch prefix: '%s'" % release_stream, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2006 self._print( "<hotfix> branch prefix: '%s'" % hotfix_stream, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2007 self._print( "<support> branch prefix: '%s'" % support_stream, prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2008
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2009 autoshelve = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2010 if (self.ui.has_section( "hgflow" ) or self.ui.has_section( "flow" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2011 self._print( "Global configuration:" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2012 autoshelve = self.ui.configbool( "hgflow", "autoshelve" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2013 if (self.ui.has_section( "flow" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2014 autoshelve = self.ui.configbool( "flow", "autoshelve" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2015 if (not (autoshelve is None)) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2016 self._print( "autoshelve: %s" % ("on" if (autoshelve) else "off"), prefix = " " )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2017
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2018 # Shall we continue if there already exists a configuration file?
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2019 if (has_goodconfig and not kwarg.get( "force" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2020 return
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2021
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2022 print
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2023 mq = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2024 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2025 mq = extensions.find( "mq" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2026 except KeyError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2027 self._warn( "The 'mq' extension is deactivated. You cannot use some features of flow." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2028 print
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2029
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2030 workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2031 branches = self._branches()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2032 if (len( branches ) > 1) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2033 self._warn( "You have the following open branches. Will initialize flow for all of them." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2034 for branch in branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2035 if (branch == workspace) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2036 self._warn( " " + branch.fullname() + " (active)" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2037 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2038 self._warn( " %s" % branch.fullname() )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2039 print
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2040
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2041 # 'status' method returns a 7-member tuple:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2042 # 0 modified, 1 added, 2 removed, 3 deleted, 4 unknown(?), 5 ignored, and 6 clean
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2043 orig_repo_status = self.repo.status()[:4]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2044 for e in orig_repo_status :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2045 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2046 e.remove( CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2047 except ValueError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2048 pass
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2049
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2050 if (any( orig_repo_status )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2051 if (len( branches ) > 1 and not mq) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2052 raise AbortFlow( "Your workspace has uncommitted changes. Cannot initialize flow for all",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2053 " open branches. You can either commit the changes or install the 'mq'",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2054 " extension, and then try again." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2055
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2056 def get_input( stream_name, default ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2057 while (True) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2058 answer = self.ui.prompt( "Branch name for %s stream: [%s]" % (stream_name, default,), default = default )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2059 if (answer.find( ':' ) > -1) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2060 self._error( "Illegal symbol ':' in branch name" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2061 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2062 return answer
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2063
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2064 if (not kwarg.get( "default" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2065 master_stream = get_input( "master", master_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2066 develop_stream = get_input( "develop", develop_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2067 feature_stream = get_input( "feature", feature_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2068 release_stream = get_input( "release", release_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2069 hotfix_stream = get_input( "hotfix", hotfix_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2070 support_stream = get_input( "support", support_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2071
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2072 if (autoshelve is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2073 self._print( """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2074 When you switch to another branch, flow can automatically shelve uncommitted
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2075 changes in workpace right before switching. Later when you switch back, flow can
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2076 automatically unshelve the changes to the workspace. This functionality is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2077 called autoshelve. You need the 'mq' extension to use it.""" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2078 answer = self.ui.prompt( "Do you want to turn it on? [Yes] ", default = "y" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2079 answer = True if (answer.lower() in ["yes", "y", "",]) else False
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2080 if (answer) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2081 self._print( """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2082 Here is what you need to do:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2083 To turn it on for only this repository, edit your <repository-root>/.hg/hgrc
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2084 file by adding the following lines:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2085 [flow]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2086 autoshelve = true
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2087 You can turn it on for all of your repositories by doing the same edition to
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2088 your $HOME/.hgrc file. To turn it off, just edit the corresponding file and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2089 replace 'true' with 'false'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2090 """ )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2091 self.ui.prompt( _("Press Enter to continue initialization...") )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2092
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2093 # Creates configuration.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2094 cfg_contents = ["[%s]" % CONFIG_SECTION_BRANCHNAME,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2095 "master = %s" % master_stream,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2096 "develop = %s" % develop_stream,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2097 "feature = %s" % feature_stream,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2098 "release = %s" % release_stream,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2099 "hotfix = %s" % hotfix_stream,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2100 "support = %s" % support_stream,]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2101 def write_config() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2102 # Writes the configuration in the current branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2103 with open( config_fname, "w" ) as fh :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2104 print >> fh, "\n".join( cfg_contents )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2105 repo_status = self.repo.status( unknown = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2106 if (CONFIG_BASENAME in repo_status[0]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2107 self._commit( config_fname, message = "flow initialization: Modified configuration file." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2108 elif (CONFIG_BASENAME in repo_status[4]) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2109 self._add ( config_fname )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2110 self._commit( config_fname, message = "flow initialization: Added configuration file." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2111
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2112 write_config()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2113
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2114 # Writes the configuration in all the other branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2115 self.autoshelve = True
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2116 self._shelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2117
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2118 if (len( branches ) > 1) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2119 for branch in branches :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2120 if (branch == workspace) : continue
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2121 self._update( branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2122 write_config()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2123 self._update( workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2124
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2125 # Creates 'master' and 'develop' streams if they don't yet exist.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2126 if (not self._find_branch( master_stream )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2127 self._create_branch( master_stream, "flow initialization: Created <master> trunk: %s." % master_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2128 if (not self._find_branch( develop_stream )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2129 self._create_branch( develop_stream, "flow initialization: Created <develop> trunk: %s." % develop_stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2130 self._update( workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2131 self._unshelve()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2132
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2133
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2134
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2135 def upgrade( self, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2136 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2137 Upgrade older version to the latest version.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2138 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2139 self._print( "Upgrade flow's configuration file from v0.9.4 (or older) to v0.9.5 (or latter)." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2140 self._print( "Renaming file '%s' to '%s' in all open branches..." % (OLD_CONFIG_BASENAME, CONFIG_BASENAME,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2141 config_fname = os.path.join( self.repo.root, CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2142 old_config_fname = os.path.join( self.repo.root, OLD_CONFIG_BASENAME )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2143 workspace = self.curr_workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2144 for branch in self._branches() :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2145 self._print( " Branch '%s'..." % branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2146 self._update( branch )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2147 if (os.path.isfile( old_config_fname )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2148 self._rename( old_config_fname, config_fname, force = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2149 self._commit( message = "flow upgrade: Renamed flow's configuration file from '%s' to '%s'." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2150 (OLD_CONFIG_BASENAME, CONFIG_BASENAME,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2151 self._update( workspace )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2152 self._print( "Upgrading done" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2153
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2154
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2155
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2156 def flow_cmd( ui, repo, cmd = None, *arg, **kwarg ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2157 """Flow is a Mercurial extension to support the generalized Driessen's branching model.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2158
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2159 actions:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2160
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2161 - start Open a new branch in the stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2162 - finish Close workspace branch and merge it to destination stream(s).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2163 - push Push workspace branch to the remote repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2164 - publish Same as `push`
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2165 - pull Pull from the remote repository and update workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2166 - list List all open branches in the stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2167 - log Show revision history of branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2168 - promote Merge workspace to other branches. (not closing any branches.)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2169 - rebase Rebase workspace branch to its parent branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2170 - abort Abort branch. Close branch without merging.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2171
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2172 If no action is specified by user, the action will default to `list`. If a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2173 branch name (instead of action) is given after the stream name, Flow will
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2174 switch the current workspace to the branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2175
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2176 commands:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2177
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2178 - init Initialize flow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2179 - unshelve Unshelve the previously shelved changes for workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2180 - upgrade Upgrade the configuration file to v0.9.5 or later.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2181 - help Show help for a specific topic. Example: `hg flow help @help`
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2182 - version Show flow's version number.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2183 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2184 # Supresses bookmarks, otherwise if the name of a bookmark happens to be the same as a named branch, hg will use the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2185 # bookmark's revision.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2186 repo._bookmarks = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2187
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2188 flow = Flow( ui, repo, cmd in ["init", "upgrade", "help",] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2189 func = {
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2190 "init" : flow.init,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2191 "upgrade" : flow.upgrade,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2192 "unshelve" : flow.unshelve,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2193 "help" : Help( ui, repo ).print_help,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2194 "version" : flow.print_version,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2195 None : flow.print_open_branches,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2196 }
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2197
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2198 commands.use_quiet_channel( kwarg.get( "history" ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2199 commands.dryrun ( kwarg.get( "dry_run" ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2200
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2201 if (kwarg.get( "dry_run" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2202 _print( ui, "This is a dry run." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2203 commands.use_quiet_channel( True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2204
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2205 # Registers common options (such as "user").
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2206 common_opts = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2207 for e in ["user",] :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2208 v = kwarg.get( e )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2209 if (v) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2210 common_opts[e] = v
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2211 commands.reg_common_options( common_opts )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2212
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2213 # - Up to this point, `cmd' is a name of command or stream, or `None'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2214 # - We assign `stream' to be a stream name (or `None') and `cmd' to be a name of command or action.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2215 # - When `arg' is a 0-tuple, `cmd' should be "list" as the default action. We use `arg + ("list",)' to ensure we can get
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2216 # the first element.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2217 stream, cmd = (None, cmd) if (cmd in func) else (cmd, (arg + ("list",))[0] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2218
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2219 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2220 # Constructs a `Stream' objects.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2221 # This will also check the validity of the part of user's input that is supposed to specify a stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2222 if (isinstance( stream, str )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2223 source = None
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2224 tokens = stream.split( ':' )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2225 n = len( tokens )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2226 if (n == 2) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2227 source, stream = tokens[0], tokens[1]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2228 if (n > 2 or not stream) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2229 raise AbortFlow( "Invalid stream syntax: '%s'" % stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2230 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2231 stream = Stream.gen( ui, repo, stream, check = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2232 except AbnormalStream, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2233 stream = e.stream()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2234 if (source) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2235 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2236 source = Stream.gen( ui, repo, source, check = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2237 except AbnormalStream, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2238 source = e.stream()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2239 stream = copy.copy( stream )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2240 stream._source = source
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2241 for i, e in enumerate( stream.destin() ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2242 if (source in e ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2243 stream._destin[i] = source
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2244 break
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2245 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2246 stream._destin = [source]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2247
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2248 # Checks the options for all commands and actions.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2249 kwarg = _getopt( ui, cmd, kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2250 stamp = kwarg.pop( "stamp", None )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2251 if (stamp) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2252 def stamp_commit_message( opts ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2253 msg = opts["message"]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2254 if (0 > msg.lower().find( stamp.lower() )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2255 msg += " %s" % stamp
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2256 opts["message"] = msg
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2257 return opts
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2258 commands.reg_option_mutator( "commit", stamp_commit_message )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2259
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2260 func = func.get( cmd, lambda *arg, **kwarg : flow.action( stream, *arg, **kwarg ) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2261 func( *arg, **kwarg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2262 except AbortFlow, e :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2263 errmsg = e.error_message()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2264 _error( ui, *errmsg )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2265 if (getattr( e, "note", None )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2266 _note( ui, *((e.note,) if (isinstance( e.note, str )) else e.note), via_quiet = True )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2267 if (ui.tracebackflag) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2268 if (hasattr( e, "traceback" )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2269 ei = e.traceback
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2270 sys.excepthook( ei[0], ei[1], ei[2] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2271 print
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2272 ei = sys.exc_info()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2273 sys.excepthook( ei[0], ei[1], ei[2] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2274
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2275 commands.print_history()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2276
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2277 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2278 os.chdir( flow.orig_dir )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2279 except :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2280 _print( ui, "The original dir is gone in file system (probably due to updating branch)." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2281 _print( ui, "You are now in the root dir of the repository." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2282
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2283
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2284
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2285 # On Windows, a topic should be wrapped with quotes.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2286 if ("nt" == os.name) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2287 flow_cmd.__doc__ = flow_cmd.__doc__.replace( "help @help", 'help "@help"' )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2288
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2289
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2290
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2291 class Help( object ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2292 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2293 Online help system
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2294 We define all help topics within this class.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2295 We support text effects on help message. See C{colortable} for predefined effects as C{flow.help.*}. To make it easy to use
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2296 text effects, we invented a primitive markdown syntax. For now, we support only the C{flow.help.code}, which will be
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2297 applied to text wrapped with '{{{' and '}}}'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2298 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2299
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2300 SHORT_USAGE = """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2301 flow: a Mercurial workflow extension
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2302
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2303 Usage: {{{hg flow {<stream> [<action> [<arg>...]] | <command>} [<option>...]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2304
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2305 """ + flow_cmd.__doc__
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2306
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2307 TOPIC = {
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2308 "@deprecated" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2309 The following item has been deprecated in this release and will be removed in
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2310 the future:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2311 * [hgflow] The '[hgflow]' section name in hg's configuration file has been
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2312 renamed to '[flow]'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2313 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2314
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2315 "@examples" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2316 {{{> hg flow}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2317 flow: Currently open branches:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2318 flow: <master> : default
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2319 flow: <develop>: develop develop/0.9#
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2320 flow: <feature>: feature/help*
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2321 # Show open branches in all streams. The '*' marker indicates the branch which
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2322 # the workspace is in, and the '#' marker indicates there are shelved changes
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2323 # in the branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2324
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2325 {{{> hg flow feature finish --history}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2326 # Finish the current <feature> branch, and print the history of primitive hg
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2327 # commands used by the workflow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2328
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2329 {{{> hg flow develop/0.9:feature start new_v0.9_feature}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2330 # Start a new feature branch from the 'develop/0.9' branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2331
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2332 {{{> hg flow develop/0.9:feature finish --verbose}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2333 flow: note: Hg command history:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2334 flow: note: hg commit --message "flow: Closed <feature> 'help'." --close-branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2335 flow: note: hg update develop/0.9
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2336 flow: note: hg merge feature/help
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2337 flow: note: hg commit --message "flow: Merged <feature> 'help' to <develop/0.9> ('develop/0.9')."
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2338 flow: note: hg update develop
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2339 flow: note: hg merge develop/0.9
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2340 flow: note: hg commit --message "flow: Merged <develop/0.9:feature> 'help' to <develop> ('develop')."
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2341 # Finish the workspace <feature> branch, merging it to 'develop/0.9', which is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2342 # in turn merged to <develop>'s trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2343 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2344
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2345 "@master" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2346 Master stream contains 1 and only 1 branch that has only and all production
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2347 revisions (i.e., official releases). New revisions in <master> are created when
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2348 a <release> or <hotfix> branch merges into <master>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2349 The following actions can be applied to <master>: push, publish, pull, list,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2350 and log.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2351 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2352
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2353 "@develop" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2354 Develop stream contains all changes made for future releases. <release> and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2355 <feature> branches are started from <develop> and will be merged to <develop>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2356 when finished. Since version 0.9, user can create branches in <develop>. A
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2357 <develop> branch can be used as the source branch to start <release> and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2358 <feature> branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2359 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2360
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2361 "@feature" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2362 Feature stream contains branches where new features for future releases are
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2363 developed. Branches in <feature> are created from either <develop> or an
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2364 existing <feature> branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2365 All actions can be applied to <feature> branches. When a <feature> branch is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2366 finished, it will normally be merged into <develop>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2367 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2368
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2369 "@release" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2370 Release stream contains branches of release candidates. Code in <release> branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2371 will usually be tested and bug-fixed. Once a <release> branch is graduated from
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2372 the testing and bug-fixing process, it will be merged to both <master> and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2373 <develop>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2374 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2375
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2376 "@hotfix" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2377 Hotfix stream contains branches for fixing bugs in <master>. <hotfix> branches
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2378 are started from <master> and once they are finished will be merged to both
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2379 <master> and <develop>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2380 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2381
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2382 "@support" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2383 Support stream contains branches for supporting a previous release. <support>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2384 branches are started from <master> and will never be merged to anywhere. When
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2385 finished, they will be simply closed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2386 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2387
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2388 "@start" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2389 Start a new branch in stream. <feature> and <release> branches are started from
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2390 <develop>. <hotfix> and <support> branches are started from <master>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2391
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2392 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2393 {{{hg flow <stream> start <name> [<option>...]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2394
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2395 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2396 -r --rev REV Revision to start a new branch from.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2397 -m --message TEXT Record TEXT as commit message when opening new branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2398 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2399 -d --date DATE Record the specified DATE as commit date.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2400 -u --user USER Use specified USER as committer.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2401 --dirty Start a new branch from current dirty workspace branch and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2402 move all uncommitted changes to the new branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2403
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2404 The new branch is named after <stream-prefix>/<name>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2405 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2406
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2407 "@finish" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2408 Finishing a branch in stream means to close the branch and merge the branch to
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2409 destination stream(s). <feature> branches will be merged to <develop>, and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2410 <release> and <hotfix> branches will be merged to both <develop> and <master>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2411 <support> branches will not be merged to anywhere, and they will only be closed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2412 Note that merging to a non-trunk <develop> branch will cause the <develop>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2413 branch to be merged into the <develop> trunk.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2414
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2415 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2416 {{{hg flow <stream> finish [<option>...]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2417
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2418 The workspace branch will be finished. Hgflow intentionally forbids finishing
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2419 a branch other than the workspace one, which forces user to update to and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2420 check the branch before finishing it.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2421
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2422 The workspace branch must be in the specified <stream>. When the workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2423 branch is merged into <master>, a new tag will be added to the corresponding
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2424 snapshot in the <master> trunk. User can use the '-t' option to specify the tag
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2425 name; if not specified, the tag name will be derived automatically from the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2426 name of the workspace branch by replacing the stream prefix with the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2427 `version_prefix`. The '-t' option has no effect if the workspace branch is not
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2428 merged into <master>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2429
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2430 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2431 -c --commit Commit changes before closing the branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2432 -m --message TEXT Record TEXT as commit message.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2433 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2434 -t --tag NAME Tag the snapshot in the <master> trunk with NAME.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2435 -d --date DATE Record the specified DATE as commit date.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2436 -u --user USER Use specified USER as committer.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2437 -e --erase Erase branch after it is merged successfully.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2438
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2439 N.B.: RE. '--erase': A branch cannot be erased if it has been previously merged
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2440 to other branches, creating nodes that are not erased together with the branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2441 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2442
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2443 "@push" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2444 Push the workspace branch to the remote repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2445
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2446 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2447 {{{hg flow <stream> push}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2448
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2449 alternative syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2450 {{{hg flow <stream> publish}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2451 The two syntaxes are completely equivalent.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2452
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2453 The workspace branch must be in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2454 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2455
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2456 "@publish" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2457 Push the workspace branch to the remote repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2458
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2459 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2460 {{{hg flow <stream> publish}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2461
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2462 alternative syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2463 {{{hg flow <stream> push}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2464 The two syntaxes are completely equivalent.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2465
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2466 The workspace branch must be in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2467 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2468
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2469 "@pull" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2470 Pull a branch named after <stream-prefix>/<name> from the remote repository and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2471 update the workspace. If <name> is not specified, it defaults to the workspace
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2472 branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2473
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2474 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2475 {{{hg flow <stream> pull [<name>]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2476
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2477 The pulled branch must be in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2478 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2479
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2480 "@list" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2481 List all open branches in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2482
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2483 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2484 {{{hg flow <stream> list}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2485
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2486 alternative syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2487 {{{hg flow <stream>}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2488 If <stream> has trunk (e.g., <develop> and <master>), this syntax will update
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2489 the workspace to the trunk besides listing all open branches in <stream>. If
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2490 <stream> does not have trunk (e.g., <feature>, <release>, <hotfix>, and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2491 <support>), this syntax is completely equivalent to the other one (i.e., only
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2492 list all open branches in the stream).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2493
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2494 option:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2495 -c --closed Show open and closed branches in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2496
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2497 example:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2498 {{{> hg flow hotfix list}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2499 flow: Open <hotfix> branches:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2500 flow: hotfix/0.9.6#
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2501 flow: hotfix/0.9.6/init_-d_option*
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2502 # List all currently open branches in <hotfix>. The '*' marker indicates the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2503 # branch which the workspace is in, and the '#' marker indicates that there are
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2504 # shelved changes for the branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2505 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2506
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2507 "@log" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2508 Show revision history of the specified branch, which must be in <stream>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2509 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2510 {{{hg flow <stream> log [<basename>]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2511 where <basename> is of the branch name, e.g., if a branch's name is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2512 'feature/colored_help', its basename relative to <feature> (assuming the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2513 branch name prefix is 'feature/') is 'colored_help'.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2514 If <basename> is missing, it will default to the workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2515
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2516 Show revision history of a single file in the workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2517 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2518 {{{hg flow <stream> log <filename>}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2519 If <filename> happens to be the same as the basename of a branch in <stream>,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2520 it will be recognized as the basename.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2521
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2522 alternative syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2523 {{{hg flow <stream> log -F <filename>}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2524 Use this syntax to avoid the potential ambiguity with the prior syntax. Also,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2525 you can specify multiple file names to show revision history of these files.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2526
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2527 Show revision history of specified files in a designated branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2528 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2529 {{{hg flow <stream> log <basename> -F <filename>}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2530
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2531 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2532 -F --file FILE [+] File to show history of.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2533 -d --date DATE Show revisions matching date spec.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2534 -u --user USER Show revisions committed by USER.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2535 -k --keyword TEXT Do case-insensitive search for a given text.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2536 -p --patch Show patch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2537 -g --git Use git extended diff format to show patch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2538 -l --limit VALUE Limit number of changesets displayed.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2539 -c --closed Show closed branches when used together with -s option.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2540
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2541 [+] marked option can be specified multiple times.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2542 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2543
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2544 "@abort" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2545 Aborting the workspace branch can be done in two ways:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2546 1. The default way is simply marking the branch as closed so that it will not
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2547 show up when you list alive branches, but all changesets in the branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2548 remain in the repository and you cannot reuse the branch's name for a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2549 different branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2550 2. The other way is erasing the branch, in other words, completely deleting the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2551 branch and all changesets in it from the repository. This way is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2552 devastating, but you can clear unneeded changesets and reuse the branch's
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2553 name. To abort a branch in this way, you just add the {{{-e}}} option.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2554 N.B.: A branch cannot be erased if you have previously merged it to other
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2555 branches that remain in the repository.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2556
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2557 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2558 {{{hg flow <stream> abort [-m <TEXT>] [-e]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2559
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2560 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2561 -m --message TEXT Record TEXT as commit message when closing branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2562 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2563 -e --erase Abort branch and erase it.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2564 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2565
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2566 "@promote" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2567 Merge the workspace branch to destination branches. The destination branches,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2568 if omitted, will default to the trunk of the destination stream. The destination
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2569 streams of the basic streams are listed as follows:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2570
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2571 stream destination
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2572 ------------+-----------------------
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2573 <feature> <develop>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2574 <develop> <master>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2575 <release> <develop> & <master>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2576 <hotfix> <develop> & <master>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2577 <master> n/a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2578 <support> n/a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2579 natural stream-trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2580
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2581 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2582 {{{hg flow <stream> promote [<destination-branch-full-name>...] [<option>...]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2583
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2584 The workspace branch must be in <stream>. If the `-r` option is omitted, its
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2585 value will default to the head of the workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2586
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2587 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2588 -r --rev REV Revision to promote to other branches.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2589 -m --message TEXT Record TEXT as commit message when promoting branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2590 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2591 -t --tag NAME Tag the merging changeset with NAME
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2592 -d --date DATE Record the specified DATE as commit date.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2593 -u --user USER Use specified USER as committer.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2594
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2595 examples:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2596 {{{> hg flow develop promote -t v0.2.0}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2597 # Immediately release <develop> trunk's tip into <master>, bypassing <release>.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2598 # What this command exactly does is to promote the <develop> trunk into
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2599 # <master> (<master> is <develop>'s default promotion destination, so you don't
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2600 # have to spell it out in the command), and then label the <master> snapshot
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2601 # with "v0.2.0".
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2602 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2603
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2604 "@rebase" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2605 Rebase the workspace branch to the specified revision.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2606
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2607 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2608 {{{hg flow <stream> rebase [-d <rev>]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2609
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2610 option:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2611 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2612
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2613 The workspace branch must be in <stream>. If the destination revision is not
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2614 specified, it will default to the source branch of the workspace branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2615 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2616
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2617 "@version" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2618 Show version of the flow extension.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2619
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2620 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2621 {{{hg flow version}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2622 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2623
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2624 "@init" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2625 Initialize the flow extension for the repository. The configuration file:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2626 {{{.hgflow}}} will be written in the root dir of the repository. The file will be
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2627 tracked by hg. If you have multiple open branches, the file should be present
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2628 and synchronized in all of them -- init command will do this for you
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2629 automatically.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2630
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2631 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2632 {{{hg flow init [<option>...]}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2633
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2634 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2635 -f --force Force reinitializing flow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2636 -u --user USER Use specified USER as committer.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2637 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2638 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2639
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2640 "@upgrade" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2641 Upgrade the configuration file from v0.9.4 (or older) to v0.9.5 or later.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2642
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2643 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2644 {{{hg flow upgrade}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2645
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2646 options:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2647 -u --user USER Use specified USER as committer.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2648 -p --stamp TEXT Append TEXT to all commit messages.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2649 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2650
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2651 "@unshelve" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2652 Unshelve previously shelved changes by hgflow. Sometimes, unshelving is not
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2653 automatically executed because workflow is terminated prematurelly. In such
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2654 situations, you can always use the unshelve command to manually restore the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2655 shelved changes.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2656
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2657 syntax:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2658 {{{hg flow unshelve}}}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2659 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2660
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2661 "@terms" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2662 Concepts:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2663 - stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2664 The entire set of branches of the same type. Stream is not branch, it is a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2665 set of branches. In general, a stream can contain any number (including zero)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2666 of branches. The master stream is, however, special in that it contains 1 and
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2667 only 1 branch. The develop stream contains at least one branch.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2668
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2669 - basic streams
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2670 Refers to the master, develop, feature, release, hotfix, and support streams
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2671 as predefined in Driessen's model.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2672
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2673 - natural streams
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2674 Refers to a set of branches that diverged from and will merge into the same
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2675 branch. The set of branches plus the branch that they diverged from form a
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2676 natural stream. The branch that all the other branches in the same natural
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2677 stream diverged from and will merge into is the trunk of the natural stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2678
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2679 - trunk
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2680 Trunk is a special branch. A stream can optionally have a trunk, but only one
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2681 trunk at most. For example, master and develop streams each has a trunk,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2682 whereas feature, release, hotfix, and support streams don't. And all natural
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2683 streams each has a trunk. If a stream has a trunk, all branches in the stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2684 normally should diverge from the trunk and later merge to the trunk when they
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2685 are finished.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2686 Trunk is a relative concept. A trunk of a stream may be a regular branch of
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2687 another stream. (The former stream will be called a substream of the latter.)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2688
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2689 - source
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2690 Source is an attribute of stream. The source of a stream refers to the stream
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2691 where branches in the current stream are created from. A stream's source can
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2692 be the stream itself. But this is not always the case, for example,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2693 the sources of release and feature streams are the develop stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2694
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2695 - destin
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2696 Destin is another attribute of stream. The destin of a stream refers to the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2697 stream(s) where branches in the current stream will merge to. A stream's
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2698 destin can be the stream itself. But this is not always the case,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2699 for example, the destin of release is the develop and the master streams.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2700
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2701 - fullname
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2702 Branch name as recognized by the SCM, e.g., feature/enhance_log.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2703
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2704 - basename
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2705 Branch name recognized by flow, but not necessarily by SCM, e.g.,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2706 enhanced_log (with prefix 'feature/' dropped).
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2707
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2708 - flow action
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2709 Refer to action on a specified stream, e.g., hg flow feature start, where
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2710 'start' is an action.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2711
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2712 - flow command
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2713 Commands don't act on a stream, e.g., hg flow unshelve, where 'unshelve'
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2714 is a command.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2715
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2716 - hg command
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2717 Refer to commands not from flow extension.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2718
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2719 - workflow
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2720 Refer to the process of executing a sequence of hg commands.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2721
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2722 - history
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2723 Refer to a sequence of executed hg commands.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2724
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2725 Notations
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2726 - <stream>
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2727 Examples: <feature>, <hotfix>. These denote the corresponding streams. When
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2728 you refer to a stream, e.g., feature stream, use '<feature>' (or more
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2729 verbosely 'feature stream'), instead of '<feature> stream', because
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2730 '<feature>' already means stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2731
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2732 - <stream> branch
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2733 Example: a <feature> branch. This phrase refers a branch in <feature>. Do not
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2734 use 'a feature branch' to mean a branch in <feature> because the word
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2735 'feature' there should take its usual meaning as in English, which doesn't
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2736 necessarily mean the feature stream.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2737 """,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2738
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2739 "@help" : """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2740 Show online help and then quit. An argument can be optionally given after the
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2741 'help' command to specify a particular help topic. Detailed online help is
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2742 available for the following topics:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2743 @all - Show detailed help for all supported topics.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2744 @<stream> - Show help about a particular stream, e.g., {{{@feature}}}, {{{@master}}}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2745 @<action> - Show help about an action, e.g., {{{@finish,}}} {{{@log}}}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2746 @<command> - Show help about a command, e.g., {{{@help}}}, {{{@unshelve}}}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2747 @terms - Show explanations of terminologies used in hgflow.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2748 @examples - Show a few command examples.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2749 @deprecated - Show a list of deprecated features.%s""" % \
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2750 ("\nOn Windows platform, a topic should be wrapped with quotes, e.g., {{{\"@finish\"}}}." if ("nt" == os.name) else ""),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2751 }
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2752
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2753 def __init__( self, ui, repo ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2754 self.ui = ui
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2755 self.repo = repo
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2756
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2757
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2758
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2759 def _print( self, s ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2760 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2761 Print text with predefined effects.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2762 @type s: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2763 @param s: String to be printed
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2764 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2765 import re
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2766 code_pattern = re.compile( "{{{.*?}}}" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2767 last_span = (0, 0,)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2768 for match in code_pattern.finditer( s ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2769 span = match.span()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2770 self.ui.write( s[last_span[1]:span[0]] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2771 self.ui.write( s[span[0] + 3:span[1] - 3], label = "flow.help.code" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2772 last_span = span
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2773 self.ui.write( s[last_span[1]:] )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2774
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2775
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2776
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2777 def print_help( self, topic = None, *arg, **opts ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2778 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2779 Print help information.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2780
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2781 @type topic : C{str} or C{None}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2782 @param topic : Help topic
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2783 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2784 if (topic is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2785 self._print( self.SHORT_USAGE )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2786 elif (topic == "@all") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2787 doc = self.TOPIC.items()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2788 doc.sort()
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2789 for t, help in doc :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2790 self.ui.write( "%s" % t, label = "flow.help.topic" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2791 self._print( "%s\n" % help )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2792 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2793 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2794 help_content = self.TOPIC[topic]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2795 self.ui.write( "%s" % topic, label = "flow.help.topic" )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2796 self._print( "%s\n" % help_content )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2797 except KeyError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2798 _error( self.ui, "Unknown topic: %s" % topic )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2799 if (("@" + topic) in self.TOPIC or topic == "all") :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2800 _error( self.ui, "Did you mean '@%s'?" % topic )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2801 _print( self.ui, """Supported topics are the following:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2802 @all - Show detailed help for all supported topics.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2803 @<stream> - Show help about a particular stream, e.g., @feature, @master.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2804 @<action> - Show help about an action, e.g., @finish, @log.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2805 @<command> - Show help about a command, e.g., @help, @unshelve.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2806 @<option> - Show help about an option, e.g., @-F, @--history.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2807 @examples - Show a few command examples.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2808 @deprecated - Show a list of deprecated features.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2809 """ )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2810
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2811
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2812
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2813 OPT_FILTER = {
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2814 "init" : ("force", "user", "stamp", "default",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2815 "upgrade" : ("user", "stamp",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2816 "start" : ("rev", "message", "stamp", "date", "user", "dirty",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2817 "finish" : ("commit", "message", "stamp", "tag", "date", "user", "erase", "onstream",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2818 "list" : ("closed",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2819 "log" : ("file", "date", "user", "keyword", "patch", "git", "limit", "graph", "closed", "onstream",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2820 "abort" : ("erase", "message", "stamp", "onstream",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2821 "promote" : ("rev", "message", "stamp", "tag", "date", "user", "onstream",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2822 "rebase" : ("dest", "onstream", "stamp",),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2823 }
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2824
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2825 OPT_CONFLICT = {
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2826 "dest" : ("-d", '', ), # (short-form-of-option, default-value,)
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2827 "date" : ("-d", '', ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2828 "default" : ("-d", False,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2829 "closed" : ("-c", False,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2830 "commit" : ("-c", False,),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2831 "stamp" : ("-p", '' ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2832 "patch" : ("-p", False ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2833 }
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2834
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2835 def _getopt( ui, key, opt ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2836 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2837 Return user-specified options.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2838
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2839 We cannot separate options for different subcommands because of the design of the C{cmdtable}. So ambiguity exists for some
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2840 options. For example, the C{-d} option, it means C{dest} for C{rebase} and C{date} for C{finish}. For either of the two
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2841 actions, the value of the C{-d} option could be saved in C{dest} or C{date}. In general, we don't know which one.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2842
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2843 We have to do a bit of parsing to resolve potential ambiguity. This function is here for that purpose. C{opt} is the raw
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2844 option C{dict} from C{hg}. We will reparse it a bit for a particular command or action given by C{key}. The function
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2845 returns a C{dict} that contains the option's name and its value.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2846 N.B.:
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2847 (1) If the value of an option evaluates to false, the option will be absent in the returned C{dict} object.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2848 (2) This function will mutate and return C{opt}.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2849
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2850 @type ui: C{mercurial.ui}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2851 @param ui: Mercurial user interface object
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2852 @type key: C{str}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2853 @param key: Command or action for which you are getting the options
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2854 @type opt: C{dict}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2855 @param opt: Raw options
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2856
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2857 @raise AbortFlow: AbortFlow exception will be raised if there is option error.
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2858 """
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2859 ret = {}
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2860 rec_short = [] # A list of recoginized short options
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2861 for e in OPT_FILTER.get( key, [] ) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2862 if (opt.get( e )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2863 ret[e] = opt[e]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2864 elif (e in OPT_CONFLICT) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2865 short_opt, default_value = OPT_CONFLICT[e]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2866 argv = sys.argv
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2867 if (short_opt in argv) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2868 rec_short.append( short_opt )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2869 if (isinstance( default_value, str )) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2870 index = argv.index( short_opt )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2871 try :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2872 ret[e] = argv[index + 1]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2873 except IndexError :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2874 raise AbortFlow( "Value not found for %s option." % short_opt )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2875 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2876 ret[e] = not default_value
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2877
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2878 bad_opt = [e for e in opt if (e not in (["history", "dry_run"] + ret.keys()) and opt[e])]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2879 bad_opt = [e for e in bad_opt if (e in sys.argv) or (OPT_CONFLICT.get( e, [0,] )[0] not in rec_short)]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2880
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2881 if (bad_opt) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2882 bad_opt = [e.replace( "_", "-" ) for e in bad_opt]
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2883 if (key is None) :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2884 raise AbortFlow( "Unrecognized option%s for `hg flow`: %s." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2885 ("" if (len( bad_opt ) == 1) else "s", "--" + (", --".join( bad_opt )),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2886 note = "`hg flow` should take no options." )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2887 else :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2888 raise AbortFlow( "Unrecognized option%s for `%s`: %s." %
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2889 ("" if (len( bad_opt ) == 1) else "s", key, "--" + (", --".join( bad_opt )),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2890 note = "Execute `hg flow help @%s` to see available options for `%s`." % (key, key,) )
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2891
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2892 return ret
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2893
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2894
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2895
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2896 cmdtable = {
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2897 "flow" :
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2898 (flow_cmd,
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2899 [("", "history", False, _("Print history of hg commands used in this workflow."), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2900 ("", "dry-run", None, _("Do not perform actions, just print history."), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2901 ("", "dirty", False, _("Start a new branch from a dirty workspace, and move all"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2902 " uncommitted changes to the new branch. [start]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2903 ("c", "closed", False, _("Show normal and closed branches in stream. [list, log]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2904 ("c", "commit", False, _("Commit changes before closing the branch. [finish]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2905 ("d", "default", False, _("Initialize flow with default configuration. [init]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2906 ("d", "date", '', _("Record the specified date as commit date. [start, finish, promote]"), _('DATE'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2907 ("d", "date", '', _("Show revisions matching date spec. [log]"), _('DATE'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2908 ("d", "dest", '', _("Destination changeset of rebasing. [rebase]"), _('REV' ),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2909 ("e", "erase", False, _("Erase branch after it is merged or aborted successfully. [finish, abort]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2910 ("F", "file", [], _("File to show history of. [log]"), _('FILE'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2911 ("f", "force", False, _("Force reinitializing flow. [init]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2912 ("g", "git", False, _("Use git extended diff format to show patch. [log]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2913 ("k", "keyword", '', _("Do case-insensitive search for a given text. [log]"), _('TEXT'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2914 ("l", "limit", '', _("Limit number of changesets displayed. [log]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2915 ("m", "message", '', _("Record TEXT as commit message. [start, finish, promote, abort]"), _('TEXT'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2916 ("p", "stamp", '', _("Append TEXT to all commit messages. [init, upgrade, start, finish,"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2917 " promote, rebase, abort]"), _('TEXT'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2918 ("p", "patch", False, _("Show patch. [log]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2919 ("r", "rev", '', _("Revision to start a new branch from. [start]"), _('REV'), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2920 ("r", "rev", '', _("Revision to promote to other branches. [promote]"), _('REV'), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2921 ("s", "onstream", False, _("Act on stream. [finish, rebase, log, abort]"), ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2922 ("t", "tag", '', _("Tag the merging changeset with NAME. [promote]"), _('NAME'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2923 ("t", "tag", '', _("Tag the <master> trunk with NAME after merging. [finish]"), _('NAME'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2924 ("u", "user", '', _("Use specified user as committer. [init, upgrade, start, finish,"
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2925 " promote]"), _('USER'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2926 ("u", "user", '', _("Show revisions committed by specified user. [log]"), _('USER'),),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2927 ],
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2928 "hg flow {<stream> [<action> [<arg>]] | <command>} [<option>...]",
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2929 ),
ba72a71f23e6 Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2930 }

mercurial