changeset 2372:a0099d568ef8

merge with stable
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 17 May 2017 09:52:06 +0200
parents 48e879b3f5b6 (current diff) 3be45918c7b5 (diff)
children 2a1aad0fd8bf
files README hgext3rd/evolve/obscache.py
diffstat 4 files changed, 98 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/README	Wed May 17 00:23:19 2017 +0200
+++ b/README	Wed May 17 09:52:06 2017 +0200
@@ -127,6 +127,9 @@
 -------------------
 
  - also enable the new cache (from 6.1.0) for 'evolve.server-only',
+ - fix hg stack json output to be valid json
+ - stack: now display if current revision is in bad state (issue5533)
+ - obscache: fix more cache invalidation propagation
 
 6.1.0 -- 2017-05-03
 -------------------
--- a/hgext3rd/evolve/obscache.py	Wed May 17 00:23:19 2017 +0200
+++ b/hgext3rd/evolve/obscache.py	Wed May 17 09:52:06 2017 +0200
@@ -482,6 +482,7 @@
         def destroyed(self):
             if 'obsstore' in vars(self):
                 self.obsstore.obscache.clear()
+            super(obscacherepo, self).destroyed()
 
         def transaction(self, *args, **kwargs):
             tr = super(obscacherepo, self).transaction(*args, **kwargs)
--- a/hgext3rd/topic/stack.py	Wed May 17 00:23:19 2017 +0200
+++ b/hgext3rd/topic/stack.py	Wed May 17 09:52:06 2017 +0200
@@ -15,6 +15,12 @@
     trevs = repo.revs("topic(%s) - obsolete()", topic)
     return _orderrevs(repo, trevs)
 
+def labelsgen(prefix, labelssuffix):
+    """ Takes a label prefix and a list of suffixes. Returns a string of the prefix
+    formatted with each suffix separated with a space.
+    """
+    return ' '.join(prefix % suffix for suffix in labelssuffix)
+
 def showstack(ui, repo, topic, opts):
     fm = ui.formatter('topicstack', opts)
     prev = None
@@ -59,35 +65,44 @@
 
     # super crude initial version
     for idx, isentry, ctx in entries[::-1]:
+
+        states = []
+        iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
+
+        if iscurrentrevision:
+            states.append('current')
+
         if not isentry:
             symbol = '^'
-            state = 'base'
-        elif repo.revs('%d and parents()', ctx.rev()):
+            # "base" is kind of a "ghost" entry
+            # skip other label for them (no current, no unstable)
+            states = ['base']
+        elif iscurrentrevision:
             symbol = '@'
-            state = 'current'
         elif repo.revs('%d and unstable()', ctx.rev()):
             symbol = '$'
-            state = 'unstable'
+            states.append('unstable')
         else:
             symbol = ':'
-            state = 'clean'
+            states.append('clean')
         fm.startitem()
         fm.data(isentry=isentry)
+
         if idx is None:
             fm.plain('  ')
         else:
             fm.write('topic.stack.index', 't%d', idx,
-                     label='topic.stack.index topic.stack.index.%s' % state)
+                     label='topic.stack.index ' + labelsgen('topic.stack.index.%s', states))
         fm.write('topic.stack.state.symbol', '%s', symbol,
-                 label='topic.stack.state topic.stack.state.%s' % state)
+                 label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states))
         fm.plain(' ')
         fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0],
-                 label='topic.stack.desc topic.stack.desc.%s' % state)
-        fm.condwrite(state != 'clean' and idx is not None, 'topic.stack.state',
-                     ' (%s)', state,
-                     label='topic.stack.state topic.stack.state.%s' % state)
+                 label='topic.stack.desc ' + labelsgen('topic.stack.desc.%s', states))
+        fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state',
+                     ' (%s)', fm.formatlist(states, 'topic.stack.state'),
+                     label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states))
         fm.plain('\n')
-        fm.end()
+    fm.end()
 
 def stackdata(repo, topic):
     """get various data about a stack
--- a/tests/test-topic-stack.t	Wed May 17 00:23:19 2017 +0200
+++ b/tests/test-topic-stack.t	Wed May 17 09:52:06 2017 +0200
@@ -77,6 +77,53 @@
   t2: c_d
   t1: c_c
     ^ c_b
+  $ hg stack -Tjson | python -m json.tool
+  [
+      {
+          "isentry": true,
+          "topic.stack.desc": "c_f",
+          "topic.stack.index": 4,
+          "topic.stack.state": [
+              "current"
+          ],
+          "topic.stack.state.symbol": "@"
+      },
+      {
+          "isentry": true,
+          "topic.stack.desc": "c_e",
+          "topic.stack.index": 3,
+          "topic.stack.state": [
+              "clean"
+          ],
+          "topic.stack.state.symbol": ":"
+      },
+      {
+          "isentry": true,
+          "topic.stack.desc": "c_d",
+          "topic.stack.index": 2,
+          "topic.stack.state": [
+              "clean"
+          ],
+          "topic.stack.state.symbol": ":"
+      },
+      {
+          "isentry": true,
+          "topic.stack.desc": "c_c",
+          "topic.stack.index": 1,
+          "topic.stack.state": [
+              "clean"
+          ],
+          "topic.stack.state.symbol": ":"
+      },
+      {
+          "isentry": false,
+          "topic.stack.desc": "c_b",
+          "topic.stack.state": [
+              "base"
+          ],
+          "topic.stack.state.symbol": "^"
+      }
+  ]
 
 error case, nothing to list
 
@@ -135,6 +182,26 @@
   t2@ c_d (current)
   t1: c_c
     ^ c_b
+  $ hg up t3
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg topic --list
+  ### topic: foo
+  ### branch: default
+  t4$ c_f (unstable)
+  t3@ c_e (current)
+  t2: c_d
+  t1: c_c
+    ^ c_b
+  $ hg topic --list --color=debug
+  [topic.stack.summary.topic|### topic: [topic.active|foo]]
+  [topic.stack.summary.branches|### branch: default]
+  [topic.stack.index topic.stack.index.unstable|t4][topic.stack.state topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.unstable|c_f][topic.stack.state topic.stack.state.unstable| (unstable)]
+  [topic.stack.index topic.stack.index.current|t3][topic.stack.state topic.stack.state.current|@] [topic.stack.desc topic.stack.desc.current|c_e][topic.stack.state topic.stack.state.current| (current)]
+  [topic.stack.index topic.stack.index.clean|t2][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_d]
+  [topic.stack.index topic.stack.index.clean|t1][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_c]
+    [topic.stack.state topic.stack.state.base|^] [topic.stack.desc topic.stack.desc.base|c_b]
+  $ hg up t2
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
 
 Also test the revset: