obshistory: display a message when one marker node has no change ctx
authorBoris Feld <boris.feld@octobus.net>
Fri, 12 May 2017 11:39:41 +0200
changeset 2349 521a18a10a06
parent 2347 24bf0e3d84e3
child 2350 ea816b5c1cf6
obshistory: display a message when one marker node has no change ctx When exchanging obs markers, there is some change contexts referencing change contexts that are not available locally. As we cannot display informations about them, instead print a message saying so.
hgext3rd/evolve/__init__.py
tests/test-evolve-obshistory.t
--- a/hgext3rd/evolve/__init__.py	Thu May 11 17:00:55 2017 +0200
+++ b/hgext3rd/evolve/__init__.py	Fri May 12 11:39:41 2017 +0200
@@ -3288,14 +3288,19 @@
 
         markerfm = fm.nested("debugobshistory.markers")
         for successor in sorted(succs):
-            _debugobshistorydisplaymarker(ui, markerfm, repo, successor)
+            _debugobshistorydisplaymarker(markerfm, repo, successor)
         markerfm.end()
 
         precs = precursors.get(ctxnode, ())
         nodes.extend(precursor[0] for precursor in sorted(precs))
 
 def _debugobshistorydisplaynode(ui, fm, repo, node):
-    ctx = repo.unfiltered()[node]
+    if node in repo.unfiltered():
+        _debugobshistorydisplayctx(fm, repo.unfiltered()[node])
+    else:
+        _debugobshistorydisplaymissingctx(fm, node)
+
+def _debugobshistorydisplayctx(fm, ctx):
     shortdescription = ctx.description().splitlines()[0]
 
     fm.startitem()
@@ -3311,7 +3316,14 @@
              label="evolve.short_description")
     fm.plain('\n')
 
-def _debugobshistorydisplaymarker(ui, fm, repo, marker):
+def _debugobshistorydisplaymissingctx(fm, nodewithoutctx):
+    hexnode = node.short(nodewithoutctx)
+    fm.startitem()
+    fm.write('debugobshistory.node', '%s', hexnode,
+             label="evolve.short_node evolve.missing_change_ctx")
+    fm.plain('\n')
+
+def _debugobshistorydisplaymarker(fm, repo, marker):
     succnodes = marker[1]
     date = marker[4]
     metadata = dict(marker[3])
--- a/tests/test-evolve-obshistory.t	Thu May 11 17:00:55 2017 +0200
+++ b/tests/test-evolve-obshistory.t	Fri May 12 11:39:41 2017 +0200
@@ -1200,3 +1200,102 @@
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   working directory parent is obsolete! (0dec01379d3b)
   (use 'hg evolve' to update to its successor: eb5a0daa2192)
+
+Test output with pushed and pulled obs markers
+==============================================
+
+Test setup
+----------
+
+  $ hg init $TESTTMP/local-remote-markers-1
+  $ cd $TESTTMP/local-remote-markers-1
+  $ mkcommit ROOT
+  $ mkcommit A0
+  $ hg log --hidden -G
+  @  changeset:   1:471f378eab4c
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     A0
+  |
+  o  changeset:   0:ea207398892e
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     ROOT
+  
+  $ hg clone $TESTTMP/local-remote-markers-1 $TESTTMP/local-remote-markers-2
+  updating to branch default
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd $TESTTMP/local-remote-markers-2
+  $ hg log --hidden -G
+  @  changeset:   1:471f378eab4c
+  |  tag:         tip
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     A0
+  |
+  o  changeset:   0:ea207398892e
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     ROOT
+  
+  $ cd $TESTTMP/local-remote-markers-1
+  $ hg amend -m "A1"
+  $ hg amend -m "A2"
+  $ hg log --hidden -G
+  @  changeset:   3:7a230b46bf61
+  |  tag:         tip
+  |  parent:      0:ea207398892e
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     A2
+  |
+  | x  changeset:   2:fdf9bde5129a
+  |/   parent:      0:ea207398892e
+  |    user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     A1
+  |
+  | x  changeset:   1:471f378eab4c
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     A0
+  |
+  o  changeset:   0:ea207398892e
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     ROOT
+  
+ Actual test
+ -----------
+
+  $ hg debugobshistory 7a230b46bf61
+  7a230b46bf61 (3) A2
+  fdf9bde5129a (2) A1
+    rewritten by test (*20*) as 7a230b46bf61 (glob)
+  471f378eab4c (1) A0
+    rewritten by test (*20*) as fdf9bde5129a (glob)
+  $ cd $TESTTMP/local-remote-markers-2
+  $ hg pull
+  pulling from $TESTTMP/local-remote-markers-1
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 0 changes to 1 files (+1 heads)
+  2 new obsolescence markers
+  (run 'hg heads' to see heads, 'hg merge' to merge)
+  working directory parent is obsolete! (471f378eab4c)
+  (use 'hg evolve' to update to its successor: 7a230b46bf61)
+  $ hg debugobshistory 7a230b46bf61 --traceback
+  7a230b46bf61 (2) A2
+  fdf9bde5129a
+    rewritten by test (*20*) as 7a230b46bf61 (glob)
+  471f378eab4c (1) A0
+    rewritten by test (*20*) as fdf9bde5129a (glob)
+  $ hg debugobshistory 7a230b46bf61 --color=debug
+  [evolve.short_node|7a230b46bf61] [evolve.rev|(2)] [evolve.short_description|A2]
+  [evolve.short_node evolve.missing_change_ctx|fdf9bde5129a]
+    [evolve.verb|rewritten] by [evolve.user|test] [evolve.date|(*20*)] as [evolve.short_node|7a230b46bf61] (glob)
+  [evolve.short_node|471f378eab4c] [evolve.rev|(1)] [evolve.short_description|A0]
+    [evolve.verb|rewritten] by [evolve.user|test] [evolve.date|(*20*)] as [evolve.short_node|fdf9bde5129a] (glob)