Patchwork [stable] eol: fix crash when handling removed files

login
register
mail settings
Submitter Mads Kiilerich
Date Oct. 22, 2014, 2:10 p.m.
Message ID <67e1820879c6287c8dac.1413987032@ssl.google-analytics.com>
Download mbox | patch
Permalink /patch/6441/
State Accepted
Headers show

Comments

Mads Kiilerich - Oct. 22, 2014, 2:10 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1413987023 -7200
#      Wed Oct 22 16:10:23 2014 +0200
# Branch stable
# Node ID 67e1820879c6287c8daccdd4a69ea93fed8433f3
# Parent  c1ae0b2c1719f56b906472efea8b20ca0774c968
eol: fix crash when handling removed files

ci --amend would in some cases fail after 650b5b6e75ed failed to refactor the
eol extension too.
David Soria Parra - Oct. 22, 2014, 6:34 p.m.
Mads Kiilerich <mads@kiilerich.com> writes:

> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1413987023 -7200
> #      Wed Oct 22 16:10:23 2014 +0200
> # Branch stable
> # Node ID 67e1820879c6287c8daccdd4a69ea93fed8433f3
> # Parent  c1ae0b2c1719f56b906472efea8b20ca0774c968
> eol: fix crash when handling removed files
>
> ci --amend would in some cases fail after 650b5b6e75ed failed to refactor the
> eol extension too.

Queued for clowncopter. Thank you.

Patch

diff --git a/hgext/eol.py b/hgext/eol.py
--- a/hgext/eol.py
+++ b/hgext/eol.py
@@ -333,10 +333,10 @@  def reposetup(ui, repo):
             for f in sorted(ctx.added() + ctx.modified()):
                 if not self._eolfile(f):
                     continue
-                try:
-                    data = ctx[f].data()
-                except IOError:
+                fctx = ctx[f]
+                if fctx is None:
                     continue
+                data = fctx.data()
                 if util.binary(data):
                     # We should not abort here, since the user should
                     # be able to say "** = native" to automatically
diff --git a/tests/test-eol.t b/tests/test-eol.t
--- a/tests/test-eol.t
+++ b/tests/test-eol.t
@@ -525,4 +525,19 @@  append a line without trailing newline
   fourth
   fifth
 
+amend of changesets with renamed/deleted files expose new code paths
+
+  $ hg mv a.txt b.txt
+  $ hg ci --amend -q
+  $ hg diff -c.
+  diff --git a/a.txt b/b.txt
+  rename from a.txt
+  rename to b.txt
+  --- a/a.txt
+  +++ b/b.txt
+  @@ -1,2 +1,3 @@
+   third
+   fourth
+  +fifth
+
   $ cd ..