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.
--- 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
=============================