split: add support for storing a note in obsmarker
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 17 Nov 2017 03:06:06 +0530
changeset 3216 13cb0810ce22
parent 3215 175b524b9a2b
child 3217 b6ba296532cb
split: add support for storing a note in obsmarker
hgext3rd/evolve/cmdrewrite.py
tests/test-evolve-obshistory.t
--- a/hgext3rd/evolve/cmdrewrite.py	Sun Nov 12 01:54:13 2017 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Fri Nov 17 03:06:06 2017 +0530
@@ -925,6 +925,7 @@
 @eh.command(
     '^split',
     [('r', 'rev', [], _("revision to split")),
+     ('n', 'note', '', _("store a note on split")),
     ] + commitopts + commitopts2 + commitopts3,
     _('hg split [OPTION]... [-r] REV'))
 def cmdsplit(ui, repo, *revs, **opts):
@@ -935,6 +936,7 @@
 
     Use --rev to split a given changeset instead.
     """
+    _checknotesize(opts)
     _resolveoptions(ui, opts)
     tr = wlock = lock = None
     newcommits = []
@@ -996,7 +998,11 @@
             bmupdate(tip.node())
             if bookactive is not None:
                 bookmarksmod.activate(repo, bookactive)
-            obsolete.createmarkers(repo, [(repo[rev], newcommits)])
+            metadata = {}
+            if opts.get('note'):
+                metadata['note'] = opts['note']
+            obsolete.createmarkers(repo, [(repo[rev], newcommits)],
+                                   metadata=metadata)
         tr.close()
     finally:
         lockmod.release(tr, lock, wlock)
--- a/tests/test-evolve-obshistory.t	Sun Nov 12 01:54:13 2017 +0530
+++ b/tests/test-evolve-obshistory.t	Fri Nov 17 03:06:06 2017 +0530
@@ -308,7 +308,7 @@
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     ROOT
   
-  $ hg split -r 'desc(A0)' -d "0 0" << EOF
+  $ hg split -r 'desc(A0)' -n "testing split" -d "0 0" << EOF
   > y
   > y
   > n
@@ -374,6 +374,7 @@
   $ hg obslog 471597cad322 --hidden --patch
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
   $ hg obslog 471597cad322 --hidden --no-graph -Tjson | python -m json.tool
@@ -389,6 +390,7 @@
                       "parent",
                       "content"
                   ],
+                  "note": "testing split",
                   "succnodes": [
                       "337fec4d2edc",
                       "f257fde29c7a"
@@ -409,6 +411,7 @@
   |
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
 With the all option, it should show the three changesets
@@ -419,6 +422,7 @@
   |/
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
 Check that debugobshistory on the second successor after split show
@@ -428,6 +432,7 @@
   |
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
 With the all option, it should show the three changesets
@@ -438,6 +443,7 @@
   |/
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
 Obslog with all option all should also works on the splitted commit
@@ -448,6 +454,7 @@
   |/
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
 Check that debugobshistory on both successors after split show
@@ -459,6 +466,7 @@
   |/
   x  471597cad322 (1) A0
        rewritten(parent, content) as 337fec4d2edc, f257fde29c7a by test (*) (glob)
+         note: 'testing split'
          (No patch available, too many successors (2))
   
   $ hg update 471597cad322