Mercurial > hg
view mercurial/txnutil.py @ 51531:f85f23f1479b
branchcache: skip entries that are topological heads in the on disk file
In the majority of cases, topological heads are also branch heads. We have
efficient way to get the topological heads and efficient way to retrieve
their branch information. So there is little value in putting them in the branch
cache file explicitly. On the contrary, writing them explicitly tend to create
very large cache file that are inefficient to read and update.
So the branch cache v3 format is no longer including them. This changeset focus
on the format aspect and have no focus on the performance aspect. We will cover
that later.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 07 Mar 2024 10:55:22 +0100 |
parents | 2e726c934fcd |
children | f4733654f144 |
line wrap: on
line source
# txnutil.py - transaction related utilities # # Copyright FUJIWARA Katsunori <foozy@lares.dti.ne.jp> and others # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. from . import encoding def mayhavepending(root): """return whether 'root' may have pending changes, which are visible to this process. """ return root == encoding.environ.get(b'HG_PENDING') def trypending(root, vfs, filename, **kwargs): """Open file to be read according to HG_PENDING environment variable This opens '.pending' of specified 'filename' only when HG_PENDING is equal to 'root'. This returns '(fp, is_pending_opened)' tuple. """ if mayhavepending(root): try: return (vfs(b'%s.pending' % filename, **kwargs), True) except FileNotFoundError: pass return (vfs(filename, **kwargs), False)