Patchwork [2,of,3,evolve-ext] obshistory: make obslog work when a commit doesn't have any description

login
register
mail settings
Submitter Anton Shestakov
Date April 27, 2018, 10:26 a.m.
Message ID <73e62fe390ee02620c30.1524824803@neuro>
Download mbox | patch
Permalink /patch/31239/
State Accepted
Headers show

Comments

Anton Shestakov - April 27, 2018, 10:26 a.m.
# HG changeset patch
# User Anton Shestakov <av6@dwimlabs.net>
# Date 1524817185 -28800
#      Fri Apr 27 16:19:45 2018 +0800
# Node ID 73e62fe390ee02620c30878b333a20fa18d644b1
# Parent  65ddff799cfd4d8c47b246350f8df8581c0c3c78
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.

Patch

diff --git a/hgext3rd/evolve/obshistory.py b/hgext3rd/evolve/obshistory.py
--- a/hgext3rd/evolve/obshistory.py
+++ b/hgext3rd/evolve/obshistory.py
@@ -391,7 +391,9 @@  def _debugobshistorydisplaynode(fm, repo
         _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),
diff --git a/tests/test-evolve-obshistory.t b/tests/test-evolve-obshistory.t
--- a/tests/test-evolve-obshistory.t
+++ b/tests/test-evolve-obshistory.t
@@ -16,6 +16,20 @@  Global setup
   > 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
 =============================