obslog: make note template property into notes
authorAnton Shestakov <av6@dwimlabs.net>
Tue, 18 Feb 2020 18:10:58 +0800
changeset 5170 f8488bdc9e4b
parent 5169 897b371cd0c5
child 5171 7f7f40cc6c9b
obslog: make note template property into notes
hgext3rd/evolve/obshistory.py
tests/test-evolve-obshistory-split.t
--- a/hgext3rd/evolve/obshistory.py	Tue Feb 18 18:07:11 2020 +0800
+++ b/hgext3rd/evolve/obshistory.py	Tue Feb 18 18:10:58 2020 +0800
@@ -118,17 +118,17 @@
 TEMPLATE_OPERATIONS = b"""{if(operations, "using {label("evolve.operation", join(operations, ", "))}")}"""
 TEMPLATE_USERS = b"""by {label("evolve.user", join(users, ", "))}"""
 TEMPLATE_DATE = b"""{label("evolve.date", "({date(date, "%a %b %d %H:%M:%S %Y %1%2")})")}"""
-TEMPLATE_NOTE = b"""{if(note, "\n    note: {label("evolve.note", note)}")}"""
+TEMPLATE_NOTES = b"""{if(notes, notes % "\n    note: {label("evolve.note", note)}")}"""
 TEMPLATE_PATCH = b"""{if(patch, "{patch}")}{if(nopatchreason, "\n(No patch available, {nopatchreason})")}"""
 DEFAULT_TEMPLATE = (b"""%(firstline)s
-{markers %% "  {separate(" ", "%(rewrite)s", "%(operations)s", "%(users)s", "%(date)s")}%(note)s{indent(descdiff, "    ")}{indent("%(patch)s", "    ")}\n"}
+{markers %% "  {separate(" ", "%(rewrite)s", "%(operations)s", "%(users)s", "%(date)s")}%(notes)s{indent(descdiff, "    ")}{indent("%(patch)s", "    ")}\n"}
 """) % {
     b"firstline": TEMPLATE_FIRST_LINE,
     b"rewrite": TEMPLATE_REWRITE,
     b"operations": TEMPLATE_OPERATIONS,
     b"users": TEMPLATE_USERS,
     b"date": TEMPLATE_DATE,
-    b"note": TEMPLATE_NOTE,
+    b"notes": TEMPLATE_NOTES,
     b"patch": TEMPLATE_PATCH,
 }
 
@@ -499,7 +499,6 @@
 def _debugobshistorydisplaymarker(ui, fm, marker, node, repo, includediff=False):
     succnodes = marker[1]
     date = marker[4]
-    metadata = dict(marker[3])
 
     fm.startitem()
 
@@ -528,9 +527,10 @@
 
     fm.data(date=date)
 
-    # initial support for showing note
-    if metadata.get(b'note'):
-        fm.data(note=metadata[b'note'])
+    # Notes
+    notes = _markersnotes([marker])
+    if notes:
+        fm.data(notes=fm.formatlist(notes, name=b'note', sep=b'\n'))
 
     # Patch display
     if includediff is True:
@@ -734,6 +734,11 @@
 
     return (fate, successors)
 
+def _markersnotes(markers):
+    markersmeta = [dict(m[3]) for m in markers]
+    notes = [meta.get(b'note') for meta in markersmeta]
+    return sorted(note for note in notes if note)
+
 EFFECTMAPPING = util.sortdict([
     (obsutil.DESCCHANGED, b'description'),
     (obsutil.METACHANGED, b'meta'),
--- a/tests/test-evolve-obshistory-split.t	Tue Feb 18 18:07:11 2020 +0800
+++ b/tests/test-evolve-obshistory-split.t	Tue Feb 18 18:10:58 2020 +0800
@@ -123,7 +123,9 @@
                       "parent",
                       "content"
                   ],
-                  "note": "testing split",
+                  "notes": [
+                      "testing split"
+                  ],
                   "operations": [
                       "split"
                   ],