filelog: switch 'not len(filerevlog)' to 'not filerevlog'
authorDurham Goode <durham@fb.com>
Thu, 30 May 2013 18:47:16 -0700
changeset 19293 446ab88d3f1c
parent 19292 e0aa6fff8f02
child 19294 3c3f6b83f8cb
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__.
mercurial/changegroup.py
mercurial/cmdutil.py
--- a/mercurial/changegroup.py	Thu May 30 19:29:03 2013 -0700
+++ b/mercurial/changegroup.py	Thu May 30 18:47:16 2013 -0700
@@ -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:
--- a/mercurial/cmdutil.py	Thu May 30 19:29:03 2013 -0700
+++ b/mercurial/cmdutil.py	Thu May 30 18:47:16 2013 -0700
@@ -1338,7 +1338,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: