20 if not util.safehasattr(context.basectx, 'orphan'): |
21 if not util.safehasattr(context.basectx, 'orphan'): |
21 context.basectx.orphan = context.basectx.unstable |
22 context.basectx.orphan = context.basectx.unstable |
22 |
23 |
23 if not util.safehasattr(context.basectx, 'isunstable'): |
24 if not util.safehasattr(context.basectx, 'isunstable'): |
24 context.basectx.isunstable = context.basectx.troubled |
25 context.basectx.isunstable = context.basectx.troubled |
|
26 |
|
27 def _stackcandidates(repo): |
|
28 """build the smaller set of revs that might be part of a stack. |
|
29 |
|
30 The intend is to build something more efficient than what revsets do in |
|
31 this area. |
|
32 """ |
|
33 phasecache = repo._phasecache |
|
34 if not phasecache._phasesets: |
|
35 return repo.revs('(not public()) - obsolete()') |
|
36 if any(s is None for s in phasecache._phasesets): |
|
37 return repo.revs('(not public()) - obsolete()') |
|
38 |
|
39 result = set() |
|
40 for s in phasecache._phasesets[phases.draft:]: |
|
41 result |= s |
|
42 |
|
43 result -= obsolete.getrevs(repo, 'obsolete') |
|
44 return result |
25 |
45 |
26 class stack(object): |
46 class stack(object): |
27 """object represent a stack and common logic associated to it.""" |
47 """object represent a stack and common logic associated to it.""" |
28 |
48 |
29 def __init__(self, repo, branch=None, topic=None): |
49 def __init__(self, repo, branch=None, topic=None): |
30 self._repo = repo |
50 self._repo = repo |
31 self.branch = branch |
51 self.branch = branch |
32 self.topic = topic |
52 self.topic = topic |
33 self.behinderror = None |
53 self.behinderror = None |
|
54 |
|
55 subset = _stackcandidates(repo) |
|
56 |
34 if topic is not None and branch is not None: |
57 if topic is not None and branch is not None: |
35 raise error.ProgrammingError('both branch and topic specified (not defined yet)') |
58 raise error.ProgrammingError('both branch and topic specified (not defined yet)') |
36 elif topic is not None: |
59 elif topic is not None: |
37 trevs = repo.revs("not obsolete() and topic(%s)", topic) |
60 trevs = repo.revs("%ld and topic(%s)", subset, topic) |
38 elif branch is not None: |
61 elif branch is not None: |
39 trevs = repo.revs("not public() and branch(%s) - obsolete() - topic()", branch) |
62 trevs = repo.revs("%ld and branch(%s) - topic()", subset, branch) |
40 else: |
63 else: |
41 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') |
64 raise error.ProgrammingError('neither branch and topic specified (not defined yet)') |
42 self._revs = trevs |
65 self._revs = trevs |
43 |
66 |
44 def __iter__(self): |
67 def __iter__(self): |