touch: add support for storing a note in obsmarker
authorPulkit Goyal <7895pulkit@gmail.com>
Sun, 12 Nov 2017 01:54:13 +0530
changeset 3215 175b524b9a2b
parent 3214 9fe2b3fd7fc7
child 3216 13cb0810ce22
touch: add support for storing a note in obsmarker
hgext3rd/evolve/cmdrewrite.py
tests/test-touch.t
--- a/hgext3rd/evolve/cmdrewrite.py	Sun Nov 12 01:35:51 2017 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Sun Nov 12 01:54:13 2017 +0530
@@ -1004,6 +1004,7 @@
 @eh.command(
     '^touch',
     [('r', 'rev', [], 'revision to update'),
+     ('n', 'note', '', _('store a note on touch')),
      ('D', 'duplicate', False,
       'do not mark the new revision as successor of the old one'),
      ('A', 'allowdivergence', False,
@@ -1017,6 +1018,7 @@
 
     This is used to "resurrect" changesets
     """
+    _checknotesize(opts)
     duplicate = opts['duplicate']
     allowdivergence = opts['allowdivergence']
     revs = list(revs)
@@ -1080,7 +1082,11 @@
             newmapping[ctx.node()] = new
 
             if not duplicate:
-                obsolete.createmarkers(repo, [(ctx, (repo[new],))])
+                metadata = {}
+                if opts.get('note'):
+                    metadata['note'] = opts['note']
+                obsolete.createmarkers(repo, [(ctx, (repo[new],))],
+                                       metadata=metadata)
             phases.retractboundary(repo, tr, ctx.phase(), [new])
             if ctx in repo[None].parents():
                 with repo.dirstate.parentchange():
--- a/tests/test-touch.t	Sun Nov 12 01:35:51 2017 +0530
+++ b/tests/test-touch.t	Sun Nov 12 01:54:13 2017 +0530
@@ -151,5 +151,11 @@
 
   $ hg prune 13
   1 changesets pruned
-  $ hg touch 13 --hidden
+  $ hg touch 13 --hidden --note "testing with no successor"
   1 new orphan changesets
+  $ hg obslog -r 13 --hidden
+  x  [0-9a-f]{12} (.*) move (re)
+       pruned by test (Thu Jan 01 00:00:00 1970 +0000)
+       rewritten(.*) as [0-9a-f]{12} by test (.*) (re)
+         note: 'testing with no successor'
+