[PATCH 2 of 2] rbc: empty (and invalid) rbc-names file should give an empty name list

Mads Kiilerich mads at kiilerich.com
Sun Mar 12 15:33:56 EDT 2017


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1489346250 25200
#      Sun Mar 12 12:17:30 2017 -0700
# Node ID 1b5144a87e936fc8071463956816a89041478126
# Parent  023b6f7456b3622cc81332ae9d6e30b7ecc37415
rbc: empty (and invalid) rbc-names file should give an empty name list

An empty file (if it somehow should exist) used to give a list with an empty
name. That didn't do any harm, but it was "wrong". Fix that.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -362,7 +362,9 @@ class revbranchcache(object):
         try:
             bndata = repo.vfs.read(_rbcnames)
             self._rbcsnameslen = len(bndata) # for verification before writing
-            self._names = [encoding.tolocal(bn) for bn in bndata.split('\0')]
+            if bndata:
+                self._names = [encoding.tolocal(bn)
+                               for bn in bndata.split('\0')]
         except (IOError, OSError):
             if readonly:
                 # don't try to use cache - fall back to the slow path


More information about the Mercurial-devel mailing list