Mercurial > hg > evolve
annotate hgext3rd/topic/stack.py @ 2780:90e11985d0cc
topic: exclude public and topic changeset from branch stack
Stack use-case is to show the current work in progress, which are symbolized by
the phase draft and secret phase. Moreover showing public changesets in stack
output when displaying current branch would display a lot of changesets for
long-lived branches and would be quite useless.
We also exclude topic changeset form the stack since they already exist on their
own stack.
getstack revsets didn't needed update when displaying a topic as when a
changeset become public, its topic is no longer relevant.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 29 Jun 2017 16:49:33 +0200 |
parents | f5d52fa1cd55 |
children | f19b314d8475 |
rev | line source |
---|---|
1991
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
1 # stack.py - code related to stack workflow |
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
2 # |
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
3 # This software may be used and distributed according to the terms of the |
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
4 # GNU General Public License version 2 or any later version. |
2091
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
5 from mercurial.i18n import _ |
2032
31583ddda6d9
stack: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2021
diff
changeset
|
6 from mercurial import ( |
2081
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
7 destutil, |
2032
31583ddda6d9
stack: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2021
diff
changeset
|
8 error, |
2057
d9c7fced94fc
stack: prevent crash when topic is rooted on nullid
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2053
diff
changeset
|
9 node, |
2032
31583ddda6d9
stack: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2021
diff
changeset
|
10 ) |
2078
d87fc4f749e6
evolve: extract the code copied from evolve in a submodule
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2075
diff
changeset
|
11 from .evolvebits import builddependencies, _orderrevs, _singlesuccessor |
1991
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
12 |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
13 def getstack(repo, branch=None, topic=None): |
1991
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
14 # XXX need sorting |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
15 if topic is not None and branch is not None: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
16 raise error.ProgrammingError('both branch and topic specified (not defined yet)') |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
17 elif topic is not None: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
18 trevs = repo.revs("topic(%s) - obsolete()", topic) |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
19 elif branch is not None: |
2780
90e11985d0cc
topic: exclude public and topic changeset from branch stack
Boris Feld <boris.feld@octobus.net>
parents:
2766
diff
changeset
|
20 trevs = repo.revs("branch(%s) - public() - obsolete() - topic()", branch) |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
21 else: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
22 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') |
1993
38570c53b1cf
stack: fix printing order in case of unstability
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1992
diff
changeset
|
23 return _orderrevs(repo, trevs) |
1991
c8e4c6e03957
stack: add a very first version of stack display with 'hg topic --list'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
24 |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
25 def labelsgen(prefix, labelssuffix): |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
26 """ Takes a label prefix and a list of suffixes. Returns a string of the prefix |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
27 formatted with each suffix separated with a space. |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
28 """ |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
29 return ' '.join(prefix % suffix for suffix in labelssuffix) |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
30 |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
31 def showstack(ui, repo, branch=None, topic=None, opts=None): |
2764
1d2c66dc4ee3
topic: explicitly pass topic as a keyword argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2728
diff
changeset
|
32 if opts is None: |
1d2c66dc4ee3
topic: explicitly pass topic as a keyword argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2728
diff
changeset
|
33 opts = {} |
2723
42abd3bd30ee
topics: abort if user wants to show the stack of a non-existent topic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2722
diff
changeset
|
34 |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
35 if topic is not None and branch is not None: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
36 msg = 'both branch and topic specified [%s]{%s}(not defined yet)' |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
37 msg %= (branch, topic) |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
38 raise error.ProgrammingError(msg) |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
39 elif topic is not None: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
40 prefix = 't' |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
41 if topic not in repo.topics: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
42 raise error.Abort(_('cannot resolve "%s": no such topic found') % topic) |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
43 elif branch is not None: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
44 prefix = 'b' |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
45 else: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
46 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') |
2723
42abd3bd30ee
topics: abort if user wants to show the stack of a non-existent topic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2722
diff
changeset
|
47 |
2003
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2002
diff
changeset
|
48 fm = ui.formatter('topicstack', opts) |
2005
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2003
diff
changeset
|
49 prev = None |
2051
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
50 entries = [] |
2087
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
51 idxmap = {} |
2091
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
52 |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
53 label = 'topic' |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
54 if topic == repo.currenttopic: |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
55 label = 'topic.active' |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
56 |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
57 data = stackdata(repo, branch=branch, topic=topic) |
2766
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
58 if topic is not None: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
59 fm.plain(_('### topic: %s') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
60 % ui.label(topic, label), |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
61 label='topic.stack.summary.topic') |
2094
302be26a3fd8
stack: add warning about multiple heads
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2093
diff
changeset
|
62 |
2766
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
63 if 1 < data['headcount']: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
64 fm.plain(' (') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
65 fm.plain('%d heads' % data['headcount'], |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
66 label='topic.stack.summary.headcount.multiple') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
67 fm.plain(')') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
68 fm.plain('\n') |
2093
ce86f7bb4b7b
stack: add some behind information
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2092
diff
changeset
|
69 fm.plain(_('### branch: %s') |
2092
5c40dd2cf131
stack: add some basic branch information
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2091
diff
changeset
|
70 % '+'.join(data['branches']), # XXX handle multi branches |
5c40dd2cf131
stack: add some basic branch information
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2091
diff
changeset
|
71 label='topic.stack.summary.branches') |
2766
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
72 if topic is None: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
73 if 1 < data['headcount']: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
74 fm.plain(' (') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
75 fm.plain('%d heads' % data['headcount'], |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
76 label='topic.stack.summary.headcount.multiple') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
77 fm.plain(')') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
78 else: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
79 if data['behindcount'] == -1: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
80 fm.plain(', ') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
81 fm.plain('ambigious rebase destination', label='topic.stack.summary.behinderror') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
82 elif data['behindcount']: |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
83 fm.plain(', ') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2765
diff
changeset
|
84 fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount') |
2093
ce86f7bb4b7b
stack: add some behind information
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2092
diff
changeset
|
85 fm.plain('\n') |
2091
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2087
diff
changeset
|
86 |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
87 for idx, r in enumerate(getstack(repo, branch=branch, topic=topic), 1): |
2021 | 88 ctx = repo[r] |
2005
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2003
diff
changeset
|
89 p1 = ctx.p1() |
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2003
diff
changeset
|
90 if p1.obsolete(): |
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2003
diff
changeset
|
91 p1 = repo[_singlesuccessor(repo, p1)] |
2057
d9c7fced94fc
stack: prevent crash when topic is rooted on nullid
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2053
diff
changeset
|
92 if p1.rev() != prev and p1.node() != node.nullid: |
2087
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
93 entries.append((idxmap.get(p1.rev()), False, p1)) |
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
94 entries.append((idx, True, ctx)) |
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
95 idxmap[ctx.rev()] = idx |
2051
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
96 prev = r |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
97 |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
98 # super crude initial version |
2087
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
99 for idx, isentry, ctx in entries[::-1]: |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
100 |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
101 states = [] |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
102 iscurrentrevision = repo.revs('%d and parents()', ctx.rev()) |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
103 |
2087
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
104 if not isentry: |
2053
ea5553e47027
stack: change the ascii symbold for base
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2052
diff
changeset
|
105 symbol = '^' |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
106 # "base" is kind of a "ghost" entry |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
107 # skip other label for them (no current, no unstable) |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
108 states = ['base'] |
2728
62eb5a2d2112
refactoring: directly use 'ctx.unstable()' in showstack function
Boris Feld <boris.feld@octobus.net>
parents:
2723
diff
changeset
|
109 elif ctx.unstable(): |
2722
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
110 # current revision can be unstable also, so in that case show both |
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
111 # the states and the symbol '@' (issue5553) |
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
112 if iscurrentrevision: |
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
113 states.append('current') |
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
114 symbol = '@' |
2002
5e9ce6310720
stack: show the currently active changeset and unstable ones
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2001
diff
changeset
|
115 symbol = '$' |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
116 states.append('unstable') |
2722
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
117 elif iscurrentrevision: |
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
118 states.append('current') |
bc36a608e9e4
stack: show unstable state for the current revision if it is one (issue5553)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2444
diff
changeset
|
119 symbol = '@' |
2051
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
120 else: |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
121 symbol = ':' |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
122 states.append('clean') |
2003
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2002
diff
changeset
|
123 fm.startitem() |
2087
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2086
diff
changeset
|
124 fm.data(isentry=isentry) |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
125 |
2051
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
126 if idx is None: |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
127 fm.plain(' ') |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2050
diff
changeset
|
128 else: |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
129 fm.write('topic.stack.index', '%s%%d' % prefix, idx, |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
130 label='topic.stack.index ' + labelsgen('topic.stack.index.%s', states)) |
2003
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2002
diff
changeset
|
131 fm.write('topic.stack.state.symbol', '%s', symbol, |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
132 label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) |
2003
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2002
diff
changeset
|
133 fm.plain(' ') |
2005
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2003
diff
changeset
|
134 fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0], |
2444
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
135 label='topic.stack.desc ' + labelsgen('topic.stack.desc.%s', states)) |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
136 fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state', |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
137 ' (%s)', fm.formatlist(states, 'topic.stack.state'), |
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2437
diff
changeset
|
138 label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) |
2003
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
2002
diff
changeset
|
139 fm.plain('\n') |
2437
a5117a5becf8
ui: Fix hg stack json output
Boris Feld <boris.feld@octobus.net>
parents:
2099
diff
changeset
|
140 fm.end() |
1993
38570c53b1cf
stack: fix printing order in case of unstability
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1992
diff
changeset
|
141 |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
142 def stackdata(repo, branch=None, topic=None): |
2073
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
143 """get various data about a stack |
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
144 |
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
145 :changesetcount: number of non-obsolete changesets in the stack |
2074
e42dd4523c0d
topic: list the number of troubled changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2073
diff
changeset
|
146 :troubledcount: number on troubled changesets |
2075
bee7a1ef8ba8
topic: list the number of head when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2074
diff
changeset
|
147 :headcount: number of heads on the topic |
2081
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
148 :behindcount: number of changeset on rebase destination |
2073
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
149 """ |
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
150 data = {} |
2765
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2764
diff
changeset
|
151 revs = getstack(repo, branch, topic) |
2073
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
152 data['changesetcount'] = len(revs) |
2074
e42dd4523c0d
topic: list the number of troubled changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2073
diff
changeset
|
153 data['troubledcount'] = len([r for r in revs if repo[r].troubled()]) |
2075
bee7a1ef8ba8
topic: list the number of head when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2074
diff
changeset
|
154 deps, rdeps = builddependencies(repo, revs) |
bee7a1ef8ba8
topic: list the number of head when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2074
diff
changeset
|
155 data['headcount'] = len([r for r in revs if not rdeps[r]]) |
2081
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
156 data['behindcount'] = 0 |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
157 if revs: |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
158 minroot = [min(r for r in revs if not deps[r])] |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
159 try: |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
160 dest = destutil.destmerge(repo, action='rebase', |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
161 sourceset=minroot, |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
162 onheadcheck=False) |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
163 data['behindcount'] = len(repo.revs("only(%d, %ld)", dest, |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
164 minroot)) |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
165 except error.NoMergeDestAbort: |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
166 data['behindcount'] = 0 |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
167 except error.ManyMergeDestAbort: |
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2078
diff
changeset
|
168 data['behindcount'] = -1 |
2084
9a5d797d25be
topic: list the branches this topic belong to when verbose
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2081
diff
changeset
|
169 data['branches'] = sorted(set(repo[r].branch() for r in revs)) |
2075
bee7a1ef8ba8
topic: list the number of head when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2074
diff
changeset
|
170 |
2073
137f8b04901e
topic: list the number of changesets when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
2057
diff
changeset
|
171 return data |