Mercurial > evolve
annotate hgext3rd/topic/stack.py @ 4829:6b82b4f72347 stable
stack: make a deep copy of `dependencies` before modifying its items
The algorithm later on in this method uses .remove() to remove individual
elements from items in dependencies, which before this patch modified the
cached property contents. So for further use that dictionary was in the form of
{1: set([])}, i.e. all sets were empty.
This deep copy block could be way simpler, but the problem is that sometimes we
get lists of _succs() from evolvebits.builddependencies(). Note: this happens
only in topic's stack version of builddependencies() and it looks like a
suboptimal way to handle multiple successors (see evolve's counterpart
function).
stack.builddependencies method is removed, it has served its purpose (see the
previous patch).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 06 Sep 2019 12:53:46 +0700 |
parents | aaf8742e09a0 |
children | 4c5377ab147a |
rev | line source |
---|---|
1895
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. |
1995
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
5 from mercurial.i18n import _ |
1936
31583ddda6d9
stack: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1925
diff
changeset
|
6 from mercurial import ( |
1985
03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1982
diff
changeset
|
7 destutil, |
1936
31583ddda6d9
stack: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1925
diff
changeset
|
8 error, |
1961
d9c7fced94fc
stack: prevent crash when topic is rooted on nullid
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1957
diff
changeset
|
9 node, |
2919
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
10 phases, |
4759
f30c1fab7155
py3: convert exceptions to bytes using pycompat.bytestr()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4658
diff
changeset
|
11 pycompat, |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
12 obsolete, |
2838
1c9150e30b28
context: unstable was deprecated
Boris Feld <boris.feld@octobus.net>
parents:
2750
diff
changeset
|
13 util, |
1936
31583ddda6d9
stack: move to new style import
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1925
diff
changeset
|
14 ) |
3278
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
15 from .evolvebits import ( |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
16 _singlesuccessor, |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
17 MultipleSuccessorsError, |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
18 builddependencies, |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
19 ) |
1895
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
|
20 |
2750
bd3824d1b795
stack: show short node of changesets in `hg stack -v`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2712
diff
changeset
|
21 short = node.short |
bd3824d1b795
stack: show short node of changesets in `hg stack -v`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2712
diff
changeset
|
22 |
3371
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
23 def parseusername(user): |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
24 """parses the ctx user and returns the username without email ID if |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
25 possible, otherwise returns the mail address from that""" |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
26 username = None |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
27 if user: |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
28 # user is of form "abc <abc@xyz.com>" |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
29 username = user.split('<')[0] |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
30 if not username: |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
31 # assuming user is of form "<abc@xyz.com>" |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
32 if len(user) > 1: |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
33 username = user[1:-1] |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
34 else: |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
35 username = user |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
36 username = username.strip() |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
37 |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
38 return username |
753e5ebabe7d
topics: take logic to parse username to a separate function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3278
diff
changeset
|
39 |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
40 def _stackcandidates(repo): |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
41 """build the smaller set of revs that might be part of a stack. |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
42 |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
43 The intend is to build something more efficient than what revsets do in |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
44 this area. |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
45 """ |
4477
faf99d48eda9
stack: fix phasecache._phasesets check logic
Anton Shestakov <av6@dwimlabs.net>
parents:
4474
diff
changeset
|
46 phasesets = repo._phasecache._phasesets |
faf99d48eda9
stack: fix phasecache._phasesets check logic
Anton Shestakov <av6@dwimlabs.net>
parents:
4474
diff
changeset
|
47 if not phasesets or None in phasesets[phases.draft:]: |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
48 return repo.revs('(not public()) - obsolete()') |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
49 |
4478
94743877e50b
stack: improve set combination logic
Anton Shestakov <av6@dwimlabs.net>
parents:
4477
diff
changeset
|
50 result = set.union(*phasesets[phases.draft:]) |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
51 result -= obsolete.getrevs(repo, 'obsolete') |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
52 return result |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
53 |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
54 class stack(object): |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
55 """object represent a stack and common logic associated to it.""" |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
56 |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
57 def __init__(self, repo, branch=None, topic=None): |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
58 self._repo = repo |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
59 self.branch = branch |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
60 self.topic = topic |
2939
7759d040d48d
topic: provide more information when behind count cannot be computed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2938
diff
changeset
|
61 self.behinderror = None |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
62 |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
63 subset = _stackcandidates(repo) |
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
64 |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
65 if topic is not None and branch is not None: |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
66 raise error.ProgrammingError('both branch and topic specified (not defined yet)') |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
67 elif topic is not None: |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
68 trevs = repo.revs("%ld and topic(%s)", subset, topic) |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
69 elif branch is not None: |
3123
237b39bf7e6b
topic: instroduce a fast path when computing stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3085
diff
changeset
|
70 trevs = repo.revs("%ld and branch(%s) - topic()", subset, branch) |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
71 else: |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
72 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
73 self._revs = trevs |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
74 |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
75 def __iter__(self): |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
76 return iter(self.revs) |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
77 |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
78 def __getitem__(self, index): |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
79 return self.revs[index] |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
80 |
4651
55c347b4874f
stack: implement __bool__ and __nonzero__
Anton Shestakov <av6@dwimlabs.net>
parents:
4650
diff
changeset
|
81 def __nonzero__(self): |
55c347b4874f
stack: implement __bool__ and __nonzero__
Anton Shestakov <av6@dwimlabs.net>
parents:
4650
diff
changeset
|
82 return bool(self._revs) |
55c347b4874f
stack: implement __bool__ and __nonzero__
Anton Shestakov <av6@dwimlabs.net>
parents:
4650
diff
changeset
|
83 |
55c347b4874f
stack: implement __bool__ and __nonzero__
Anton Shestakov <av6@dwimlabs.net>
parents:
4650
diff
changeset
|
84 __bool__ = __nonzero__ |
55c347b4874f
stack: implement __bool__ and __nonzero__
Anton Shestakov <av6@dwimlabs.net>
parents:
4650
diff
changeset
|
85 |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
86 def index(self, item): |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
87 return self.revs.index(item) |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
88 |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
89 @util.propertycache |
2916
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
90 def _dependencies(self): |
2919
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
91 deps, rdeps = builddependencies(self._repo, self._revs) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
92 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
93 repo = self._repo |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
94 srcpfunc = repo.changelog.parentrevs |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
95 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
96 ### post process to skip over possible gaps in the stack |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
97 # |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
98 # For example in the following situation, we need to detect that "t3" |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
99 # indirectly depends on t2. |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
100 # |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
101 # o t3 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
102 # | |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
103 # o other |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
104 # | |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
105 # o t2 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
106 # | |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
107 # o t1 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
108 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
109 pmap = {} |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
110 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
111 def pfuncrev(repo, rev): |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
112 """a special "parent func" that also consider successors""" |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
113 parents = pmap.get(rev) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
114 if parents is None: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
115 parents = [repo[_singlesuccessor(repo, repo[p])].rev() |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
116 for p in srcpfunc(rev) if 0 <= p] |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
117 pmap[rev] = parents |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
118 return parents |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
119 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
120 revs = self._revs |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
121 stackrevs = set(self._revs) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
122 for root in [r for r in revs if not deps[r]]: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
123 seen = set() |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
124 stack = [root] |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
125 while stack: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
126 current = stack.pop() |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
127 for p in pfuncrev(repo, current): |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
128 if p in seen: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
129 continue |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
130 seen.add(p) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
131 if p in stackrevs: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
132 rdeps[p].add(root) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
133 deps[root].add(p) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
134 elif phases.public < repo[p].phase(): |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
135 # traverse only if we did not found a proper candidate |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
136 stack.append(p) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
137 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
138 return deps, rdeps |
2916
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
139 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
140 @util.propertycache |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
141 def revs(self): |
2919
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
142 # some duplication/change from _orderrevs because we use a post |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
143 # processed dependency graph. |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
144 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
145 # Step 1: compute relation of revision with each other |
4829
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
146 origdeps, rdependencies = self._dependencies |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
147 dependencies = {} |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
148 # Making a deep copy of origdeps because we modify contents of values |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
149 # later on. Checking for list here only because right now |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
150 # builddependencies in evolvebits.py can return a list of _succs() |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
151 # objects. When that will be dealt with, this deep copy code can be |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
152 # simplified a lot. |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
153 for k, v in origdeps.items(): |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
154 if isinstance(v, list): |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
155 dependencies[k] = [i.copy() for i in v] |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
156 else: |
6b82b4f72347
stack: make a deep copy of `dependencies` before modifying its items
Anton Shestakov <av6@dwimlabs.net>
parents:
4828
diff
changeset
|
157 dependencies[k] = v.copy() |
2919
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
158 rdependencies = rdependencies.copy() |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
159 # Step 2: Build the ordering |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
160 # Remove the revisions with no dependency(A) and add them to the ordering. |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
161 # Removing these revisions leads to new revisions with no dependency (the |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
162 # one depending on A) that we can remove from the dependency graph and add |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
163 # to the ordering. We progress in a similar fashion until the ordering is |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
164 # built |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
165 solvablerevs = [r for r in sorted(dependencies.keys()) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
166 if not dependencies[r]] |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
167 revs = [] |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
168 while solvablerevs: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
169 rev = solvablerevs.pop() |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
170 for dependent in rdependencies[rev]: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
171 dependencies[dependent].remove(rev) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
172 if not dependencies[dependent]: |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
173 solvablerevs.append(dependent) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
174 del dependencies[rev] |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
175 revs.append(rev) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
176 |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
177 revs.extend(sorted(dependencies)) |
5b514ab2ab4e
stack: properly order stack when gaps existing inside it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2918
diff
changeset
|
178 # step 3: add t0 |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
179 if revs: |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
180 pt1 = self._repo[revs[0]].p1() |
2938
9872526fc39f
topic: show the t0 even if topic is not yet touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2937
diff
changeset
|
181 else: |
9872526fc39f
topic: show the t0 even if topic is not yet touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2937
diff
changeset
|
182 pt1 = self._repo['.'] |
9872526fc39f
topic: show the t0 even if topic is not yet touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2937
diff
changeset
|
183 |
9872526fc39f
topic: show the t0 even if topic is not yet touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2937
diff
changeset
|
184 if pt1.obsolete(): |
9872526fc39f
topic: show the t0 even if topic is not yet touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2937
diff
changeset
|
185 pt1 = self._repo[_singlesuccessor(self._repo, pt1)] |
9872526fc39f
topic: show the t0 even if topic is not yet touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2937
diff
changeset
|
186 revs.insert(0, pt1.rev()) |
2914
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
187 return revs |
9897babc1fb5
stack: introduce a rich stack object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2839
diff
changeset
|
188 |
2916
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
189 @util.propertycache |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
190 def changesetcount(self): |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
191 return len(self._revs) |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
192 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
193 @util.propertycache |
4581
48521a49a07e
stack: rename troubledcount to unstablecount
Anton Shestakov <av6@dwimlabs.net>
parents:
4478
diff
changeset
|
194 def unstablecount(self): |
2916
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
195 return len([r for r in self._revs if self._repo[r].isunstable()]) |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
196 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
197 @util.propertycache |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
198 def heads(self): |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
199 revs = self.revs[1:] |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
200 deps, rdeps = self._dependencies |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
201 return [r for r in revs if not rdeps[r]] |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
202 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
203 @util.propertycache |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
204 def behindcount(self): |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
205 revs = self.revs[1:] |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
206 deps, rdeps = self._dependencies |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
207 if revs: |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
208 minroot = [min(r for r in revs if not deps[r])] |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
209 try: |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
210 dest = destutil.destmerge(self._repo, action='rebase', |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
211 sourceset=minroot, |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
212 onheadcheck=False) |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
213 return len(self._repo.revs("only(%d, %ld)", dest, minroot)) |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
214 except error.NoMergeDestAbort: |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
215 return 0 |
2939
7759d040d48d
topic: provide more information when behind count cannot be computed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2938
diff
changeset
|
216 except error.ManyMergeDestAbort as exc: |
7759d040d48d
topic: provide more information when behind count cannot be computed
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2938
diff
changeset
|
217 # XXX we should make it easier for upstream to provide the information |
4759
f30c1fab7155
py3: convert exceptions to bytes using pycompat.bytestr()
Martin von Zweigbergk <martinvonz@google.com>
parents:
4658
diff
changeset
|
218 self.behinderror = pycompat.bytestr(exc).split('-', 1)[0].rstrip() |
2916
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
219 return -1 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
220 return 0 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
221 |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
222 @util.propertycache |
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
223 def branches(self): |
2936
3a9303b7b648
topics: show working directory branch when topic is empty
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2919
diff
changeset
|
224 branches = sorted(set(self._repo[r].branch() for r in self._revs)) |
3a9303b7b648
topics: show working directory branch when topic is empty
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2919
diff
changeset
|
225 if not branches: |
3a9303b7b648
topics: show working directory branch when topic is empty
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2919
diff
changeset
|
226 branches = set([self._repo[None].branch()]) |
3a9303b7b648
topics: show working directory branch when topic is empty
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2919
diff
changeset
|
227 return branches |
2916
17749d9d3968
stack: move data computation on the object
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2915
diff
changeset
|
228 |
4653
fd4f422b0b57
stack: leverage labelsgen() to produce all needed labels for fm.write()
Anton Shestakov <av6@dwimlabs.net>
parents:
4652
diff
changeset
|
229 def labelsgen(prefix, parts): |
fd4f422b0b57
stack: leverage labelsgen() to produce all needed labels for fm.write()
Anton Shestakov <av6@dwimlabs.net>
parents:
4652
diff
changeset
|
230 fmt = prefix + '.%s' |
fd4f422b0b57
stack: leverage labelsgen() to produce all needed labels for fm.write()
Anton Shestakov <av6@dwimlabs.net>
parents:
4652
diff
changeset
|
231 return prefix + ' ' + ' '.join(fmt % p.replace(' ', '-') for p in parts) |
2348
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2341
diff
changeset
|
232 |
2669
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
233 def showstack(ui, repo, branch=None, topic=None, opts=None): |
2668
1d2c66dc4ee3
topic: explicitly pass topic as a keyword argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2632
diff
changeset
|
234 if opts is None: |
1d2c66dc4ee3
topic: explicitly pass topic as a keyword argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2632
diff
changeset
|
235 opts = {} |
2627
42abd3bd30ee
topics: abort if user wants to show the stack of a non-existent topic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2626
diff
changeset
|
236 |
2669
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
237 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:
2668
diff
changeset
|
238 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:
2668
diff
changeset
|
239 msg %= (branch, topic) |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
240 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:
2668
diff
changeset
|
241 elif topic is not None: |
4067
fb4801478d5d
stack: display 's#' instead of 't#' and 'b#'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3371
diff
changeset
|
242 prefix = 's' |
2669
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
243 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:
2668
diff
changeset
|
244 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:
2668
diff
changeset
|
245 elif branch is not None: |
4067
fb4801478d5d
stack: display 's#' instead of 't#' and 'b#'
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3371
diff
changeset
|
246 prefix = 's' |
2669
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
247 else: |
b933a8068c17
topic: add some initial support for using stack on named branch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2668
diff
changeset
|
248 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') |
2627
42abd3bd30ee
topics: abort if user wants to show the stack of a non-existent topic
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2626
diff
changeset
|
249 |
1907
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1906
diff
changeset
|
250 fm = ui.formatter('topicstack', opts) |
1909
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1907
diff
changeset
|
251 prev = None |
1955
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
252 entries = [] |
1991
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1990
diff
changeset
|
253 idxmap = {} |
1995
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
254 |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
255 label = 'topic' |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
256 if topic == repo.currenttopic: |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
257 label = 'topic.active' |
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
258 |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
259 st = stack(repo, branch, topic) |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
260 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:
2669
diff
changeset
|
261 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:
2669
diff
changeset
|
262 % ui.label(topic, label), |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
263 label='stack.summary.topic') |
1998
302be26a3fd8
stack: add warning about multiple heads
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1997
diff
changeset
|
264 |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
265 if 1 < len(st.heads): |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
266 fm.plain(' (') |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
267 fm.plain('%d heads' % len(st.heads), |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
268 label='stack.summary.headcount.multiple') |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
269 fm.plain(')') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
270 fm.plain('\n') |
2997
a61634f52742
topic: try to clarify the "branch" part in stack
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2939
diff
changeset
|
271 fm.plain(_('### target: %s (branch)') |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
272 % '+'.join(st.branches), # XXX handle multi branches |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
273 label='stack.summary.branches') |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
274 if topic is None: |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
275 if 1 < len(st.heads): |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
276 fm.plain(' (') |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
277 fm.plain('%d heads' % len(st.heads), |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
278 label='stack.summary.headcount.multiple') |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
279 fm.plain(')') |
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
280 else: |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
281 if st.behindcount == -1: |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
282 fm.plain(', ') |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
283 fm.plain('ambiguous rebase destination - %s' % st.behinderror, |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
284 label='stack.summary.behinderror') |
4650
7c05b1625921
stack: get stack data directly from stack and remove stackdata()
Anton Shestakov <av6@dwimlabs.net>
parents:
4649
diff
changeset
|
285 elif st.behindcount: |
2670
f5d52fa1cd55
topic: move the heads data to the branch line when appropriates
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2669
diff
changeset
|
286 fm.plain(', ') |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
287 fm.plain('%d behind' % st.behindcount, label='stack.summary.behindcount') |
1997
ce86f7bb4b7b
stack: add some behind information
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1996
diff
changeset
|
288 fm.plain('\n') |
1995
54d6dff699f0
stack: add some header with the topic name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1991
diff
changeset
|
289 |
4652
b72cd597a887
stack: check if stack is empty more pythonically
Anton Shestakov <av6@dwimlabs.net>
parents:
4651
diff
changeset
|
290 if not st: |
2937
b54abc7e80e2
topics: improve the description if topic is not touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2936
diff
changeset
|
291 fm.plain(_("(stack is empty)\n")) |
b54abc7e80e2
topics: improve the description if topic is not touched
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2936
diff
changeset
|
292 |
4433
a19d8196b0c9
stack: optimize revset used for stack --children
Anton Shestakov <av6@dwimlabs.net>
parents:
4432
diff
changeset
|
293 st = stack(repo, branch=branch, topic=topic) |
a19d8196b0c9
stack: optimize revset used for stack --children
Anton Shestakov <av6@dwimlabs.net>
parents:
4432
diff
changeset
|
294 for idx, r in enumerate(st, 0): |
1925 | 295 ctx = repo[r] |
2712
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
296 # special case for t0, b0 as it's hard to plugin into rest of the logic |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
297 if idx == 0: |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
298 # t0, b0 can be None |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
299 if r == -1: |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
300 continue |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
301 entries.append((idx, False, ctx)) |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
302 prev = ctx.rev() |
f19b314d8475
topics: add t0 and b0 to the stack
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2684
diff
changeset
|
303 continue |
1909
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1907
diff
changeset
|
304 p1 = ctx.p1() |
2918
0437158e0ed6
stack: display both parent with displaying merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2916
diff
changeset
|
305 p2 = ctx.p2() |
1909
36112e361ee4
stack: display the base of the stack
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1907
diff
changeset
|
306 if p1.obsolete(): |
3278
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
307 try: |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
308 p1 = repo[_singlesuccessor(repo, p1)] |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
309 except MultipleSuccessorsError as e: |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
310 successors = e.successorssets |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
311 if len(successors) > 1: |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
312 # case of divergence which we don't handle yet |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
313 raise |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
314 p1 = repo[successors[0][-1]] |
e4c0332ecee4
topics: fix `hg stack` in case of split
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3225
diff
changeset
|
315 |
2918
0437158e0ed6
stack: display both parent with displaying merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2916
diff
changeset
|
316 if p2.node() != node.nullid: |
0437158e0ed6
stack: display both parent with displaying merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2916
diff
changeset
|
317 entries.append((idxmap.get(p1.rev()), False, p1)) |
0437158e0ed6
stack: display both parent with displaying merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2916
diff
changeset
|
318 entries.append((idxmap.get(p2.rev()), False, p2)) |
0437158e0ed6
stack: display both parent with displaying merge
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
2916
diff
changeset
|
319 elif p1.rev() != prev and p1.node() != node.nullid: |
1991
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1990
diff
changeset
|
320 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:
1990
diff
changeset
|
321 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:
1990
diff
changeset
|
322 idxmap[ctx.rev()] = idx |
1955
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
323 prev = r |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
324 |
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
325 # super crude initial version |
1991
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1990
diff
changeset
|
326 for idx, isentry, ctx in entries[::-1]: |
2348
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2341
diff
changeset
|
327 |
3084
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
328 symbol = None |
2348
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2341
diff
changeset
|
329 states = [] |
4285
69fb9e41ce2b
stack: add a --children flag to stack
James Reynolds <jreynolds@backstage.com>
parents:
4067
diff
changeset
|
330 if opts.get('children'): |
4433
a19d8196b0c9
stack: optimize revset used for stack --children
Anton Shestakov <av6@dwimlabs.net>
parents:
4432
diff
changeset
|
331 expr = 'children(%d) and merge() - %ld' |
4649
6b7ad4b50d00
stack: use stack._revs instead of stack.revs[1:] in external children revset
Anton Shestakov <av6@dwimlabs.net>
parents:
4581
diff
changeset
|
332 revisions = repo.revs(expr, ctx.rev(), st._revs) |
4433
a19d8196b0c9
stack: optimize revset used for stack --children
Anton Shestakov <av6@dwimlabs.net>
parents:
4432
diff
changeset
|
333 if len(revisions) > 0: |
4434
432f2155d106
stack: handle external-children just like other states
Anton Shestakov <av6@dwimlabs.net>
parents:
4433
diff
changeset
|
334 states.append('external-children') |
2348
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2341
diff
changeset
|
335 |
3084
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
336 if ctx.orphan(): |
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
337 symbol = '$' |
4434
432f2155d106
stack: handle external-children just like other states
Anton Shestakov <av6@dwimlabs.net>
parents:
4433
diff
changeset
|
338 states.append('orphan') |
3084
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
339 |
4435
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
340 if ctx.contentdivergent(): |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
341 symbol = '$' |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
342 states.append('content divergent') |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
343 |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
344 if ctx.phasedivergent(): |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
345 symbol = '$' |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
346 states.append('phase divergent') |
7915aef191ff
stack: show content and phase divergent state and symbol
Anton Shestakov <av6@dwimlabs.net>
parents:
4434
diff
changeset
|
347 |
4436
ef155f624670
stack: make @ (current) more important than $ (some sort of unstable)
Anton Shestakov <av6@dwimlabs.net>
parents:
4435
diff
changeset
|
348 iscurrentrevision = repo.revs('%d and parents()', ctx.rev()) |
ef155f624670
stack: make @ (current) more important than $ (some sort of unstable)
Anton Shestakov <av6@dwimlabs.net>
parents:
4435
diff
changeset
|
349 if iscurrentrevision: |
ef155f624670
stack: make @ (current) more important than $ (some sort of unstable)
Anton Shestakov <av6@dwimlabs.net>
parents:
4435
diff
changeset
|
350 symbol = '@' |
ef155f624670
stack: make @ (current) more important than $ (some sort of unstable)
Anton Shestakov <av6@dwimlabs.net>
parents:
4435
diff
changeset
|
351 states.append('current') |
ef155f624670
stack: make @ (current) more important than $ (some sort of unstable)
Anton Shestakov <av6@dwimlabs.net>
parents:
4435
diff
changeset
|
352 |
1991
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1990
diff
changeset
|
353 if not isentry: |
1957
ea5553e47027
stack: change the ascii symbold for base
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1956
diff
changeset
|
354 symbol = '^' |
2348
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2341
diff
changeset
|
355 # "base" is kind of a "ghost" entry |
3084
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
356 states.append('base') |
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
357 |
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
358 # none of the above if statments get executed |
144989dabe93
stack: show current and unstable also for t0 and bases
Pulkit Goyal <7895pulkit@gmail.com>
parents:
3061
diff
changeset
|
359 if not symbol: |
1955
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
360 symbol = ':' |
4434
432f2155d106
stack: handle external-children just like other states
Anton Shestakov <av6@dwimlabs.net>
parents:
4433
diff
changeset
|
361 |
432f2155d106
stack: handle external-children just like other states
Anton Shestakov <av6@dwimlabs.net>
parents:
4433
diff
changeset
|
362 if not states: |
432f2155d106
stack: handle external-children just like other states
Anton Shestakov <av6@dwimlabs.net>
parents:
4433
diff
changeset
|
363 states.append('clean') |
3085
3eca2cbdc498
stack: order the adjective of changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3084
diff
changeset
|
364 |
3eca2cbdc498
stack: order the adjective of changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3084
diff
changeset
|
365 states.sort() |
3eca2cbdc498
stack: order the adjective of changeset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
3084
diff
changeset
|
366 |
1907
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1906
diff
changeset
|
367 fm.startitem() |
4654
0d05dcb8dd37
stack: provide context to formatter with non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4653
diff
changeset
|
368 fm.context(ctx=ctx) |
1991
ba79d23594d6
stack: reusing the index number in base when applicable
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1990
diff
changeset
|
369 fm.data(isentry=isentry) |
2348
5737e0680f10
ui: hg topic now display if current revision is in bad state (issue5533)
Boris Feld <boris.feld@octobus.net>
parents:
2341
diff
changeset
|
370 |
1955
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
371 if idx is None: |
4657
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
372 spacewidth = 0 |
2750
bd3824d1b795
stack: show short node of changesets in `hg stack -v`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2712
diff
changeset
|
373 if ui.verbose: |
4657
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
374 # parentheses plus short node hash |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
375 spacewidth = 2 + 12 |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
376 if ui.debugflag: |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
377 # parentheses plus full node hash |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
378 spacewidth = 2 + 40 |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
379 # s# alias width |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
380 spacewidth += 2 |
c24dabf8e848
stack: handle hash sizes when --debug flag is provided
Anton Shestakov <av6@dwimlabs.net>
parents:
4656
diff
changeset
|
381 fm.plain(' ' * spacewidth) |
1955
5452a575b4e5
topic: extract display from entry computation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1954
diff
changeset
|
382 else: |
4655
bb0a5beb0ad8
stack: remove unnecessary prefix from stack output with non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4654
diff
changeset
|
383 fm.write('stack_index', '%s%%d' % prefix, idx, |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
384 label=labelsgen('stack.index', states)) |
2750
bd3824d1b795
stack: show short node of changesets in `hg stack -v`
Pulkit Goyal <7895pulkit@gmail.com>
parents:
2712
diff
changeset
|
385 if ui.verbose: |
4656
dbf676c86244
stack: always provide (full) node hash to non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4655
diff
changeset
|
386 fm.write('node', '(%s)', fm.hexfunc(ctx.node()), |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
387 label=labelsgen('stack.shortnode', states)) |
4656
dbf676c86244
stack: always provide (full) node hash to non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4655
diff
changeset
|
388 else: |
dbf676c86244
stack: always provide (full) node hash to non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4655
diff
changeset
|
389 fm.data(node=fm.hexfunc(ctx.node())) |
4655
bb0a5beb0ad8
stack: remove unnecessary prefix from stack output with non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4654
diff
changeset
|
390 fm.write('symbol', '%s', symbol, |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
391 label=labelsgen('stack.state', states)) |
1907
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1906
diff
changeset
|
392 fm.plain(' ') |
4655
bb0a5beb0ad8
stack: remove unnecessary prefix from stack output with non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4654
diff
changeset
|
393 fm.write('desc', '%s', ctx.description().splitlines()[0], |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
394 label=labelsgen('stack.desc', states)) |
4655
bb0a5beb0ad8
stack: remove unnecessary prefix from stack output with non-default --template
Anton Shestakov <av6@dwimlabs.net>
parents:
4654
diff
changeset
|
395 fm.condwrite(states != ['clean'] and idx is not None, 'state', |
4658
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
396 ' (%s)', fm.formatlist(states, 'stack.state'), |
89c1b739fabe
stack: remove 'topic.' prefix from colors/labels
Anton Shestakov <av6@dwimlabs.net>
parents:
4657
diff
changeset
|
397 label=labelsgen('stack.state', states)) |
1907
95874e8fc5f2
stack: add basic formatter and label support
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1906
diff
changeset
|
398 fm.plain('\n') |
2341
a5117a5becf8
ui: Fix hg stack json output
Boris Feld <boris.feld@octobus.net>
parents:
2003
diff
changeset
|
399 fm.end() |