[PATCH 2 of 2] branchmap: Log event when branchcache is updated

Siddharth Agarwal sid0 at fb.com
Sun Mar 23 20:11:12 CDT 2014


On 03/22/2014 05:21 PM, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gps at mozilla.com>
> # Date 1395533677 25200
> #      Sat Mar 22 17:14:37 2014 -0700
> # Node ID f7a3e8fe9777541850d5efa41162eb2498576bf5
> # Parent  4041f83efd1de680c82b65c776f85b642a59754a
> branchmap: Log event when branchcache is updated

(same applies to this patch)

>
> The blackblox log will now contain log events when the branch caches are
> updated.
>
> Since the various branch caches update with a recursive call to
> updatecache(), the reported timings may not be completely accurate.
>
> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
> --- a/mercurial/branchmap.py
> +++ b/mercurial/branchmap.py
> @@ -3,16 +3,17 @@
>   # Copyright 2005-2007 Matt Mackall <mpm at selenic.com>
>   #
>   # This software may be used and distributed according to the terms of the
>   # GNU General Public License version 2 or any later version.
>   
>   from node import bin, hex, nullid, nullrev
>   import encoding
>   import util
> +import time
>   
>   def _filename(repo):
>       """name of a branchcache file for a given repo or repoview"""
>       filename = "cache/branch2"
>       if repo.filtername:
>           filename = '%s-%s' % (filename, repo.filtername)
>       return filename
>   
> @@ -70,16 +71,17 @@ def read(repo):
>   # This create and ordering used for branchmap purpose.
>   # the ordering may be partial
>   subsettable = {None: 'visible',
>                  'visible': 'served',
>                  'served': 'immutable',
>                  'immutable': 'base'}
>   
>   def updatecache(repo):
> +    starttime = time.time()
>       cl = repo.changelog
>       filtername = repo.filtername
>       partial = repo._branchcaches.get(filtername)
>   
>       revs = []
>       if partial is None or not partial.validfor(repo):
>           partial = read(repo)
>           if partial is None:
> @@ -92,16 +94,18 @@ def updatecache(repo):
>                   extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
>                   revs.extend(r for  r in extrarevs if r <= partial.tiprev)
>       revs.extend(cl.revs(start=partial.tiprev + 1))
>       if revs:
>           partial.update(repo, revs)
>           partial.write(repo)
>       assert partial.validfor(repo), filtername
>       repo._branchcaches[repo.filtername] = partial
> +    duration = time.time() - starttime
> +    repo.ui.log('cache', 'Updated %s branch cache in %0.2f seconds\n')

You forgot to pass in the objects to be formatted here.

>   
>   class branchcache(dict):
>       """A dict like object that hold branches heads cache.
>   
>       This cache is used to avoid costly computations to determine all the
>       branch heads of a repo.
>   
>       The cache is serialized on disk in the following format:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list