Patchwork [1,of,6,ctx-minor-fixes] filectx: fix return of renamed

mail settings
Submitter Sean Farley
Date Sept. 19, 2018, 5:35 a.m.
Message ID <>
Download mbox | patch
Permalink /patch/34821/
State Accepted
Headers show


Sean Farley - Sept. 19, 2018, 5:35 a.m.
# HG changeset patch
# User Sean Farley <>
# Date 1531872982 25200
#      Tue Jul 17 17:16:22 2018 -0700
# Branch ctx-minor-fixes
# Node ID 03041a020368729345f9b72e6914122c5e88a302
# Parent  3d22aef3ecd5fe02c9411503b04dfbdcb6240cc1
filectx: fix return of renamed

How is this not blowing up everywhere?

It seems that filelog.renamed has always returned False (incorrectly a
boolean) instead of the assumed None. Tracing through history, you need
to skip over my move of code in 2013 by annotating from 896193a9cab4^
and you can see the original code is from 2007 (180a3eee4b75) and that
ab9fa7a85dd9 broke this by assuming renamed was a bool (instead of

Refactoring memctx code later exposed this bug.


diff --git a/hgext/largefiles/ b/hgext/largefiles/
index d934972..d29ef5b 100644
--- a/hgext/largefiles/
+++ b/hgext/largefiles/
@@ -207,10 +207,14 @@  def _lfconvert_addchangeset(rsrc, rdst, 
             # If this file was renamed or copied then copy
             # the largefile-ness of its predecessor
             if f in ctx.manifest():
                 fctx = ctx.filectx(f)
                 renamed = fctx.renamed()
+                if renamed is None:
+                    # the code below assumes renamed to be a boolean or a list
+                    # and won't quite work with the value None
+                    renamed = False
                 renamedlfile = renamed and renamed[0] in lfiles
                 islfile |= renamedlfile
                 if 'l' in fctx.flags():
                     if renamedlfile:
                         raise error.Abort(
diff --git a/mercurial/ b/mercurial/
index fc7dd6a..40267e7 100644
--- a/mercurial/
+++ b/mercurial/
@@ -1050,11 +1050,11 @@  class filectx(basefilectx):
         or both changeset parents contain different file revisions.
         renamed = self._filelog.renamed(self._filenode)
         if not renamed:
-            return renamed
+            return None
         if self.rev() == self.linkrev():
             return renamed
         name = self.path()