obshistory: make obslog work when a commit doesn't have any description stable
authorAnton Shestakov <av6@dwimlabs.net>
Fri, 27 Apr 2018 16:19:45 +0800
branchstable
changeset 3729 1b1badb3d2fc
parent 3728 0fc78fdca4b8
child 3730 f5b9030e18e9
obshistory: make obslog work when a commit doesn't have any description This logic is taken from logcmdutil.changesetprinter class. It checks that commit description is not empty before extracting the first line (before this patch it would try to index an empty list). Stripping description also makes obslog behave more like regular log when there are trailing/leading whitespaces.
hgext3rd/evolve/obshistory.py
tests/test-evolve-obshistory.t
--- a/hgext3rd/evolve/obshistory.py	Fri Apr 27 16:14:10 2018 +0800
+++ b/hgext3rd/evolve/obshistory.py	Fri Apr 27 16:19:45 2018 +0800
@@ -391,7 +391,9 @@
         _debugobshistorydisplaymissingctx(fm, node)
 
 def _debugobshistorydisplayctx(fm, ctx):
-    shortdescription = ctx.description().splitlines()[0]
+    shortdescription = ctx.description().strip()
+    if shortdescription:
+        shortdescription = shortdescription.splitlines()[0]
 
     fm.startitem()
     fm.write('node', '%s', str(ctx),
--- a/tests/test-evolve-obshistory.t	Fri Apr 27 16:14:10 2018 +0800
+++ b/tests/test-evolve-obshistory.t	Fri Apr 27 16:19:45 2018 +0800
@@ -16,6 +16,20 @@
   > evolution.effect-flags = yes
   > EOF
 
+Test simple common cases
+========================
+
+Test setup
+----------
+  $ hg init $TESTTMP/simple
+  $ cd $TESTTMP/simple
+
+Actual test
+-----------
+  $ hg obslog -ap null
+  @  000000000000 (-1)
+  
+
 Test output on amended commit
 =============================