Sat, 19 Mar 2016 15:28:12 -0400
add set-titles
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 |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
6 | # Copyright (C) 2011-2014, Yujie Wu and others |
8
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 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
115 | VERSION = "0.9.8" |
8
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 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
318 | self.reg_option_mutator( "strip", lambda opts : dict( {"rev" : [],}, **opts ) ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
319 | self.reg_option_mutator( "graft", lambda opts : dict( {"rev" : [], "continue" : False,}, **opts ) ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
320 | self.reg_option_mutator( "log", lambda opts : dict( {"date" : None, "user" : None, "rev" : None,}, **opts ) ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
321 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
322 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
323 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
324 | def __getattr__( self, name ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
325 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
326 | 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
|
327 | 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
|
328 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
329 | if (name[0] != "_") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
330 | self._cmd = name |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
331 | return self |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
334 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
335 | def __call__( self, ui, repo, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
336 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
337 | Invoke the mercurial command and save it as a string into the history. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
338 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
339 | @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
|
340 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
341 | self.ui = ui |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
342 | 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
|
343 | arg = self._branch2str( arg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
344 | kwarg = self._branch2str( kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
345 | cmd = self._cmd |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
346 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
347 | if (cmd[0] == "q") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
348 | where = extensions.find( "mq" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
349 | cmd = cmd[1:] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
350 | elif (cmd == "strip" ) : where = extensions.find( "mq" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
351 | elif (cmd == "rebase") : where = extensions.find( "rebase" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
352 | else : where = mercurial.commands |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
353 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
354 | kwarg = self._mutate_options( where, self._cmd, kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
355 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
356 | for key, value in sorted( kwarg.items(), reverse = True ) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
357 | if (value in [None, "", False]) : |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
358 | continue |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
359 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
360 | # 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
|
361 | # `--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
|
362 | # option (it avails only programmatically). |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
363 | 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
|
364 | continue |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
365 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
366 | new_key = "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
367 | for e in key : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
368 | new_key += "-" if (e == "_") else e |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
369 | key = new_key |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
370 | 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
|
371 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
372 | if (isinstance( value, bool )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
373 | cmd_str = "%s --%s" % (cmd_str, key,) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
374 | elif (isinstance( value, list )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
375 | for e in value : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
376 | 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
|
377 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
378 | 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
|
379 | for e in arg : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
380 | 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
|
381 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
382 | self._cmd_history.append( cmd_str ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
383 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
384 | if (self._dryrun) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
385 | return |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
386 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
387 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
388 | # 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
|
389 | if ("strip" == cmd) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
390 | from mercurial import __version__ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
391 | if (__version__.version > "2.8") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
392 | where = extensions.find( "strip" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
393 | cmd = "stripcmd" |
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 | ret = None |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
396 | ret = getattr( where, cmd )( ui, repo, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
397 | except Exception, e : |
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: %s\n" % str( e ), traceback = sys.exc_info() ) |
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 | if (ret and cmd not in ["commit", "rebase",]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
401 | # 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
|
402 | if ((ret, cmd,) not in [(1, "push",),]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
403 | 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
|
404 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
405 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
406 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
407 | def _add_quotes( self, value ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
408 | """ |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
409 | If C{value} is a string that contains space, slash, double quote, and parenthesis (viz: '(' or ')'), wrap it with |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
410 | double quotes and properly escape the double-quotes and slashes within, and finally return the modified string. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
411 | Otherwise, return the value as is. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
412 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
413 | 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
|
414 | new_value = "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
415 | for c in value : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
416 | if (c == "\\") : new_value += "\\\\" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
417 | elif (c == '"' ) : new_value += "\"" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
418 | else : new_value += c |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
419 | value = '"%s"' % new_value |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
420 | return value |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
421 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
422 | |
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 | def _branch2str( self, value ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
425 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
426 | 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
|
427 | 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
|
428 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
429 | if (isinstance( value, Branch )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
430 | return value.fullname() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
431 | if (isinstance( value, (list, tuple,) )) : |
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 e in value : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
434 | new_value.append( self._branch2str( e ) ) |
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 | if (isinstance( value, dict )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
437 | new_value = {} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
438 | for k, v in value.items() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
439 | new_value[k] = self._branch2str( v ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
440 | return new_value |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
441 | return value |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
442 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
445 | def _filter_common_options( self, where, cmd ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
446 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
447 | 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
|
448 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
449 | @type where: module |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
450 | @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
|
451 | @type cmd : C{str} |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
452 | @param cmd : Mercurial command name |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
453 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
454 | ret = {} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
455 | if (self._common_opts != {}) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
456 | if (cmd[-1] == "_") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
457 | cmd = cmd[:-1] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
458 | 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
|
459 | opts = [e[1] for e in table[1]] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
460 | for e in self._common_opts : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
461 | if (e in opts) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
462 | ret[e] = self._common_opts[e] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
463 | return ret |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
467 | def _mutate_options( self, where, cmd, opts ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
468 | """ |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
469 | Call the registered command option mutator for the command and return the modified command options. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
470 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
471 | @type where: module |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
472 | @param where: Should be `mercurial.commands', or a Mercurial's plugin object. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
473 | @type cmd : C{str} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
474 | @param cmd : Mercurial command name |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
475 | @type opts : C{dict} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
476 | @param opts : Original command options |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
477 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
478 | @rtype: C{dict} |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
479 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
480 | common_opts = self._filter_common_options( where, cmd ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
481 | common_opts.update( opts ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
482 | opts = common_opts |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
483 | mutator = self._opt_mutator.get( cmd ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
484 | if (mutator) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
485 | opts = mutator( opts ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
486 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
487 | return opts |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
488 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
491 | def use_quiet_channel( self, via_quiet = True ) : |
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 | 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
|
494 | C{--verbose} option. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
495 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
496 | @type via_quiet: C{bool} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
497 | @param via_quiet: To turn off using the "quiet" channel for history printing, you can call this function like: |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
498 | C{use_quiet_channel( False )}. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
499 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
500 | self._via_quiet = via_quiet |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
501 | |
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 | def use_verbose_channel( self, via_verbose = True ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
505 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
506 | Print the history to the I{verbose} channel, where text will be display only when user specify the C{--verbose} option. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
507 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
508 | @type via_verbose: C{bool} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
509 | @param via_verbose: To turn off using the "verbose" channel for history printing (you will be using the "quiet" |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
510 | channel instead), you can call this function like: C{use_verbose_channel( False )}. |
8
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._via_quiet = not via_verbose |
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 reg_common_options( self, opts ) : |
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 | Register common options. |
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 opts: C{dict} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
521 | @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
|
522 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
523 | self._common_opts.update( opts ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
524 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
525 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
526 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
527 | def reg_option_mutator( self, cmd, mutator ) : |
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 | Register common options. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
530 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
531 | @type cmd : C{str} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
532 | @param cmd : Mercurial command name |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
533 | @type mutator: Callable object |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
534 | @param mutator: It will take a C{dict} object as its argument and return another C{dict} object that is supposed to be |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
535 | a mutant of the former. The input object is supposed to be the original hg-command options in form of |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
536 | key-value pairs. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
537 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
538 | self._opt_mutator[cmd] = mutator |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
542 | def dryrun( self, switch = None ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
543 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
544 | Switch the dry-run mode. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
545 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
546 | @type switch: C{boolean} or C{None} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
547 | @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
|
548 | return the current state of dry-run mode. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
549 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
550 | if (switch is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
551 | return self._dryrun |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
552 | self._dryrun = switch |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
553 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
554 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
555 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
556 | def print_history( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
557 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
558 | Print the command history using the L{_note} function. |
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 | if (self.ui) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
561 | _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
|
562 | for e in self._cmd_history : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
563 | _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
|
564 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
565 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
566 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
567 | class Stream( object ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
568 | @staticmethod |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
569 | def gen( ui, repo, name, check = False ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
570 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
571 | 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
|
572 | 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
|
573 | 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
|
574 | 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
|
575 | get the object. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
576 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
577 | @type name : C{str} |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
578 | @param name : Name of the stream. It can be a complex stream name, e.g., "develop/spring:release". |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
579 | @type check: C{boolean} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
580 | @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
|
581 | or not and (if exists) open or not. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
582 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
583 | @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
|
584 | @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
|
585 | """ |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
586 | source = None |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
587 | tokens = name.split( ':' ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
588 | n = len( tokens ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
589 | if (n == 2) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
590 | source, name = tokens[0], tokens[1] |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
591 | if (n > 2 or not name) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
592 | raise AbortFlow( "Invalid stream syntax: '%s'" % stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
593 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
594 | for e in STREAM.values() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
595 | if (name == e.name()) : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
596 | if (source) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
597 | stream = copy.copy( e ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
598 | break |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
599 | else : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
600 | return e |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
601 | else : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
602 | rootstream_name = name.split( '/', 1 )[0] |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
603 | is_normalstream = True |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
604 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
605 | if (rootstream_name in STREAM) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
606 | trunk = name.replace( rootstream_name + '/', STREAM[rootstream_name].prefix(), 1 ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
607 | stream = Stream( ui, repo, name, trunk = trunk ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
608 | else : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
609 | stream = Stream( ui, repo, name, trunk = name ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
610 | is_normalstream = False |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
611 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
612 | if (check) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
613 | try : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
614 | trunk = stream.trunk() |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
615 | except error.RepoLookupError , e : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
616 | misspelling = difflib.get_close_matches( stream.name(), STREAM.keys(), 3, 0.7 ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
617 | note = "Did you mean: %s?" % " or ".join( misspelling ) if (misspelling) else None |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
618 | raise AbortFlow( "Stream not found: %s" % stream, note = note ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
619 | if (trunk.is_closed()) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
620 | raise AbortFlow( "%s has been closed." % stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
621 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
622 | # It seems we never really mind abnormal streams. So comment this out. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
623 | #if (not is_normalstream) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
624 | # raise AbnormalStream( stream = Stream( ui, repo, name ) ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
625 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
626 | if (source) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
627 | source = Stream.gen( ui, repo, source, check = True ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
628 | stream = copy.copy( stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
629 | stream._source = source |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
630 | for i, e in enumerate( stream.destin() ) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
631 | if (source in e) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
632 | stream._destin[i] = source |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
633 | break |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
634 | else : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
635 | stream._destin = [source] |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
636 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
637 | return stream |
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 | |
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 | def __init__( self, ui, repo, name, **kwarg ) : |
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 | Create a new C{Stream} object. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
644 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
645 | @type name : C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
646 | @param name : Name of the new stream |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
647 | @type trunk : C{str} or C{None} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
648 | @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
|
649 | @type prefix: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
650 | @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
|
651 | 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
|
652 | @type source: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
653 | @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
|
654 | @type destin: C{list} of C{Stream} objects |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
655 | @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
|
656 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
657 | self.ui = ui |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
658 | self.repo = repo |
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 | self._name = name |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
661 | self._trunk = kwarg.get( "trunk" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
662 | self._prefix = kwarg.get( "prefix" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
663 | self._source = kwarg.get( "source", self ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
664 | self._destin = kwarg.get( "destin", [self._source,] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
665 | 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
|
666 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
667 | if (self._prefix is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
668 | if (self._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
669 | self._prefix = self._trunk + '/' |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
670 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
671 | self._prefix = self._name + '/' |
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 | |
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 | def __str__( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
676 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
677 | Return a string: '<stream-name>'. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
678 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
679 | return "<%s>" % self._name |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
680 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
681 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
682 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
683 | def __cmp__( self, rhs ) : |
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 | Compare streams by comparing their names as strings. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
686 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
687 | lhs = self._name |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
688 | rhs = rhs ._name |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
689 | 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
|
690 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
693 | def __contains__( self, stranch ) : |
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 | 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
|
696 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
697 | @type stranch: C{Stream} or C{Branch} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
698 | @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
|
699 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
700 | if (isinstance( stranch, Branch )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
701 | if (stranch._fullname == self._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
702 | return True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
703 | return stranch._fullname.startswith( self.prefix() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
704 | elif (isinstance( stranch, Stream )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
705 | return stranch.prefix().startswith( self.prefix() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
706 | return str( stranch ).startswith( self.prefix() ) |
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 | |
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 | def name( self ) : |
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 the name of this stream. |
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 | return self._name |
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 | |
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 | def trunk( self, trace = False ) : |
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 | 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
|
721 | C{trace} parameter. |
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 | @type trace: C{boolean} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
724 | @param trace: If true and this stream has no trunk, return the trunk of the source stream, and do this recursively |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
725 | until a trunk is found. If false and this stream has no trunk, this function will return C{None}. |
8
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 | @return: A C{Branch} object or C{None} |
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 | if (self._tcache) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
730 | return self._tcache |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
731 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
732 | 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
|
733 | if (not trunk and trace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
734 | return self.source().trunk( True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
735 | self._tcache = trunk |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
736 | return trunk |
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 | |
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 | def prefix( self ) : |
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 | Return the branch name prefix of this stream. |
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: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
745 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
746 | return self._prefix |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
747 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
748 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
749 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
750 | def source( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
751 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
752 | Return the source stream. |
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 | @return: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
755 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
756 | return self._source |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
757 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
758 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
759 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
760 | def destin( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
761 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
762 | 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
|
763 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
764 | @return: C{Stream} |
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 | return self._destin |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
767 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
768 | |
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 | def get_fullname( self, branch_basename ) : |
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 | Return the fullname of a branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
773 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
774 | @type branch_basename: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
775 | @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
|
776 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
777 | @return: C{str} |
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 | return self._prefix + branch_basename |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
780 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
783 | def get_branch( self, branch_basename ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
784 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
785 | 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
|
786 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
787 | @type branch_basename: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
788 | @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
|
789 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
790 | @return: C{Branch} |
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 | 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
|
793 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
794 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
795 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
796 | def branches( self, openclosed = "open" ) : |
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 | 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
|
799 | The returned list is sorted per branch name. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
800 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
801 | @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
|
802 | @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
|
803 | 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
|
804 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
805 | if (openclosed not in ["open", "closed", "all",]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
806 | raise ValueError( "Invalid value for `openclosed` parameter: %s" % openclosed ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
807 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
808 | all_branches = [] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
809 | if (openclosed == "open") : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
810 | for branch_fullname, heads in self.repo.branchmap().items() : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
811 | all_branches += [Branch( self.ui, self.repo, head ) for head in heads |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
812 | if (not self.repo[head].extra().get( "close", False ))] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
813 | elif (openclosed == "closed") : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
814 | for branch_fullname, heads in self.repo.branchmap().items() : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
815 | all_branches += [Branch( self.ui, self.repo, head ) for head in heads |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
816 | if (self.repo[head].extra().get( "close", False ))] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
817 | else : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
818 | for branch_fullname, heads in self.repo.branchmap().items() : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
819 | all_branches += [Branch( self.ui, self.repo, head ) for head in heads] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
820 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
821 | 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
|
822 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
823 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
824 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
825 | class Branch( object ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
826 | def __init__( self, ui, repo, rev = None ) : |
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 | 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
|
829 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
830 | self.ui = ui |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
831 | self.repo = repo |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
832 | 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
|
833 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
834 | self._fullname = str( self.ctx.branch() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
835 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
836 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
837 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
838 | def __str__( self ) : |
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 | Return the fullname of this branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
841 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
842 | return self._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
843 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
846 | def __cmp__( self, rhs ) : |
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 | Compare two C{Branch} object by comparing their fullnames. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
849 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
850 | if (rhs is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
851 | return 1 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
852 | lhs = self._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
853 | rhs = rhs ._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
854 | 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
|
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
858 | def fullname( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
859 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
860 | Return the fullname of this branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
861 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
862 | return self._fullname |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
866 | def basename( self, stream = None, should_quote = False ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
867 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
868 | 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
|
869 | not contain any '/'s). |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
870 | 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
|
871 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
872 | @type stream: C{Stream} or C{None} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
873 | @param stream: Stream to which the basename is relative |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
874 | @type should_quote: C{bool} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
875 | @param should_quote: The returned string will be wrapped with single quotes ' if this parameter's value is true. |
8
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 | if (stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
878 | if (self._fullname == stream._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
879 | return "trunk" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
880 | ret = self._fullname[len( stream.prefix() ):] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
881 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
882 | ret = self._fullname.rsplit( '/', 1 )[-1] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
883 | if (should_quote) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
884 | ret = "'%s'" % ret |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
885 | return ret |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
886 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
887 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
888 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
889 | def rev_node( self ) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
890 | """ |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
891 | Return a string showing this branch's head's revision number and short node ID in the format of "<rev>:<node-ID>", |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
892 | e.g., "9:db14bf692069". |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
893 | """ |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
894 | return "%s:%s" % (self.ctx.rev(), short( self.ctx.node() ),) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
895 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
896 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
897 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
898 | def is_closed( self ) : |
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 | 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
|
901 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
902 | extra = self.ctx.extra() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
903 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
904 | return extra["close"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
905 | except KeyError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
906 | return False |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
907 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
908 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
909 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
910 | def is_open( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
911 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
912 | 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
|
913 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
914 | return not self.is_closed() |
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 | |
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 | def is_develop_trunk( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
919 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
920 | 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
|
921 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
922 | return STREAM["develop"]._trunk == self._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
923 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
924 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
925 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
926 | def is_master_trunk( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
927 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
928 | 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
|
929 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
930 | return STREAM["master"]._trunk == self._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
931 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
932 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
933 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
934 | def is_trunk( self, stream ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
935 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
936 | 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
|
937 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
938 | return stream._trunk == self._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
939 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
940 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
941 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
942 | def stream( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
943 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
944 | Return the stream that this branch belongs to. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
945 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
946 | name = self._fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
947 | for stream in STREAM.values() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
948 | if (name == stream._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
949 | return stream |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
950 | if (name.startswith( stream.prefix() )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
951 | name = name.replace( stream.prefix(), stream.name() + '/' ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
952 | break |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
953 | 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
|
954 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
957 | commands = Commands() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
958 | 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
|
959 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
960 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
961 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
962 | class Flow( object ) : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
963 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
964 | ACTION_NAME = ["start", "finish", "push", "publish", "pull", "list", "log", "abort", "promote", "rebase", "rename",] |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
965 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
966 | def __init__( self, ui, repo, init = False ) : |
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 | 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
|
969 | 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
|
970 | 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
|
971 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
972 | @type init: C{boolean} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
973 | @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
|
974 | 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
|
975 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
976 | self.ui = ui |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
977 | self.repo = repo |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
978 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
979 | self.autoshelve = False |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
980 | self.warn_uncommitted = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
981 | self.msg_prefix = "flow: " |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
982 | self.version_prefix = "v" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
983 | self.orig_workspace = Branch( ui, repo ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
984 | 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
|
985 | self.orig_dir = os.getcwd() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
986 | self._dryrun_shelve = set() |
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 | if (init) : return |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
989 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
990 | 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
|
991 | if (os.path.isfile( config_fname )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
992 | cfg = config.config() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
993 | cfg.read( config_fname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
994 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
995 | master = cfg.get( CONFIG_SECTION_BRANCHNAME, "master" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
996 | develop = cfg.get( CONFIG_SECTION_BRANCHNAME, "develop" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
997 | feature = cfg.get( CONFIG_SECTION_BRANCHNAME, "feature" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
998 | release = cfg.get( CONFIG_SECTION_BRANCHNAME, "release" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
999 | hotfix = cfg.get( CONFIG_SECTION_BRANCHNAME, "hotfix" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1000 | support = cfg.get( CONFIG_SECTION_BRANCHNAME, "support" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1001 | except Exception, e : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1002 | self._error( str( e ) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1003 | 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
|
1004 | 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
|
1005 | sys.exit( 1 ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1006 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1007 | 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
|
1008 | if (os.path.isfile( old_config_fname )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1009 | cfg = config.config() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1010 | cfg.read( old_config_fname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1011 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1012 | master = cfg.get( CONFIG_SECTION_BRANCHNAME, "master" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1013 | develop = cfg.get( CONFIG_SECTION_BRANCHNAME, "develop" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1014 | feature = cfg.get( CONFIG_SECTION_BRANCHNAME, "feature" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1015 | release = cfg.get( CONFIG_SECTION_BRANCHNAME, "release" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1016 | hotfix = cfg.get( CONFIG_SECTION_BRANCHNAME, "hotfix" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1017 | support = cfg.get( CONFIG_SECTION_BRANCHNAME, "support" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1018 | except Exception, e : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1019 | self._error( str( e ) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1020 | self._error( "Flow has not been initialized properly for this repository." ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1021 | self._note ( "You can use command `hg flow init -f` to reinitialize for this repository.", |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1022 | via_quiet = True ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1023 | sys.exit( 1 ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1024 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1025 | 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
|
1026 | 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
|
1027 | sys.exit( 1 ) |
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 | global STREAM |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1030 | STREAM["master" ] = Stream( ui, repo, "master", trunk = master ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1031 | STREAM["develop"] = Stream( ui, repo, "develop", trunk = develop ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1032 | 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
|
1033 | 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
|
1034 | 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
|
1035 | 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
|
1036 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1037 | STREAM["develop"]._destin.append( STREAM["release"] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1038 | STREAM["release"]._destin.append( STREAM["master" ] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1039 | STREAM["hotfix" ]._destin.append( STREAM["develop"] ) |
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 | if (ui.has_section( "hgflow" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1042 | 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
|
1043 | 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
|
1044 | self.autoshelve = ui.configbool( "hgflow", "autoshelve", self.autoshelve ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1045 | 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
|
1046 | if (ui.has_section( "flow" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1047 | self.autoshelve = ui.configbool( "flow", "autoshelve", self.autoshelve ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1048 | 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
|
1049 | 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
|
1050 | 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
|
1051 | if (self._has_uncommitted_changes() and self.warn_uncommitted) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1052 | self._warn( "Your workspace has uncommitted changes." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1053 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1054 | # 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
|
1055 | # 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
|
1056 | # 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
|
1057 | os.chdir( self.repo.root ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1058 | # __init__ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1059 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1062 | def __getattr__( self, name ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1063 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1064 | Execute mercurial command of name C{name[1:]}. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1065 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1066 | @type name: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1067 | @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
|
1068 | use C{self._commit}. |
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 | if (name[0] == "_") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1071 | cmd = getattr( commands, name[1:] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1072 | def func( *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1073 | cmd( self.ui, self.repo, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1074 | return func |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1075 | 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
|
1076 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1079 | def _update( self, rev, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1080 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1081 | 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
|
1082 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1083 | @type rev: C{str} or C{mercurial.changectx} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1084 | @param rev: Revision to which the workspace will update |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1085 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1086 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1087 | old_workspace_ctx = self.curr_workspace.ctx |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1088 | 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
|
1089 | except error.RepoLookupError, e : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1090 | if (commands.dryrun()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1091 | commands.update( self.ui, self.repo, rev, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1092 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1093 | raise e |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1094 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1095 | if (old_workspace_ctx != self.curr_workspace.ctx) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1096 | commands.update( self.ui, self.repo, rev, *arg, **kwarg ) |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1100 | def _print( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1101 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1102 | Thin wrapper of the global C{_print} function |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1103 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1104 | _print( self.ui, *arg, **kwarg ) |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1107 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1108 | def _warn( self, *arg, **kwarg ) : |
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 | Thin wrapper of the global C{_warn} function |
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 | _warn( self.ui, *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 | |
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 | def _error( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1117 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1118 | Thin wrapper of the global C{_error} function |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1119 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1120 | _error( self.ui, *arg, **kwarg ) |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1123 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1124 | def _note( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1125 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1126 | Thin wrapper of the global C{_note} function |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1127 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1128 | _note( self.ui, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1129 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1130 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1131 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1132 | def _check_rebase( self ) : |
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 | 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
|
1135 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1136 | @raise AbortFlow: When 'rebase' extension is not found |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1137 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1138 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1139 | extensions.find( "rebase" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1140 | except KeyError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1141 | raise AbortFlow( "Cannot rebase without 'rebase' extension." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1142 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1145 | def _check_mq( self ) : |
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 | 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
|
1148 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1149 | @raise AbortFlow: When 'mq' extension is not found |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1150 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1151 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1152 | extensions.find( "mq" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1153 | except KeyError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1154 | raise AbortFlow( "Cannot shelve/unshelve changes without 'mq' extension." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1155 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1156 | |
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 | def _check_strip( self ) : |
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 | The 'strip' command comes with the 'mq' extension. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1161 | 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
|
1162 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1163 | @raise AbortFlow: When 'mq' extension is not found |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1164 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1165 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1166 | extensions.find( "mq" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1167 | except KeyError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1168 | raise AbortFlow( "Cannot use 'strip' command without 'mq' extension." ) |
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 | |
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 | def _is_shelved( self, branch ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1173 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1174 | Return true if the given branch has been shelved. |
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 | @type branch: C{Branch} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1177 | @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
|
1178 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1179 | shelve_name = "flow/" + branch.fullname() + ".pch" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1180 | patch_fname = self.repo.join( "patches/" + shelve_name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1181 | return os.path.isfile( patch_fname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1182 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1183 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1184 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1185 | def _shelve( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1186 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1187 | Shelve workspace if C{self.autoshelve} is C{True}. |
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 | 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
|
1190 | C{hg qnew <patchname> --currentuser --currentdate -m "Shelved changes"} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1191 | C{hg qpop} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1192 | where <patchname> follows the pattern: flow/<branch_fullname>.pch |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1193 | 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
|
1194 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1195 | if (self.autoshelve or kwarg.get( "force" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1196 | if (self._has_uncommitted_changes()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1197 | shelve_name = "flow/" + self.curr_workspace.fullname() + ".pch" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1198 | if (commands.dryrun()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1199 | # 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
|
1200 | # 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
|
1201 | self._dryrun_shelve.add( shelve_name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1202 | self._check_mq() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1203 | 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
|
1204 | self._qpop() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1205 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1208 | def _unshelve( self, basename = None, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1209 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1210 | 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
|
1211 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1212 | 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
|
1213 | C{hg import <patch_filename> --no-commit} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1214 | C{hg qdelete <patchname>} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1215 | 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
|
1216 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1217 | @type basename: C{str} |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1218 | @param basename: Basename of the path of the shelved patch file. Default is the name of current workspace branch. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1219 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1220 | if (self.autoshelve or kwarg.get( "force" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1221 | basename = basename if (basename) else self.curr_workspace.fullname() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1222 | shelve_name = "flow/" + basename + ".pch" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1223 | patch_fname = self.repo.join( "patches/" + shelve_name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1224 | 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
|
1225 | self._check_mq() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1226 | 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
|
1227 | self._qdelete( shelve_name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1228 | if (commands.dryrun()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1229 | self._dryrun_shelve.discard( shelve_name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1230 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1233 | def _has_uncommitted_changes( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1234 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1235 | 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
|
1236 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1237 | return any( self.repo.status() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1238 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1239 | |
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 | def _branches( self, openclosed = "open" ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1242 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1243 | Return a list of branches. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1244 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1245 | @type openclosed: C{str}, "open", "closed", and "all" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1246 | @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
|
1247 | return all branches. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1248 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1249 | if (openclosed not in ["open", "closed", "all",]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1250 | raise ValueError( "Invalid value for openclosed parameter: %s" % openclosed ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1251 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1252 | all_branches = [] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1253 | if (openclosed == "open") : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1254 | for branch_fullname, heads in self.repo.branchmap().items() : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1255 | all_branches += [Branch( self.ui, self.repo, head ) for head in heads |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1256 | if (not self.repo[head].extra().get( "close", False ))] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1257 | elif (openclosed == "closed") : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1258 | for branch_fullname, heads in self.repo.branchmap().items() : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1259 | all_branches += [Branch( self.ui, self.repo, head ) for head in heads |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1260 | if (self.repo[head].extra().get( "close", False ))] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1261 | else : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1262 | for branch_fullname, heads in self.repo.branchmap().items() : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1263 | all_branches += [Branch( self.ui, self.repo, head ) for head in heads] |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1264 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1265 | return all_branches |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1266 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1267 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1268 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1269 | def _find_branch( self, fullname ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1270 | """ |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1271 | Try to find a branch of name: C{fullname}. If it exists, return a C{Branch} object of this branch and a boolean value |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1272 | indicating if it's open (C{True}) or closed (C{False}). If it does not exists, return C{(None, None)}. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1273 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1274 | @type fullname: C{str} |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1275 | @param fullname: Fullname of the branch to find |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1276 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1277 | try : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1278 | branch = Branch( self.ui, self.repo, fullname ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1279 | return branch, branch.is_open() |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1280 | except error.RepoLookupError : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1281 | return None, None |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1282 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1283 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1284 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1285 | def latest_master_tags( self ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1286 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1287 | Return the latest tag of C{<master>} branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1288 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1289 | trunk = STREAM["master"].trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1290 | trunk_fullname = trunk.fullname() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1291 | master_context = trunk.ctx |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1292 | while (master_context) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1293 | tags = master_context.tags() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1294 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1295 | tags.remove( "tip" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1296 | except ValueError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1297 | pass |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1298 | if (tags) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1299 | return tags |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1300 | parents = master_context.parents() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1301 | master_context = None |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1302 | for e in parents : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1303 | if (trunk_fullname == e.branch()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1304 | master_context = e |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1305 | break |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1306 | return [] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1307 | |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1310 | 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
|
1311 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1312 | Create a new branch and commit the change. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1313 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1314 | @type fullname: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1315 | @param fullname: Fullname of the new branch |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1316 | @type message: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1317 | @param message: Commit message |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1318 | @type from_branch: C{Branch} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1319 | @param from_branch: Parent branch of the new branch |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1320 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1321 | if (from_branch and self.curr_workspace != from_branch) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1322 | self._update( from_branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1323 | self._branch( fullname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1324 | self._commit( message = message, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1325 | if (commands.dryrun()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1326 | # Makes a fake new branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1327 | self.curr_workspace = Branch( self.ui, self.repo ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1328 | self.curr_workspace._fullname = fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1329 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1330 | self.curr_workspace = Branch( self.ui, self.repo, fullname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1331 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1332 | |
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 | def _action_start( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1335 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1336 | 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
|
1337 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1338 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1339 | @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
|
1340 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1341 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1342 | basename = arg[1] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1343 | except IndexError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1344 | 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
|
1345 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1346 | rev = kwarg.pop( "rev", None ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1347 | msg = kwarg.pop( "message", "" ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1348 | dirty = kwarg.pop( "dirty", None ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1349 | fullname = stream.get_fullname( basename ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1350 | br, is_open = self._find_branch( fullname ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1351 | if (br) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1352 | self._error( "A branch named '%s' already exists in %s: '%s'." % (basename, stream, fullname,) ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1353 | if (not is_open) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1354 | self._note( "Branch '%s' is currently closed." % fullname, via_quiet = True ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1355 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1356 | shelvedpatch_basename = self.curr_workspace.fullname() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1357 | if (rev is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1358 | from_branch = stream.source().trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1359 | self._shelve( force = dirty ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1360 | self._update( from_branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1361 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1362 | from_branch = Branch( self.ui, self.repo, rev ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1363 | if (from_branch._fullname != stream.source()._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1364 | 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
|
1365 | self._shelve( force = dirty ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1366 | self._update( rev = rev ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1367 | if (msg) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1368 | msg = "%s\n" % msg |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1369 | 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
|
1370 | if (dirty) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1371 | self._unshelve( shelvedpatch_basename, force = dirty ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1372 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1373 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1374 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1375 | def _action_push( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1376 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1377 | 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
|
1378 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1379 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1380 | @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
|
1381 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1382 | if (self.curr_workspace in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1383 | 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
|
1384 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1385 | 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
|
1386 | "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
|
1387 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1388 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1389 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1390 | def _action_pull( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1391 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1392 | 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
|
1393 | remote repository. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1394 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1395 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1396 | @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
|
1397 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1398 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1399 | branch = stream.get_fullname( arg[1] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1400 | except IndexError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1401 | branch = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1402 | if (branch not in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1403 | 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
|
1404 | "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
|
1405 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1406 | self._pull( update = True, branch = [branch,] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1407 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1408 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1409 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1410 | def _action_list( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1411 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1412 | Print all open branches in the given stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1413 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1414 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1415 | @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
|
1416 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1417 | # Lists all open branches in this stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1418 | open_branches = stream.branches() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1419 | trunk = stream.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1420 | if (trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1421 | tags = "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1422 | if (stream == STREAM["master"]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1423 | tags = self.latest_master_tags() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1424 | tags = (", latest tags: %s" % ", ".join( tags )) if (tags) else "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1425 | self._print( "%s trunk: %s%s" % (stream, trunk, tags,) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1426 | if (open_branches) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1427 | self._print( "Open %s branches:" % stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1428 | for e in open_branches : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1429 | marker = "#" if (self._is_shelved( e ) ) else "" |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1430 | marker += "*" if (e == self.curr_workspace) else "" |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1431 | marker += " %s" % e.rev_node() |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1432 | self._print( str( e ) + marker, prefix = " " ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1433 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1434 | self._print( "No open %s branches" % stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1435 | if (kwarg.get( "closed" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1436 | closed_branches = stream.branches( "closed" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1437 | if (closed_branches) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1438 | self._print( "Closed %s branches:" % stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1439 | 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
|
1440 | for e in closed_branches : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1441 | self.ui.write( "%-31s" % e.basename( stream ), label = "branches.closed" ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1442 | self.ui.write( " %18s" % e.rev_node(), label = "log.changeset" ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1443 | 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
|
1444 | label = "log.date" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1445 | bn = str( e ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1446 | p1 = e.ctx |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1447 | while (p1.branch() == bn) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1448 | e = p1 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1449 | p1 = e.p1() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1450 | description = e.description() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1451 | 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
|
1452 | if (not (description.startswith( msg_prefix ))) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1453 | lines = [e.strip() for e in description.split( "\n" )] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1454 | self.ui.note( " description: %s\n" % lines[0] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1455 | for line in lines[1:] : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1456 | if (not (line.startswith( msg_prefix ))) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1457 | self.ui.note( " %s\n" % lines[0] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1458 | self.ui.note( "\n" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1459 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1460 | self._print( "No closed %s branches" % stream ) |
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 | |
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 | def _action_log( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1465 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1466 | Show revision history of the specified branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1467 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1468 | @type stream: C{Stream}, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1469 | @param stream: Stream where the specified branch is |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1470 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1471 | # 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
|
1472 | # `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
|
1473 | os.chdir( self.orig_dir ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1474 | filenames = kwarg.pop( "file", [] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1475 | onstream = kwarg.pop( "onstream", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1476 | closed = kwarg.pop( "closed", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1477 | if (onstream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1478 | filenames.extend( arg[1:] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1479 | branches = stream.branches( "all" if (closed) else "open" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1480 | if (stream._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1481 | branches.append( stream._trunk ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1482 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1483 | # Case 1: hg flow <stream> log <basename> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1484 | # - Shows the log of the "<stream>/<basename>" branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1485 | # Case 2: hg flow <stream> log |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1486 | # - Case 2a: <stream> does not have a trunk |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1487 | # - 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
|
1488 | # - Case 2b: <stream> has a trunk |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1489 | # - Case 2b1: Current workspace is a branch in <stream>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1490 | # - Shows the log of the current workspace. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1491 | # - 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
|
1492 | # - Shows the log of <stream>'s trunk. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1493 | # Case 3: hg flow <stream> log <filename> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1494 | # - 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
|
1495 | # <basename>, the latter will take precedence. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1496 | # - Case 3a: The current workspace is in <stream> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1497 | # - 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
|
1498 | # - 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
|
1499 | # - Show the log of <filename> in <stream>'s trunk. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1500 | # - 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
|
1501 | # - Error |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1502 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1503 | branch = stream.get_branch( arg[1] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1504 | # Case 1 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1505 | except error.RepoLookupError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1506 | filenames.append( arg[1] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1507 | if (self.curr_workspace in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1508 | # Case 3a |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1509 | branch = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1510 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1511 | branch = stream.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1512 | if (not branch) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1513 | # Case 3c |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1514 | 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
|
1515 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1516 | # Case 3b |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1517 | # Just be clear that we have covered Case 2b2. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1518 | pass |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1519 | except IndexError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1520 | branch = stream.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1521 | if (not branch) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1522 | # Case 2a |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1523 | branch = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1524 | if (branch not in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1525 | 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
|
1526 | "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
|
1527 | elif (self.curr_workspace in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1528 | # Case 2b1 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1529 | branch = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1530 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1531 | # Case 2b2 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1532 | # Just be clear that we have covered Case 2b2. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1533 | pass |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1534 | # At this point, `branch` must be existent. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1535 | branches = [branch,] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1536 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1537 | opts = {"branch" : branches,} |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1538 | opts.update( kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1539 | self._log( *filenames, **opts ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1540 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1541 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1542 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1543 | def _action_abort( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1544 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1545 | Abort the workspace branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1546 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1547 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1548 | @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
|
1549 | """ |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1550 | arg = arg[1:] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1551 | msg = kwarg.pop( "message", "" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1552 | should_erase = kwarg.pop( "erase", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1553 | onstream = kwarg.pop( "onstream", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1554 | curr_workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1555 | if (msg) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1556 | msg = "%s\n" % msg |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1557 | if (curr_workspace.is_develop_trunk()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1558 | raise AbortFlow( "You cannot abort the <develop> trunk." ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1559 | if (arg) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1560 | if (len( arg ) > 1 or curr_workspace.basename() != arg[0]) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1561 | raise AbortFlow( "hgflow intentionally forbids aborting a non-workspace branch." ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1562 | if (onstream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1563 | branches = stream.branches() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1564 | if (stream == STREAM["develop"]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1565 | branches.remove( stream.trunk() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1566 | elif (stream._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1567 | branches.append( stream.trunk() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1568 | for branch in branches : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1569 | if (should_erase) : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1570 | self._strip( branch, self.repo.revs( "min(branch('%s'))" % branch )[0] ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1571 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1572 | self._update( branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1573 | 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
|
1574 | (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
|
1575 | 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
|
1576 | self._update( self.orig_workspace ) |
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 | if (curr_workspace.is_trunk( stream )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1579 | curr_stream = curr_workspace.stream() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1580 | raise AbortFlow( "You cannot abort a trunk.", |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1581 | "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
|
1582 | ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1583 | if (curr_workspace not in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1584 | 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
|
1585 | "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
|
1586 | if (should_erase) : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1587 | self._strip( curr_workspace, self.repo.revs( "min(branch('%s'))" % curr_workspace )[0] ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1588 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1589 | 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
|
1590 | (msg, self.msg_prefix, stream, curr_workspace.basename( stream ),) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1591 | self._update( stream.trunk( trace = True ) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1592 | self._unshelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1593 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1594 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1595 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1596 | def _action_promote( self, stream, *arg, **kwarg ) : |
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 | 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
|
1599 | 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
|
1600 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1601 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1602 | @param stream: Stream where the branch which you want to rebase is |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1603 | @type rev : C{str} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1604 | @param rev : If provided, promote this revision instead of the head. The specified revision must be in the workspace |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1605 | branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1606 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1607 | rev = kwarg.pop( "rev", None ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1608 | tag_name = kwarg.pop( "tag", None ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1609 | message = kwarg.pop( "message", None ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1610 | message = (message + "\n") if (message) else "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1611 | orig_workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1612 | has_shelved = False |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1613 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1614 | if (orig_workspace not in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1615 | 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
|
1616 | "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
|
1617 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1618 | if (rev) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1619 | # Ensures `rev` is in workspace branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1620 | promoted_branch = Branch( self.ui, self.repo, rev ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1621 | promoted_rev = rev |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1622 | promoted_node = promoted_branch.ctx.node() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1623 | if (promoted_branch != orig_workspace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1624 | 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
|
1625 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1626 | promoted_branch = orig_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1627 | promoted_rev = orig_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1628 | promoted_ctx = promoted_branch.ctx |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1629 | promoted_node = promoted_ctx.node() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1630 | # `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
|
1631 | while (promoted_node is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1632 | promoted_ctx = promoted_ctx._parents[0] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1633 | promoted_node = promoted_ctx.node() |
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 | if (arg[1:]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1636 | if (not has_shelved) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1637 | self._shelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1638 | has_shelved = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1639 | for dest in arg[1:] : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1640 | self._update( dest ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1641 | self._merge ( promoted_rev ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1642 | 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
|
1643 | (self.msg_prefix, stream, promoted_branch.basename( stream ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1644 | short( promoted_node ), dest,)), **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1645 | if (tag_name) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1646 | self._tag( tag_name, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1647 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1648 | 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
|
1649 | for s in destin : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1650 | if (s == stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1651 | continue |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1652 | trunk = s.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1653 | if (trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1654 | if (not has_shelved) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1655 | self._shelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1656 | has_shelved = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1657 | self._update( trunk ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1658 | self._merge ( promoted_rev ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1659 | 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
|
1660 | (self.msg_prefix, stream, promoted_branch.basename( stream ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1661 | short( promoted_node ), trunk,)), **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1662 | if (tag_name) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1663 | self._tag( tag_name, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1664 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1665 | self._error( "Cannot determine promote destination." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1666 | return |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1667 | if (orig_workspace != self.curr_workspace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1668 | self._update( orig_workspace ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1669 | self._unshelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1670 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1671 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1672 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1673 | def _action_rebase( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1674 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1675 | 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
|
1676 | automatically shelved before rebasing and unshelved afterwards. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1677 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1678 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1679 | @param stream: Stream where the branch which you want to rebase is |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1680 | @type dest : C{str} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1681 | @param dest : If provided, use its value as the destination of rebasing. The value must be a changeset of the parent |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1682 | 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
|
1683 | destination of rebasing. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1684 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1685 | dest = kwarg.get( "dest" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1686 | onstream = kwarg.pop( "onstream", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1687 | if (onstream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1688 | if (not dest) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1689 | dest = stream.source().trunk( trace = True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1690 | branches = stream.branches() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1691 | if (stream == STREAM["develop"]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1692 | branches.remove( stream.trunk() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1693 | elif (stream._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1694 | branches.append( stream.trunk() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1695 | self._check_rebase() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1696 | self._shelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1697 | for branch in branches : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1698 | if (dest != branch) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1699 | self._rebase( base = branch, dest = dest, keepbranches = True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1700 | self._unshelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1701 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1702 | curr_workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1703 | if (not dest) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1704 | dest = stream.trunk( trace = True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1705 | if (curr_workspace not in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1706 | 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
|
1707 | "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
|
1708 | if (curr_workspace.is_develop_trunk()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1709 | raise AbortFlow( "You cannot rebase the <develop> trunk." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1710 | if (dest == curr_workspace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1711 | 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
|
1712 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1713 | self._check_rebase() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1714 | self._shelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1715 | self._rebase( base = curr_workspace, dest = dest, keepbranches = True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1716 | self._unshelve() |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1717 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1718 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1719 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1720 | def _action_rename( self, stream, *arg, **kwarg ) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1721 | """ |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1722 | Rename the workspace branch to a new basename. If there are uncommitted changes in the current branch, they will be |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1723 | automatically shelved before renaming and unshelved afterwards. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1724 | Under the hood this action will create a new branch and copy (or graft) all commits in the workspace branch to the new |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1725 | branch and then erase the workspace branch. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1726 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1727 | @type stream: C{Stream} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1728 | @param stream: Stream where the branch which you want to rename is |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1729 | @type to : C{str} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1730 | @param to : Its value should be the new basename of the workspace branch. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1731 | """ |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1732 | new_branch_name = kwarg.pop( "to", None ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1733 | curr_workspace = self.curr_workspace |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1734 | if (not new_branch_name) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1735 | raise AbortFlow( "Please specify the new base name of this branch via the `-t` option." ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1736 | if (curr_workspace not in stream) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1737 | raise AbortFlow( "Your workspace is '%s' branch, which is not in %s." % (curr_workspace, stream,), |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1738 | "To rename a %s branch, you must first update to it." % stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1739 | if (curr_workspace.is_trunk( stream )) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1740 | raise AbortFlow( "You cannot rename the trunk of %s." % stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1741 | if (new_branch_name == curr_workspace.basename( stream )) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1742 | self._warn( "No effects because the supposed new basename turns out to be the same as the current one." ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1743 | else : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1744 | cfn = curr_workspace.fullname() |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1745 | brn = "branch(%s)" % cfn |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1746 | rev = "min(%s)" % brn |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1747 | ctx = self.repo[self.repo.revs( rev )[0]] |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1748 | nfn = stream.get_fullname( new_branch_name ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1749 | msg = ctx.description() |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1750 | msg = msg.replace( cfn, nfn ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1751 | self._shelve() |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1752 | self._update( self.repo.revs( "%s^" % rev )[0] ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1753 | self._create_branch( nfn, msg, user = ctx.user(), date = util.datestr( ctx.date() ) ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1754 | self._graft( curr_workspace, **kwarg ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1755 | self._unshelve( cfn ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1756 | self._strip( curr_workspace, int( ctx ) ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1757 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1758 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1759 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1760 | def _update_workspace( self, stream, branch, verbose = True ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1761 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1762 | 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
|
1763 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1764 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1765 | @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
|
1766 | @type branch: C{Branch} or C{None} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1767 | @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
|
1768 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1769 | if (not branch) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1770 | return |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1771 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1772 | if (branch == self.curr_workspace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1773 | if (verbose) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1774 | 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
|
1775 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1776 | 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
|
1777 | self._shelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1778 | self._update( branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1779 | self._unshelve() |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1780 | self._print( "Parent of working directory: %s" % branch.rev_node() ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1781 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1782 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1783 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1784 | def _action_other( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1785 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1786 | 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
|
1787 | action is considered as an error. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1788 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1789 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1790 | @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
|
1791 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1792 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1793 | name = arg[0] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1794 | branch = stream.get_branch( name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1795 | if (branch.is_closed()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1796 | self._warn( "%s '%s' has been closed." % (stream, name,) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1797 | self._update_workspace( stream, branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1798 | except error.RepoLookupError : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1799 | misspelling = difflib.get_close_matches( name, Flow.ACTION_NAME, 3, 0.7 ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1800 | 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
|
1801 | note = ("Did you mean: finish or abort?") if ("close" == name) else note |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1802 | if (stream != STREAM["master"]) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1803 | note = ("If you meant to create a new branch called '%s' in %s" % (name, stream,), |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1804 | "try command:", " hg flow %s start %s" % (stream.name(), name,),) if (not note) else note |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1805 | 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
|
1806 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1807 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1808 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1809 | 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
|
1810 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1811 | Commit the changes in the workspace. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1812 | 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
|
1813 | they present in C{opt}. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1814 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1815 | @type opt: C{dict} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1816 | @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
|
1817 | 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
|
1818 | 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
|
1819 | 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
|
1820 | 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
|
1821 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1822 | @rtype : C{bool} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1823 | @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
|
1824 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1825 | if (opt.get( "commit" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1826 | del opt["commit"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1827 | msg = opt.get( "message" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1828 | if (msg is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1829 | opt["force_editor"] = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1830 | opt["message"] = "\n\nHG: flow: %s" % commit_hint |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1831 | self._commit( **opt ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1832 | del opt["message"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1833 | if (msg is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1834 | del opt["force_editor"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1835 | return True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1836 | elif (opt.get( "message" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1837 | if (is_erasing) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1838 | del opt["message"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1839 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1840 | 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
|
1841 | return False |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1842 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1843 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1844 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1845 | def _action_finish( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1846 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1847 | 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
|
1848 | 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
|
1849 | 1. close the branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1850 | 2. merge the branch to the C{destin} streams. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1851 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1852 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1853 | @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
|
1854 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1855 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1856 | tag_name = arg[1] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1857 | 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
|
1858 | self._warn( " hg flow <stream> finish <tag-name> [<options>]" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1859 | 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
|
1860 | 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
|
1861 | except IndexError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1862 | tag_name = None |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1863 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1864 | message = kwarg.get( "message", None ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1865 | tag_name = kwarg.pop( "tag", tag_name ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1866 | onstream = kwarg.pop( "onstream", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1867 | should_erase = kwarg.pop( "erase", False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1868 | curr_workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1869 | curr_stream = curr_workspace.stream() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1870 | name = curr_workspace.basename( stream, should_quote = True ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1871 | tag_name_orig = tag_name |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1872 | 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
|
1873 | develop_stream = STREAM["develop"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1874 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1875 | if (should_erase) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1876 | 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
|
1877 | 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
|
1878 | self._check_strip() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1879 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1880 | if (onstream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1881 | 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
|
1882 | raise AbortFlow( "You cannot finish %s." % stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1883 | branches = stream.branches() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1884 | if (stream._trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1885 | substream = Stream.gen( self.ui, self.repo, stream.name() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1886 | for branch in branches : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1887 | self._update( branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1888 | self._action_finish( substream, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1889 | self._update( stream.trunk() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1890 | self._action_finish( stream, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1891 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1892 | for branch in branches : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1893 | self._update( branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1894 | self._action_finish( stream, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1895 | return |
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 (curr_workspace.is_develop_trunk()) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1898 | raise AbortFlow( "You cannot finish the <develop> trunk." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1899 | elif (curr_workspace not in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1900 | 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
|
1901 | "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
|
1902 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1903 | # Merges the workspace to its `destin` streams. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1904 | destin_with_trunk = [] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1905 | destin_without_trunk = [] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1906 | final_branch = None |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1907 | for s in stream.destin() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1908 | trunk = s.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1909 | if (trunk == curr_workspace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1910 | pass |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1911 | elif (trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1912 | destin_with_trunk.append( s ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1913 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1914 | destin_without_trunk.append( s ) |
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 | if (should_erase) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1917 | if (len( destin_with_trunk + destin_without_trunk ) > 1) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1918 | 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
|
1919 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1920 | # Commits changes (if any) in the current branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1921 | 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
|
1922 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1923 | # 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
|
1924 | # This is particularly needed for dry run. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1925 | 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
|
1926 | 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
|
1927 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1928 | # For destin streams without trunks, we need to create a branch in each of these destin streams. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1929 | # Each newly created branch will be from the current branch and named after the pattern: |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1930 | # <stream-prefix>/<current-branch-basename>. Afterwards, the current branch will be closed. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1931 | # Note that there is no need to merge the current branch because the new branch is created from it. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1932 | for s in destin_without_trunk : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1933 | trunk = s.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1934 | so_name = "" if ("trunk" == curr_workspace.basename( stream )) else ("/" + curr_workspace.basename( stream )) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1935 | so = Stream ( self.ui, self.repo, stream.name() + so_name, trunk = curr_workspace.fullname() ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1936 | so = Stream.gen( self.ui, self.repo, "%s:%s" % (so.name(), s.name(),), check = True ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1937 | basename = curr_workspace.basename() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1938 | self.action( so, "start", basename ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1939 | final_branch = s.get_fullname( basename ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1940 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1941 | if (destin_with_trunk or destin_without_trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1942 | # If either list is not empty. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1943 | self._update( curr_workspace ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1944 | 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
|
1945 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1946 | # If both lists are empty. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1947 | if (stream == STREAM["support"]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1948 | self._update( curr_workspace ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1949 | 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
|
1950 | final_branch = STREAM["master"].trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1951 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1952 | self._print( "All open branches in %s are finished and merged to its trunk." % stream ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1953 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1954 | if (tag_name_orig and (STREAM["master"] not in destin_with_trunk)) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1955 | self._warn( "You specified a tag name, but it has effect only when the workspace branch is merged to <master>." ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1956 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1957 | for s in destin_with_trunk : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1958 | trunk = s.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1959 | self._update( trunk ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1960 | self._merge ( curr_workspace ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1961 | 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
|
1962 | if (s == STREAM["master"]) : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1963 | self._tag( tag_name, force = True ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1964 | 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
|
1965 | tr_stream = trunk.stream() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1966 | for ss in tr_stream.destin() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1967 | if (ss == develop_stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1968 | dvtrunk = develop_stream.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1969 | tr_name = trunk.basename( ss ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1970 | self._update( dvtrunk ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1971 | self._merge ( trunk ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1972 | 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
|
1973 | (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
|
1974 | if (final_branch) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1975 | self._update( final_branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1976 | if (should_erase) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1977 | rev = "p1(.)" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1978 | rev = mercurial.scmutil.revsingle( self.repo, rev ).rev() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1979 | self._update( "tip" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1980 | self._update( rev ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1981 | self._revert( rev = "-1", all = True ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
1982 | self._strip ( curr_workspace, self.repo.revs( "min(branch('%s'))" % curr_workspace )[0] ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1983 | self._commit( message = message, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1984 | self._unshelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1985 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1986 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1987 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1988 | def _execute_action( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1989 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1990 | 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
|
1991 | (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
|
1992 | can be given through the C{action_func} parameter. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1993 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1994 | @type stream: C{Stream} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1995 | @param stream: Stream where we will execute the action |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1996 | @type action_func: C{dict} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
1997 | @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
|
1998 | behavior of the custom action. |
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 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2001 | action = arg[0] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2002 | except IndexError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2003 | action = "list" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2004 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2005 | action_func = { |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2006 | "start" : self._action_start, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2007 | "finish" : self._action_finish, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2008 | "push" : self._action_push, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2009 | "publish" : self._action_push, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2010 | "pull" : self._action_pull, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2011 | "list" : self._action_list, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2012 | "log" : self._action_log, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2013 | "abort" : self._action_abort, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2014 | "promote" : self._action_promote, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2015 | "rebase" : self._action_rebase, |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2016 | "rename" : self._action_rename, |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2017 | "other" : self._action_other, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2018 | } |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2019 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2020 | custom_action_func = kwarg.pop( "action_func", {} ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2021 | action_func.update( custom_action_func ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2022 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2023 | 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
|
2024 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2025 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2026 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2027 | def action( self, stream, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2028 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2029 | Execute action on the stream. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2030 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2031 | @type stream: C{Stream} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2032 | @param stream: Stream where we will execute the action |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2033 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2034 | if (len( arg ) > 0) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2035 | action = arg[0] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2036 | if (stream == STREAM["master"]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2037 | if (action in ["start", "finish", "abort", "rebase",]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2038 | raise AbortFlow( "Invalid action for <master>" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2039 | else : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2040 | trunk = stream.trunk() |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2041 | self._update_workspace( stream, trunk, verbose = False ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2042 | self._execute_action( stream, *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2043 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2044 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2045 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2046 | def print_version( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2047 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2048 | Print flow's version and then quit. |
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 | self._print( "version %s" % VERSION ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2051 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2052 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2053 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2054 | def unshelve( self, *arg, **kwarg ) : |
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 | Unshelve the previously shelved changes. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2057 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2058 | self.autoshelve = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2059 | self._unshelve( *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2060 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2061 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2062 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2063 | def print_open_branches( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2064 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2065 | Print open branches in each stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2066 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2067 | 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
|
2068 | with a # symbol. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2069 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2070 | self._print( "Currently open branches:" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2071 | curr_workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2072 | stream_names = ["master", "develop", "feature", "release", "hotfix", "support",] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2073 | all_branches = self._branches() |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2074 | name_branches = {} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2075 | for branch in all_branches : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2076 | name_branches.setdefault( branch.fullname(), [] ).append( branch ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2077 | name_branches = sorted( name_branches.items() ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2078 | for sn in stream_names : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2079 | stream = STREAM[sn] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2080 | trunk = stream.trunk() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2081 | open_branches_in_stream = [] |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2082 | for name, heads in name_branches : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2083 | e = heads[0] |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2084 | if (e in stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2085 | open_branches_in_stream.append( e ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2086 | 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
|
2087 | continue |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2088 | self._print( "%-9s: " % stream, newline = False ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2089 | if (trunk) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2090 | marker = "#" if (self._is_shelved( trunk )) else "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2091 | marker += "*" if (trunk == curr_workspace ) else "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2092 | self.ui.write( "%s%s " % (trunk, marker,) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2093 | if (trunk in open_branches_in_stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2094 | # 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
|
2095 | open_branches_in_stream.remove( trunk ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2096 | if (open_branches_in_stream) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2097 | for e in open_branches_in_stream : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2098 | marker = "#" if (self._is_shelved( e )) else "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2099 | marker += "*" if (e == curr_workspace ) else "" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2100 | self.ui.write( "%s%s " % (e, marker,) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2101 | self.ui.write( "\n" ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2102 | if (sum( [len( heads ) - 1 for name, heads in name_branches] )) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2103 | self._print( "\n", newline = False ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2104 | self._print( "Multihead branches:" ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2105 | for name, heads in name_branches : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2106 | if (len( heads ) > 1) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2107 | self._print( " %s" % name ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2108 | for head in heads : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2109 | self._print( " %s" % head.rev_node() ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2110 | |
8
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2113 | def init( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2114 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2115 | Initialize flow. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2116 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2117 | 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
|
2118 | master_stream = "default" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2119 | hotfix_stream = "hotfix/" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2120 | develop_stream = "develop" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2121 | feature_stream = "feature/" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2122 | release_stream = "release/" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2123 | support_stream = "support/" |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2124 | has_goodconfig = False |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2125 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2126 | # Fetches existing condition |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2127 | if (os.path.isfile( config_fname )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2128 | self._print( "Flow was already initialized for workspace:" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2129 | cfg = config.config() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2130 | cfg.read( config_fname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2131 | SECTION = CONFIG_SECTION_BRANCHNAME |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2132 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2133 | master_stream = cfg.get( SECTION, "master" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2134 | develop_stream = cfg.get( SECTION, "develop" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2135 | feature_stream = cfg.get( SECTION, "feature" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2136 | release_stream = cfg.get( SECTION, "release" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2137 | hotfix_stream = cfg.get( SECTION, "hotfix" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2138 | support_stream = cfg.get( SECTION, "support" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2139 | has_goodconfig = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2140 | except ConfigParser.NoSectionError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2141 | 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
|
2142 | 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
|
2143 | except ConfigParser.NoOptionError, e : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2144 | self._error( "%s" % e ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2145 | self._error( "Your configuration file is probably corrupt." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2146 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2147 | if (has_goodconfig) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2148 | self._print( "Repository-specific configuration:" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2149 | self._print( "<master> trunk: '%s'" % master_stream, prefix = " " ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2150 | self._print( "<develop> trunk: '%s'" % develop_stream, prefix = " " ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2151 | self._print( "<feature> branch prefix: '%s'" % feature_stream, prefix = " " ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2152 | self._print( "<release> branch prefix: '%s'" % release_stream, prefix = " " ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2153 | self._print( "<hotfix> branch prefix: '%s'" % hotfix_stream, prefix = " " ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2154 | self._print( "<support> branch prefix: '%s'" % support_stream, prefix = " " ) |
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 | autoshelve = None |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2157 | 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
|
2158 | self._print( "Global configuration:" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2159 | autoshelve = self.ui.configbool( "hgflow", "autoshelve" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2160 | if (self.ui.has_section( "flow" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2161 | autoshelve = self.ui.configbool( "flow", "autoshelve" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2162 | if (not (autoshelve is None)) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2163 | 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
|
2164 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2165 | # 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
|
2166 | if (has_goodconfig and not kwarg.get( "force" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2167 | return |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2168 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2169 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2170 | mq = None |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2171 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2172 | mq = extensions.find( "mq" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2173 | except KeyError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2174 | 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
|
2175 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2176 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2177 | workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2178 | branches = self._branches() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2179 | if (len( branches ) > 1) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2180 | 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
|
2181 | for branch in branches : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2182 | if (branch == workspace) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2183 | self._warn( " " + branch.fullname() + " (active)" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2184 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2185 | self._warn( " %s" % branch.fullname() ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2186 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2187 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2188 | # 'status' method returns a 7-member tuple: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2189 | # 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
|
2190 | orig_repo_status = self.repo.status()[:4] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2191 | for e in orig_repo_status : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2192 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2193 | e.remove( CONFIG_BASENAME ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2194 | except ValueError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2195 | pass |
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 | if (any( orig_repo_status )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2198 | if (len( branches ) > 1 and not mq) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2199 | 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
|
2200 | " 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
|
2201 | " extension, and then try again." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2202 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2203 | def get_input( stream_name, default ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2204 | while (True) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2205 | 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
|
2206 | if (answer.find( ':' ) > -1) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2207 | self._error( "Illegal symbol ':' in branch name" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2208 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2209 | return answer |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2210 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2211 | if (not kwarg.get( "default" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2212 | master_stream = get_input( "master", master_stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2213 | develop_stream = get_input( "develop", develop_stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2214 | feature_stream = get_input( "feature", feature_stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2215 | release_stream = get_input( "release", release_stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2216 | hotfix_stream = get_input( "hotfix", hotfix_stream ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2217 | support_stream = get_input( "support", support_stream ) |
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 | if (autoshelve is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2220 | self._print( """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2221 | 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
|
2222 | 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
|
2223 | 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
|
2224 | 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
|
2225 | 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
|
2226 | 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
|
2227 | if (answer) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2228 | self._print( """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2229 | Here is what you need to do: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2230 | 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
|
2231 | file by adding the following lines: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2232 | [flow] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2233 | autoshelve = true |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2234 | 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
|
2235 | 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
|
2236 | replace 'true' with 'false'. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2237 | """ ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2238 | self.ui.prompt( _("Press Enter to continue initialization...") ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2239 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2240 | # Creates configuration. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2241 | cfg_contents = ["[%s]" % CONFIG_SECTION_BRANCHNAME, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2242 | "master = %s" % master_stream, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2243 | "develop = %s" % develop_stream, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2244 | "feature = %s" % feature_stream, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2245 | "release = %s" % release_stream, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2246 | "hotfix = %s" % hotfix_stream, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2247 | "support = %s" % support_stream,] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2248 | def write_config() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2249 | # Writes the configuration in the current branch. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2250 | if (not commands.dryrun()) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2251 | with open( config_fname, "w" ) as fh : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2252 | print >> fh, "\n".join( cfg_contents ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2253 | repo_status = self.repo.status( unknown = True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2254 | if (CONFIG_BASENAME in repo_status[0]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2255 | 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
|
2256 | elif (CONFIG_BASENAME in repo_status[4]) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2257 | self._add ( config_fname ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2258 | 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
|
2259 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2260 | write_config() |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2261 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2262 | master_trunk, is_open = self._find_branch( master_stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2263 | if (master_trunk and not is_open) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2264 | self._warn( "Branch \"%s\" is currently closed." % master_stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2265 | self._warn( "Will reopen and use it as <master> trunk." ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2266 | branches.append( master_trunk ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2267 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2268 | develop_trunk, is_open = self._find_branch( develop_stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2269 | if (develop_trunk and not is_open) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2270 | self._warn( "Branch \"%s\" is currently closed." % develop_stream ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2271 | self._warn( "Will reopen and use it as <develop> trunk." ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2272 | branches.append( develop_trunk ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2273 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2274 | # Writes the configuration in all the other branches. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2275 | self.autoshelve = True |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2276 | self._shelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2277 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2278 | if (len( branches ) > 1) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2279 | for branch in branches : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2280 | if (branch == workspace) : continue |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2281 | self._update( branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2282 | write_config() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2283 | self._update( workspace ) |
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 | # Creates 'master' and 'develop' streams if they don't yet exist. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2286 | if (master_trunk is None) : |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2287 | self._create_branch( master_stream, "flow initialization: Created <master> trunk: %s." % master_stream ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2288 | if (develop_trunk is None) : |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2289 | self._create_branch( develop_stream, "flow initialization: Created <develop> trunk: %s." % develop_stream ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2290 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2291 | self._update( workspace ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2292 | self._unshelve() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2293 | |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2294 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2295 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2296 | def upgrade( self, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2297 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2298 | Upgrade older version to the latest version. |
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 | 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
|
2301 | 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
|
2302 | 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
|
2303 | 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
|
2304 | workspace = self.curr_workspace |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2305 | for branch in self._branches() : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2306 | self._print( " Branch '%s'..." % branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2307 | self._update( branch ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2308 | if (os.path.isfile( old_config_fname )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2309 | self._rename( old_config_fname, config_fname, force = True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2310 | 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
|
2311 | (OLD_CONFIG_BASENAME, CONFIG_BASENAME,) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2312 | self._update( workspace ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2313 | self._print( "Upgrading done" ) |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2316 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2317 | def flow_cmd( ui, repo, cmd = None, *arg, **kwarg ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2318 | """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
|
2319 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2320 | actions: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2321 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2322 | - start Open a new branch in the stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2323 | - 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
|
2324 | - push Push workspace branch to the remote repository. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2325 | - publish Same as `push` |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2326 | - 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
|
2327 | - list List all open branches in the stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2328 | - log Show revision history of branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2329 | - 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
|
2330 | - rebase Rebase workspace branch to its parent branch. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2331 | - rename Rename workspace branch to a new basename. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2332 | - abort Abort branch. Close branch without merging. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2333 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2334 | 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
|
2335 | 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
|
2336 | switch the current workspace to the branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2337 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2338 | commands: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2339 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2340 | - init Initialize flow. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2341 | - unshelve Unshelve the previously shelved changes for workspace branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2342 | - 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
|
2343 | - 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
|
2344 | - version Show flow's version number. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2345 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2346 | # 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
|
2347 | # bookmark's revision. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2348 | repo._bookmarks = {} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2349 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2350 | flow = Flow( ui, repo, cmd in ["init", "upgrade", "help",] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2351 | func = { |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2352 | "init" : flow.init, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2353 | "upgrade" : flow.upgrade, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2354 | "unshelve" : flow.unshelve, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2355 | "help" : Help( ui, repo ).print_help, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2356 | "version" : flow.print_version, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2357 | None : flow.print_open_branches, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2358 | } |
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 | commands.use_quiet_channel( kwarg.get( "history" ) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2361 | commands.dryrun ( kwarg.get( "dry_run" ) ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2362 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2363 | if (kwarg.get( "dry_run" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2364 | _print( ui, "This is a dry run." ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2365 | commands.use_quiet_channel( True ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2366 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2367 | # Registers common options (such as "user"). |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2368 | common_opts = {} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2369 | for e in ["user",] : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2370 | v = kwarg.get( e ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2371 | if (v) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2372 | common_opts[e] = v |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2373 | commands.reg_common_options( common_opts ) |
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 | # - 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
|
2376 | # - 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
|
2377 | # - 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
|
2378 | # the first element. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2379 | 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
|
2380 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2381 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2382 | # Constructs a `Stream' objects. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2383 | # 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
|
2384 | if (isinstance( stream, str )) : |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2385 | stream = Stream.gen( ui, repo, stream, check = True ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2386 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2387 | # Checks the options for all commands and actions. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2388 | kwarg = _getopt( ui, cmd, kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2389 | stamp = kwarg.pop( "stamp", None ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2390 | if (stamp) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2391 | def stamp_commit_message( opts ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2392 | msg = opts["message"] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2393 | if (0 > msg.lower().find( stamp.lower() )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2394 | msg += " %s" % stamp |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2395 | opts["message"] = msg |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2396 | return opts |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2397 | commands.reg_option_mutator( "commit", stamp_commit_message ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2398 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2399 | 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
|
2400 | func( *arg, **kwarg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2401 | except AbortFlow, e : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2402 | errmsg = e.error_message() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2403 | _error( ui, *errmsg ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2404 | if (getattr( e, "note", None )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2405 | _note( ui, *((e.note,) if (isinstance( e.note, str )) else e.note), via_quiet = True ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2406 | elif (errmsg[0].startswith( "Stream not found" )) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2407 | misspelling = difflib.get_close_matches( stream, ["init", "upgrade", "unshelve", "help", "version",], 3, 0.7 ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2408 | note = ("Did you mean the command: %s?" % " or ".join( misspelling )) if (misspelling ) else None |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2409 | note = ("Did you mean the command: init?") if ("install" == stream) else note |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2410 | note = ("Did you mean the command: upgrade?") if ("update" == stream) else note |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2411 | if (note) : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2412 | _note( ui, note, via_quiet = True ) |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2413 | |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2414 | if (ui.tracebackflag) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2415 | if (hasattr( e, "traceback" )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2416 | ei = e.traceback |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2417 | sys.excepthook( ei[0], ei[1], ei[2] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2418 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2419 | ei = sys.exc_info() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2420 | sys.excepthook( ei[0], ei[1], ei[2] ) |
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 | commands.print_history() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2423 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2424 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2425 | os.chdir( flow.orig_dir ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2426 | except : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2427 | _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
|
2428 | _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
|
2429 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2430 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2431 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2432 | # On Windows, a topic should be wrapped with quotes. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2433 | if ("nt" == os.name) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2434 | 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
|
2435 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2436 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2437 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2438 | class Help( object ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2439 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2440 | Online help system |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2441 | We define all help topics within this class. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2442 | 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
|
2443 | 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
|
2444 | applied to text wrapped with '{{{' and '}}}'. |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2447 | SHORT_USAGE = """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2448 | flow: a Mercurial workflow extension |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2449 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2450 | Usage: {{{hg flow {<stream> [<action> [<arg>...]] | <command>} [<option>...]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2451 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2452 | """ + flow_cmd.__doc__ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2453 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2454 | TOPIC = { |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2455 | "@deprecated" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2456 | 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
|
2457 | the future: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2458 | * [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
|
2459 | renamed to '[flow]'. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2460 | * Syntax: hg flow <stream> finish {{{<tag-name>}}} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2461 | Replacement syntax: hg flow <stream> finish {{{-t <tag-name>}}} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2462 | Any positional arguments for `finish` will be considered as |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2463 | error. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2464 | """, |
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 | "@examples" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2467 | {{{> hg flow}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2468 | flow: Currently open branches: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2469 | flow: <master> : default |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2470 | flow: <develop>: develop develop/0.9# |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2471 | flow: <feature>: feature/help* |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2472 | # 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
|
2473 | # 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
|
2474 | # in the branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2475 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2476 | {{{> hg flow feature finish --history}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2477 | # 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
|
2478 | # commands used by the workflow. |
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 | {{{> 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
|
2481 | # 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
|
2482 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2483 | {{{> hg flow develop/0.9:feature finish --verbose}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2484 | flow: note: Hg command history: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2485 | 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
|
2486 | flow: note: hg update develop/0.9 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2487 | flow: note: hg merge feature/help |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2488 | 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
|
2489 | flow: note: hg update develop |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2490 | flow: note: hg merge develop/0.9 |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2491 | 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
|
2492 | # 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
|
2493 | # in turn merged to <develop>'s trunk. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2494 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2495 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2496 | "@master" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2497 | 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
|
2498 | 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
|
2499 | a <release> or <hotfix> branch merges into <master>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2500 | 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
|
2501 | and log. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2502 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2503 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2504 | "@develop" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2505 | 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
|
2506 | <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
|
2507 | 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
|
2508 | <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
|
2509 | <feature> branches. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2510 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2511 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2512 | "@feature" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2513 | 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
|
2514 | 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
|
2515 | existing <feature> branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2516 | 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
|
2517 | finished, it will normally be merged into <develop>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2518 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2519 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2520 | "@release" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2521 | 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
|
2522 | 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
|
2523 | 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
|
2524 | <develop>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2525 | """, |
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 | "@hotfix" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2528 | 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
|
2529 | 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
|
2530 | <master> and <develop>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2531 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2532 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2533 | "@support" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2534 | 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
|
2535 | 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
|
2536 | finished, they will be simply closed. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2537 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2538 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2539 | "@start" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2540 | 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
|
2541 | <develop>. <hotfix> and <support> branches are started from <master>. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2544 | {{{hg flow <stream> start <name> [<option>...]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2545 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2546 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2547 | -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
|
2548 | -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
|
2549 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2550 | -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
|
2551 | -u --user USER Use specified USER as committer. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2552 | --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
|
2553 | move all uncommitted changes to the new branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2554 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2555 | The new branch is named after <stream-prefix>/<name>. |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2558 | "@finish" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2559 | 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
|
2560 | 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
|
2561 | <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
|
2562 | <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
|
2563 | 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
|
2564 | branch to be merged into the <develop> trunk. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2567 | {{{hg flow <stream> finish [<option>...]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2568 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2569 | 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
|
2570 | 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
|
2571 | check the branch before finishing it. |
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 | 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
|
2574 | 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
|
2575 | 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
|
2576 | 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
|
2577 | 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
|
2578 | `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
|
2579 | merged into <master>. |
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 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2582 | -c --commit Commit changes before closing the branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2583 | -m --message TEXT Record TEXT as commit message. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2584 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2585 | -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
|
2586 | -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
|
2587 | -u --user USER Use specified USER as committer. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2588 | -e --erase Erase branch after it is merged successfully. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2589 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2590 | 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
|
2591 | 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
|
2592 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2593 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2594 | "@push" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2595 | Push the workspace branch to the remote repository. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2596 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2597 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2598 | {{{hg flow <stream> push}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2599 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2600 | alternative syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2601 | {{{hg flow <stream> publish}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2602 | The two syntaxes are completely equivalent. |
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 | The workspace branch must be in <stream>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2605 | """, |
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 | "@publish" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2608 | Push the workspace branch to the remote repository. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2611 | {{{hg flow <stream> publish}}} |
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 | alternative syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2614 | {{{hg flow <stream> push}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2615 | The two syntaxes are completely equivalent. |
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 | The workspace branch must be in <stream>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2618 | """, |
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 | "@pull" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2621 | 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
|
2622 | 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
|
2623 | branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2624 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2625 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2626 | {{{hg flow <stream> pull [<name>]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2627 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2628 | The pulled branch must be in <stream>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2629 | """, |
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 | "@list" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2632 | List all open branches in <stream>. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2635 | {{{hg flow <stream> list}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2636 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2637 | alternative syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2638 | {{{hg flow <stream>}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2639 | 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
|
2640 | 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
|
2641 | <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
|
2642 | <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
|
2643 | list all open branches in the stream). |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2644 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2645 | option: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2646 | -c --closed Show open and closed branches in <stream>. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2647 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2648 | example: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2649 | {{{> hg flow hotfix list}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2650 | flow: Open <hotfix> branches: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2651 | flow: hotfix/0.9.6# |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2652 | flow: hotfix/0.9.6/init_-d_option* |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2653 | # 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
|
2654 | # 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
|
2655 | # shelved changes for the branch. |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2658 | "@log" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2659 | 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
|
2660 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2661 | {{{hg flow <stream> log [<basename>]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2662 | 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
|
2663 | '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
|
2664 | branch name prefix is 'feature/') is 'colored_help'. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2665 | 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
|
2666 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2667 | 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
|
2668 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2669 | {{{hg flow <stream> log <filename>}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2670 | 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
|
2671 | it will be recognized as the basename. |
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 | alternative syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2674 | {{{hg flow <stream> log -F <filename>}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2675 | 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
|
2676 | 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
|
2677 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2678 | 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
|
2679 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2680 | {{{hg flow <stream> log <basename> -F <filename>}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2681 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2682 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2683 | -F --file FILE [+] File to show history of. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2684 | -d --date DATE Show revisions matching date spec. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2685 | -u --user USER Show revisions committed by USER. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2686 | -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
|
2687 | -p --patch Show patch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2688 | -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
|
2689 | -l --limit VALUE Limit number of changesets displayed. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2690 | -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
|
2691 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2692 | [+] marked option can be specified multiple times. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2693 | """, |
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 | "@abort" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2696 | 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
|
2697 | 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
|
2698 | 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
|
2699 | 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
|
2700 | different branch. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2701 | 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
|
2702 | 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
|
2703 | 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
|
2704 | 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
|
2705 | 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
|
2706 | branches that remain in the repository. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2709 | {{{hg flow <stream> abort [-m <TEXT>] [-e]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2710 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2711 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2712 | -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
|
2713 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2714 | -e --erase Abort branch and erase it. |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2717 | "@promote" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2718 | 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
|
2719 | 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
|
2720 | streams of the basic streams are listed as follows: |
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 | stream destination |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2723 | ------------+----------------------- |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2724 | <feature> <develop> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2725 | <develop> <master> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2726 | <release> <develop> & <master> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2727 | <hotfix> <develop> & <master> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2728 | <master> n/a |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2729 | <support> n/a |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2730 | natural stream-trunk |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2733 | {{{hg flow <stream> promote [<destination-branch-full-name>...] [<option>...]}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2734 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2735 | 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
|
2736 | 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
|
2737 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2738 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2739 | -r --rev REV Revision to promote to other branches. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2740 | -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
|
2741 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2742 | -t --tag NAME Tag the merging changeset with NAME |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2743 | -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
|
2744 | -u --user USER Use specified USER as committer. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2745 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2746 | examples: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2747 | {{{> hg flow develop promote -t v0.2.0}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2748 | # 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
|
2749 | # 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
|
2750 | # <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
|
2751 | # 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
|
2752 | # with "v0.2.0". |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2753 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2754 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2755 | "@rebase" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2756 | Rebase the workspace branch to the specified revision. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2759 | {{{hg flow <stream> rebase [-d <rev>]}}} |
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 | option: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2762 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2763 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2764 | 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
|
2765 | 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
|
2766 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2767 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2768 | "@version" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2769 | Show version of the flow extension. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2770 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2771 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2772 | {{{hg flow version}}} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2773 | """, |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2774 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2775 | "@rename" : """ |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2776 | Rename the workspace branch to a new basename. Under the hood, this action |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2777 | will create a new branch with the new basename and copy/graft the commits in |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2778 | the workspace branch to the new branch, and then erase the workspace branch. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2779 | All the user, date, and commit-message information will be copied to the |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2780 | new branch. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2781 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2782 | N.B.: The workspace branch should be a simple linear branch. This means: |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2783 | (1) It has not merged to other branches; |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2784 | (2) It has no subbranches; |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2785 | (3) No other branches has merged to this branch. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2786 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2787 | syntax: |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2788 | {{{hg flow <stream> rename [-t <basename>]}}} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2789 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2790 | option: |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2791 | -t --to NAME Rename the basename of the workspace branch to NAME. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2792 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2793 | The workspace branch must be in <stream>. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2794 | """, |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2795 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2796 | "@version" : """ |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2797 | Show version of the flow extension. |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2798 | |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2799 | syntax: |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2800 | {{{hg flow version}}} |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2801 | """, |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2802 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2803 | "@init" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2804 | 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
|
2805 | {{{.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
|
2806 | 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
|
2807 | 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
|
2808 | automatically. |
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 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2811 | {{{hg flow init [<option>...]}}} |
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 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2814 | -f --force Force reinitializing flow. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2815 | -u --user USER Use specified USER as committer. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2816 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2817 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2818 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2819 | "@upgrade" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2820 | 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
|
2821 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2822 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2823 | {{{hg flow upgrade}}} |
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 | options: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2826 | -u --user USER Use specified USER as committer. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2827 | -p --stamp TEXT Append TEXT to all commit messages. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2828 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2829 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2830 | "@unshelve" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2831 | 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
|
2832 | automatically executed because workflow is terminated prematurelly. In such |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2833 | 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
|
2834 | shelved changes. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2835 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2836 | syntax: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2837 | {{{hg flow unshelve}}} |
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 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2840 | "@terms" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2841 | Concepts: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2842 | - stream |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2843 | 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
|
2844 | 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
|
2845 | 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
|
2846 | 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
|
2847 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2848 | - basic streams |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2849 | 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
|
2850 | as predefined in Driessen's model. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2851 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2852 | - natural streams |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2853 | 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
|
2854 | 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
|
2855 | 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
|
2856 | 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
|
2857 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2858 | - trunk |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2859 | 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
|
2860 | 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
|
2861 | 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
|
2862 | 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
|
2863 | 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
|
2864 | are finished. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2865 | 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
|
2866 | 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
|
2867 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2868 | - source |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2869 | 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
|
2870 | 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
|
2871 | 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
|
2872 | 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
|
2873 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2874 | - destin |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2875 | 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
|
2876 | 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
|
2877 | 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
|
2878 | 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
|
2879 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2880 | - fullname |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2881 | 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
|
2882 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2883 | - basename |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2884 | 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
|
2885 | enhanced_log (with prefix 'feature/' dropped). |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2886 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2887 | - flow action |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2888 | 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
|
2889 | 'start' is an action. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2890 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2891 | - flow command |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2892 | 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
|
2893 | is a command. |
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 | - hg command |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2896 | Refer to commands not from flow extension. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2897 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2898 | - workflow |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2899 | 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
|
2900 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2901 | - history |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2902 | Refer to a sequence of executed hg commands. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2903 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2904 | Notations |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2905 | - <stream> |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2906 | Examples: <feature>, <hotfix>. These denote the corresponding streams. When |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2907 | 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
|
2908 | verbosely 'feature stream'), instead of '<feature> stream', because |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2909 | '<feature>' already means stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2910 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2911 | - <stream> branch |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2912 | 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
|
2913 | 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
|
2914 | '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
|
2915 | necessarily mean the feature stream. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2916 | """, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2917 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2918 | "@help" : """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2919 | 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
|
2920 | '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
|
2921 | available for the following topics: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2922 | @all - Show detailed help for all supported topics. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2923 | @<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
|
2924 | @<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
|
2925 | @<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
|
2926 | @terms - Show explanations of terminologies used in hgflow. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2927 | @examples - Show a few command examples. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2928 | @deprecated - Show a list of deprecated features.%s""" % \ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2929 | ("\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
|
2930 | } |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2931 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2932 | def __init__( self, ui, repo ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2933 | self.ui = ui |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2934 | self.repo = repo |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2935 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2936 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2937 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2938 | def _print( self, s ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2939 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2940 | Print text with predefined effects. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2941 | @type s: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2942 | @param s: String to be printed |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2943 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2944 | import re |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2945 | code_pattern = re.compile( "{{{.*?}}}" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2946 | last_span = (0, 0,) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2947 | for match in code_pattern.finditer( s ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2948 | span = match.span() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2949 | self.ui.write( s[last_span[1]:span[0]] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2950 | 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
|
2951 | last_span = span |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2952 | self.ui.write( s[last_span[1]:] ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2953 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2954 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2955 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2956 | def print_help( self, topic = None, *arg, **opts ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2957 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2958 | Print help information. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2959 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2960 | @type topic : C{str} or C{None} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2961 | @param topic : Help topic |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2962 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2963 | if (topic is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2964 | self._print( self.SHORT_USAGE ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2965 | elif (topic == "@all") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2966 | doc = self.TOPIC.items() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2967 | doc.sort() |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2968 | for t, help in doc : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2969 | self.ui.write( "%s" % t, label = "flow.help.topic" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2970 | self._print( "%s\n" % help ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2971 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2972 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2973 | help_content = self.TOPIC[topic] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2974 | self.ui.write( "%s" % topic, label = "flow.help.topic" ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2975 | self._print( "%s\n" % help_content ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2976 | except KeyError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2977 | _error( self.ui, "Unknown topic: %s" % topic ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2978 | if (("@" + topic) in self.TOPIC or topic == "all") : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2979 | _error( self.ui, "Did you mean '@%s'?" % topic ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2980 | _print( self.ui, """Supported topics are the following: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2981 | @all - Show detailed help for all supported topics. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2982 | @<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
|
2983 | @<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
|
2984 | @<command> - Show help about a command, e.g., @help, @unshelve. |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
2985 | @terms - Show explanations of terminologies used in hgflow. |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2986 | @examples - Show a few command examples. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2987 | @deprecated - Show a list of deprecated features. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2988 | """ ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2989 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2990 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2991 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2992 | OPT_FILTER = { |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2993 | "init" : ("force", "user", "stamp", "default",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2994 | "upgrade" : ("user", "stamp",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2995 | "start" : ("rev", "message", "stamp", "date", "user", "dirty",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2996 | "finish" : ("commit", "message", "stamp", "tag", "date", "user", "erase", "onstream",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2997 | "list" : ("closed",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
2998 | "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
|
2999 | "abort" : ("erase", "message", "stamp", "onstream",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3000 | "promote" : ("rev", "message", "stamp", "tag", "date", "user", "onstream",), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3001 | "rebase" : ("dest", "onstream", "stamp",), |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3002 | "rename" : ("to",), |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3003 | } |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3004 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3005 | OPT_CONFLICT = { |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3006 | "dest" : ("-d", '', ), # (short-form-of-option, default-value,) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3007 | "date" : ("-d", '', ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3008 | "default" : ("-d", False,), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3009 | "closed" : ("-c", False,), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3010 | "commit" : ("-c", False,), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3011 | "stamp" : ("-p", '' ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3012 | "patch" : ("-p", False ), |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3013 | "tag" : ("-t", '' ), |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3014 | "to" : ("-t", '' ), |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3015 | } |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3016 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3017 | def _getopt( ui, key, opt ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3018 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3019 | Return user-specified options. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3020 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3021 | 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
|
3022 | 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
|
3023 | 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
|
3024 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3025 | 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
|
3026 | 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
|
3027 | 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
|
3028 | N.B.: |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3029 | (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
|
3030 | (2) This function will mutate and return C{opt}. |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3031 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3032 | @type ui: C{mercurial.ui} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3033 | @param ui: Mercurial user interface object |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3034 | @type key: C{str} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3035 | @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
|
3036 | @type opt: C{dict} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3037 | @param opt: Raw options |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3038 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3039 | @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
|
3040 | """ |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3041 | ret = {} |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3042 | rec_short = [] # A list of recoginized short options |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3043 | for e in OPT_FILTER.get( key, [] ) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3044 | if (opt.get( e )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3045 | ret[e] = opt[e] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3046 | elif (e in OPT_CONFLICT) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3047 | short_opt, default_value = OPT_CONFLICT[e] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3048 | argv = sys.argv |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3049 | if (short_opt in argv) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3050 | rec_short.append( short_opt ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3051 | if (isinstance( default_value, str )) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3052 | index = argv.index( short_opt ) |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3053 | try : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3054 | ret[e] = argv[index + 1] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3055 | except IndexError : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3056 | 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
|
3057 | else : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3058 | ret[e] = not default_value |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3059 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3060 | 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
|
3061 | 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
|
3062 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3063 | if (bad_opt) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3064 | bad_opt = [e.replace( "_", "-" ) for e in bad_opt] |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3065 | if (key is None) : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3066 | raise AbortFlow( "Unrecognized option%s for `hg flow`: %s." % |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3067 | ("" 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
|
3068 | note = "`hg flow` should take no options." ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3069 | elif (key in Flow.ACTION_NAME) : |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3070 | raise AbortFlow( "Unrecognized option%s for `%s`: %s." % |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3071 | ("" 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
|
3072 | note = "Execute `hg flow help @%s` to see available options for `%s`." % (key, key,) ) |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3073 | else : |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3074 | raise AbortFlow( "Unrecognized option%s: %s." % |
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3075 | ("" if (len( bad_opt ) == 1) else "s", "--" + (", --".join( bad_opt )),) ) |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3076 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3077 | return ret |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3078 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3079 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3080 | |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3081 | cmdtable = { |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3082 | "flow" : |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3083 | (flow_cmd, |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3084 | [("", "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
|
3085 | ("", "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
|
3086 | ("", "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
|
3087 | " uncommitted changes to the new branch. [start]"), ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3088 | ("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
|
3089 | ("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
|
3090 | ("d", "default", False, _("Initialize flow with default configuration. [init]"), ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3091 | ("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
|
3092 | ("d", "date", '', _("Show revisions matching date spec. [log]"), _('DATE'),), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3093 | ("d", "dest", '', _("Destination changeset of rebasing. [rebase]"), _('REV' ),), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3094 | ("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
|
3095 | ("F", "file", [], _("File to show history of. [log]"), _('FILE'),), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3096 | ("f", "force", False, _("Force reinitializing flow. [init]"), ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3097 | ("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
|
3098 | ("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
|
3099 | ("l", "limit", '', _("Limit number of changesets displayed. [log]"), ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3100 | ("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
|
3101 | ("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
|
3102 | " promote, rebase, abort]"), _('TEXT'),), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3103 | ("p", "patch", False, _("Show patch. [log]"), ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3104 | ("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
|
3105 | ("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
|
3106 | ("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
|
3107 | ("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
|
3108 | ("t", "tag", '', _("Tag the <master> trunk with NAME after merging. [finish]"), _('NAME'),), |
253
a1accbd675a0
Update hgflow to 0316d61 (v0.9.8.1~)
Meredith Howard <mhoward@roomag.org>
parents:
8
diff
changeset
|
3109 | ("t", "to", '', _("Rename the branch to NAME. [rename]"), _('NAME'),), |
8
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3110 | ("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
|
3111 | " promote]"), _('USER'),), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3112 | ("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
|
3113 | ], |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3114 | "hg flow {<stream> [<action> [<arg>]] | <command>} [<option>...]", |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3115 | ), |
ba72a71f23e6
Add mercurial config and hgflow extension
Meredith Howard <mhoward@roomag.org>
parents:
diff
changeset
|
3116 | } |