Mercurial > evolve
changeset 3278:e4c0332ecee4 stable
topics: fix `hg stack` in case of split
This patch fixes the behaviour of hg stack which throws an error in some cases
when there are multiple successors. The case of divergence is not handled yet.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 11 Dec 2017 23:47:25 +0530 |
parents | 0a6954bd6502 |
children | ee71cc4eff21 |
files | CHANGELOG hgext3rd/topic/stack.py tests/test-topic-stack-complex.t |
diffstat | 3 files changed, 20 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG Mon Dec 11 23:33:50 2017 +0530 +++ b/CHANGELOG Mon Dec 11 23:47:25 2017 +0530 @@ -9,6 +9,7 @@ Topic (0.5.2) * makes code more resilient to partiel initialization + * fix behavior of `hg stack` in cases of split 7.0.1 -- 2017-11-14 -------------------
--- a/hgext3rd/topic/stack.py Mon Dec 11 23:33:50 2017 +0530 +++ b/hgext3rd/topic/stack.py Mon Dec 11 23:47:25 2017 +0530 @@ -12,7 +12,11 @@ obsolete, util, ) -from .evolvebits import builddependencies, _singlesuccessor +from .evolvebits import ( + _singlesuccessor, + MultipleSuccessorsError, + builddependencies, +) short = node.short @@ -285,7 +289,15 @@ p1 = ctx.p1() p2 = ctx.p2() if p1.obsolete(): - p1 = repo[_singlesuccessor(repo, p1)] + try: + p1 = repo[_singlesuccessor(repo, p1)] + except MultipleSuccessorsError as e: + successors = e.successorssets + if len(successors) > 1: + # case of divergence which we don't handle yet + raise + p1 = repo[successors[0][-1]] + if p2.node() != node.nullid: entries.append((idxmap.get(p1.rev()), False, p1)) entries.append((idxmap.get(p2.rev()), False, p2))
--- a/tests/test-topic-stack-complex.t Mon Dec 11 23:33:50 2017 +0530 +++ b/tests/test-topic-stack-complex.t Mon Dec 11 23:47:25 2017 +0530 @@ -128,41 +128,8 @@ $ hg stack ### topic: foo (2 heads) ### target: default (branch), 2 behind - ** unknown exception encountered, please report by visiting - ** https://mercurial-scm.org/wiki/BugTracker - ** Python 2.7.12 (default, Jul 18 2016, 15:04:44) [GCC 4.8.4] - ** Mercurial Distributed SCM (version 4.4.2+379-6812f5c492c7) - ** Extensions loaded: rebase, topic, show, evolve - Traceback (most recent call last): - File "/tmp/hgtests.d2IKdr/install/bin/hg", line 41, in <module> - dispatch.run() - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 88, in run - status = (dispatch(req) or 0) & 255 - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 177, in dispatch - ret = _runcatch(req) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 318, in _runcatch - return _callcatch(ui, _runcatchfunc) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 326, in _callcatch - return scmutil.callcatch(ui, func) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/scmutil.py", line 154, in callcatch - return func() - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 308, in _runcatchfunc - return _dispatch(req) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 912, in _dispatch - cmdpats, cmdoptions) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 667, in runcommand - ret = _runcommand(ui, options, cmd, d) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 920, in _runcommand - return cmdfunc() - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/dispatch.py", line 909, in <lambda> - d = lambda: util.checksignature(func)(ui, *args, **strcmdopt) - File "/tmp/hgtests.d2IKdr/install/lib/python/mercurial/util.py", line 1188, in check - return func(*args, **kwargs) - File "/home/pulkit/repo/mutable-history/hgext3rd/topic/__init__.py", line 663, in cmdstack - return stack.showstack(ui, repo, branch=branch, topic=topic, opts=opts) - File "/home/pulkit/repo/mutable-history/hgext3rd/topic/stack.py", line 288, in showstack - p1 = repo[_singlesuccessor(repo, p1)] - File "/home/pulkit/repo/mutable-history/hgext3rd/topic/evolvebits.py", line 92, in _singlesuccessor - raise MultipleSuccessorsError(newer) - hgext3rd.topic.evolvebits.MultipleSuccessorsError - [1] + t4$ Added e and f (unstable) + t3$ split2 (unstable) + t2@ split1 (current) + t1: Added a and b + t0^ Added foo (base)