Patchwork [evolve-ext] split: avoid trying to split an empty commit (issue5191)

login
register
mail settings
Submitter Philippe Pepiot
Date Oct. 8, 2016, 1:50 p.m.
Message ID <1ef723b6fdfb8f940e0e.1475934645@shen.in.philpep.org>
Download mbox | patch
Permalink /patch/16921/
State Accepted
Headers show

Comments

Philippe Pepiot - Oct. 8, 2016, 1:50 p.m.
# HG changeset patch
# User Philippe Pepiot <philippe.pepiot@logilab.fr>
# Date 1475934552 -7200
#      Sat Oct 08 15:49:12 2016 +0200
# Node ID 1ef723b6fdfb8f940e0e1a82f2936917e7d4e23f
# Parent  5383671ef612a1764bbbed13a7ef2d339d0a9c2d
split: avoid trying to split an empty commit (issue5191)
Pierre-Yves David - Oct. 8, 2016, 2:23 p.m.
On 10/08/2016 03:50 PM, Philippe Pepiot wrote:
> # HG changeset patch
> # User Philippe Pepiot <philippe.pepiot@logilab.fr>
> # Date 1475934552 -7200
> #      Sat Oct 08 15:49:12 2016 +0200
> # Node ID 1ef723b6fdfb8f940e0e1a82f2936917e7d4e23f
> # Parent  5383671ef612a1764bbbed13a7ef2d339d0a9c2d
> split: avoid trying to split an empty commit (issue5191)

Pushed, thanks a lot.

Patch

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -2932,11 +2932,12 @@  def cmdsplit(ui, repo, *revs, **opts):
             else:
                 ui.status(_("no more change to split\n"))
 
-        tip = repo[newcommits[-1]]
-        bmupdate(tip.node())
-        if bookactive is not None:
-            bmactivate(repo, bookactive)
-        obsolete.createmarkers(repo, [(repo[r], newcommits)])
+        if newcommits:
+            tip = repo[newcommits[-1]]
+            bmupdate(tip.node())
+            if bookactive is not None:
+                bmactivate(repo, bookactive)
+            obsolete.createmarkers(repo, [(repo[r], newcommits)])
         tr.close()
     finally:
         lockmod.release(tr, lock, wlock)
diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -378,3 +378,10 @@  Running split with both unnamed and name
   (use either `hg split <rs>` or `hg split --rev <rs>`, not both)
   [255]
 
+Split empty commit (issue5191)
+  $ hg branch new-branch
+  marked working directory as branch new-branch
+  (branches are permanent and global, did you want a bookmark?)
+  $ hg commit -m "empty"
+  $ hg split
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved