[PATCH 1 of 6 ctx-minor-fixes] filectx: fix return of renamed
Sean Farley
sean at farley.io
Wed Sep 19 05:35:43 UTC 2018
# HG changeset patch
# User Sean Farley <sean at farley.io>
# 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
None).
Refactoring memctx code later exposed this bug.
diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
index d934972..d29ef5b 100644
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -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/context.py b/mercurial/context.py
index fc7dd6a..40267e7 100644
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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()
More information about the Mercurial-devel
mailing list