uncommit: add support for storing a note in obsmarker
authorPulkit Goyal <7895pulkit@gmail.com>
Fri, 17 Nov 2017 03:14:31 +0530
changeset 3220 f0f4cc2febac
parent 3219 b73bd280b21c
child 3221 9f3521cc4c90
uncommit: add support for storing a note in obsmarker
hgext3rd/evolve/cmdrewrite.py
tests/test-tutorial.t
tests/test-uncommit-interactive.t
--- a/hgext3rd/evolve/cmdrewrite.py	Fri Nov 17 03:14:20 2017 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Fri Nov 17 03:14:31 2017 +0530
@@ -300,6 +300,7 @@
     [('a', 'all', None, _('uncommit all changes when no arguments given')),
      ('i', 'interactive', False, _('interactive mode to uncommit (EXPERIMENTAL)')),
      ('r', 'rev', '', _('revert commit content to REV instead')),
+     ('n', 'note', '', _('store a note on uncommit')),
      ] + commands.walkopts + commitopts + commitopts2 + commitopts3,
     _('[OPTION]... [NAME]'))
 def uncommit(ui, repo, *pats, **opts):
@@ -325,6 +326,7 @@
     Return 0 if changed files are uncommitted.
     """
 
+    _checknotesize(opts)
     _resolveoptions(ui, opts) # process commitopts3
     interactive = opts.get('interactive')
     wlock = lock = tr = None
@@ -377,7 +379,12 @@
                 raise error.Abort(_('nothing to uncommit'),
                                   hint=_("use --all to uncommit all files"))
 
-        obsolete.createmarkers(repo, [(old, (repo[newid],))])
+        # metadata to be stored in obsmarker
+        metadata = {}
+        if opts.get('note'):
+            metadata['note'] = opts['note']
+
+        obsolete.createmarkers(repo, [(old, (repo[newid],))], metadata=metadata)
         phases.retractboundary(repo, tr, oldphase, [newid])
         with repo.dirstate.parentchange():
             repo.dirstate.setparents(newid, node.nullid)
--- a/tests/test-tutorial.t	Fri Nov 17 03:14:20 2017 +0530
+++ b/tests/test-tutorial.t	Fri Nov 17 03:14:31 2017 +0530
@@ -937,6 +937,7 @@
   
    -a --all                 uncommit all changes when no arguments given
    -r --rev VALUE           revert commit content to REV instead
+   -n --note VALUE          store a note on uncommit
    -I --include PATTERN [+] include names matching the given patterns
    -X --exclude PATTERN [+] exclude names matching the given patterns
    -m --message TEXT        use text as commit message
--- a/tests/test-uncommit-interactive.t	Fri Nov 17 03:14:20 2017 +0530
+++ b/tests/test-uncommit-interactive.t	Fri Nov 17 03:14:31 2017 +0530
@@ -220,7 +220,7 @@
    2
    3
 
-  $ hg uncommit -i<<EOF
+  $ hg uncommit -n "testing uncommit on dirty wdir" -i<<EOF
   > y
   > n
   > y
@@ -293,6 +293,7 @@
   |
   x  678a59e5ff90 (3) another one
   |    rewritten(content) as 46e35360be47 by test (Thu Jan 01 00:00:00 1970 +0000)
+  |      note: 'testing uncommit on dirty wdir'
   |
   x  f70fb463d5bf (1) another one
        rewritten(content) as 678a59e5ff90 by test (Thu Jan 01 00:00:00 1970 +0000)