stack: also change the indexing of the t# reference
authorPierre-Yves David <pierre-yves.david@fb.com>
Sun, 03 Apr 2016 21:41:38 -0700
changeset 1958 62d5d4206840
parent 1957 ea5553e47027
child 1959 6789d5d9f2b0
stack: also change the indexing of the t# reference Changeset 61f36480740f changed the index displayed (we now index from 1), but forgot to update the logic used to resolve the 't#' name. This changeset fixes it.
hgext3rd/topic/__init__.py
tests/test-topic-stack.t
--- a/hgext3rd/topic/__init__.py	Fri Apr 01 16:58:52 2016 -0700
+++ b/hgext3rd/topic/__init__.py	Sun Apr 03 21:41:38 2016 -0700
@@ -69,7 +69,7 @@
             raise error.Abort(_('cannot resolve "%s": no active topic') % name)
         revs = list(stack.getstack(repo, topic))
         try:
-            r = revs[idx]
+            r = revs[idx - 1]
         except IndexError:
             msg = _('cannot resolve "%s": topic "%s" has only %d changesets')
             raise error.Abort(msg % (name, topic, len(revs)))
--- a/tests/test-topic-stack.t	Fri Apr 01 16:58:52 2016 -0700
+++ b/tests/test-topic-stack.t	Sun Apr 03 21:41:38 2016 -0700
@@ -71,15 +71,23 @@
 -------------------
 
 
-  $ hg up t1
-  abort: cannot resolve "t1": no active topic
+  $ hg up t2
+  abort: cannot resolve "t2": no active topic
   [255]
   $ hg topic foo
   $ hg up t42
   abort: cannot resolve "t42": topic "foo" has only 4 changesets
   [255]
-  $ hg up t1
+  $ hg up t2
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ hg summary
+  parent: 3:f9c59b863cdb 
+   c_d
+  branch: default
+  commit: (clean)
+  update: (current)
+  phases: 6 draft
+  topic:  foo
 
 Case with some of the topic unstable
 ------------------------------------