[PATCH 1 of 4 V2] filelog: switch 'not len(filerevlog)' to 'not filerevlog'
Durham Goode
durham at fb.com
Tue Jun 4 19:59:27 UTC 2013
# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1369964836 25200
# Thu May 30 18:47:16 2013 -0700
# Node ID c74c942b6f1a8cfb4a47a9767e0ea41b93a0656d
# Parent 843cf14e70bfde062911b9b5f91117a598690805
filelog: switch 'not len(filerevlog)' to 'not filerevlog'
A few places in the code use 'if not len(revlog)' to check if the revlog
exists. Replacing this with 'not filerevlog' allows alternative revlog
implementations to override __nonzero__ to handle this case without
implementing __len__.
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -359,7 +359,7 @@
msgfiles = _('files')
for i, fname in enumerate(sorted(changedfiles)):
filerevlog = repo.file(fname)
- if not len(filerevlog):
+ if not filerevlog:
raise util.Abort(_("empty or missing revlog for %s") % fname)
if fastpathlinkrev:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1320,7 +1320,7 @@
raise util.Abort(_('cannot follow file not in parent '
'revision: "%s"') % f)
filelog = repo.file(f)
- if not len(filelog):
+ if not filelog:
# A zero count may be a directory or deleted file, so
# try to find matching entries on the slow path.
if follow:
More information about the Mercurial-devel
mailing list