changeset 3219:b73bd280b21c

fold: add support for storing a note in obsmarker
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 17 Nov 2017 03:14:20 +0530
parents 772cc931f085
children f0f4cc2febac
files hgext3rd/evolve/cmdrewrite.py tests/test-evolve-obshistory-complex.t tests/test-tutorial.t
diffstat 3 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/cmdrewrite.py	Fri Nov 17 03:14:08 2017 +0530
+++ b/hgext3rd/evolve/cmdrewrite.py	Fri Nov 17 03:14:20 2017 +0530
@@ -489,7 +489,8 @@
     '^fold|squash',
     [('r', 'rev', [], _("revision to fold")),
      ('', 'exact', None, _("only fold specified revisions")),
-     ('', 'from', None, _("fold revisions linearly to working copy parent"))
+     ('', 'from', None, _("fold revisions linearly to working copy parent")),
+     ('n', 'note', '', _('store a note on fold')),
     ] + commitopts + commitopts2 + commitopts3,
     _('hg fold [OPTION]... [-r] REV'))
 def fold(ui, repo, *revs, **opts):
@@ -529,6 +530,7 @@
 
          hg fold foo::@ --exact
     """
+    _checknotesize(opts)
     _resolveoptions(ui, opts)
     revs = list(revs)
     revs.extend(opts['rev'])
@@ -584,6 +586,10 @@
                 commitopts['message'] = "\n".join(msgs)
                 commitopts['edit'] = True
 
+            metadata = {}
+            if opts.get('note'):
+                metadata['note'] = opts['note']
+
             newid, unusedvariable = rewriteutil.rewrite(repo, root, allctx,
                                                         head,
                                                         [root.p1().node(),
@@ -591,7 +597,7 @@
                                                         commitopts=commitopts)
             phases.retractboundary(repo, tr, targetphase, [newid])
             obsolete.createmarkers(repo, [(ctx, (repo[newid],))
-                                   for ctx in allctx])
+                                   for ctx in allctx], metadata=metadata)
             tr.close()
         finally:
             tr.release()
--- a/tests/test-evolve-obshistory-complex.t	Fri Nov 17 03:14:08 2017 +0530
+++ b/tests/test-evolve-obshistory-complex.t	Fri Nov 17 03:14:20 2017 +0530
@@ -71,9 +71,20 @@
   4 new orphan changesets
   $ hg fold --exact -r 3 -r 4 --date "0 0" -m "fold1"
   2 changesets folded
-  $ hg fold --exact -r 5 -r 6 --date "0 0" -m "fold2"
+  $ hg fold --exact -r 5 -r 6 --date "0 0" -m "fold2" -n "folding changesets to test"
   2 changesets folded
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg obslog -r .
+  @    100cc25b765f (9) fold2
+  |\
+  x |  0da815c333f6 (5) E
+   /     rewritten(description, content) as 100cc25b765f by test (Thu Jan 01 00:00:00 1970 +0000)
+  |        note: 'folding changesets to test'
+  |
+  x  d9f908fde1a1 (6) F
+       rewritten(description, parent, content) as 100cc25b765f by test (Thu Jan 01 00:00:00 1970 +0000)
+         note: 'folding changesets to test'
+  
   $ hg log -G 
   @  changeset:   9:100cc25b765f
   |  tag:         tip
@@ -417,6 +428,7 @@
   | | | |
   | | x |  0da815c333f6 (5) E
   | |  /     rewritten(description, content) as 100cc25b765f by test (*) (glob)
+  | | |        note: 'folding changesets to test'
   | | |
   x | |    b868bc49b0a4 (7) fold0
   |\ \ \     rewritten(parent, content) as 19e14c8397fc, e036916b63ea by test (*) (glob)
@@ -426,6 +438,7 @@
   | | | | |
   | | | | x  d9f908fde1a1 (6) F
   | | | |      rewritten(description, parent, content) as 100cc25b765f by test (*) (glob)
+  | | | |        note: 'folding changesets to test'
   | | | |
   x | | |  2a34000d3544 (1) A
    / / /     rewritten(description, content) as b868bc49b0a4 by test (*) (glob)
--- a/tests/test-tutorial.t	Fri Nov 17 03:14:08 2017 +0530
+++ b/tests/test-tutorial.t	Fri Nov 17 03:14:20 2017 +0530
@@ -976,6 +976,7 @@
    -r --rev VALUE [+] revision to fold
       --exact         only fold specified revisions
       --from          fold revisions linearly to working copy parent
+   -n --note VALUE    store a note on fold
    -m --message TEXT  use text as commit message
    -l --logfile FILE  read commit message from file
    -d --date DATE     record the specified date as commit date