[PATCH 1 of 7] obsolete: introduction of obsolete markers

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed May 16 02:26:34 CDT 2012


On 14 mai 2012, at 18:10, Pierre-Yves David wrote:

> # HG changeset patch
> # User Pierre-Yves.David at ens-lyon.org
> # Date 1337007906 -7200
> # Node ID 76b72def92ce1da2f62189287d9e45e17af714ee
> # Parent  ddd4996740c785cc187766249977ea3ece8c17ab
> obsolete: introduction of obsolete markers
> 
> This changeset add a obsstore attribute on localrepository. We are able to Save
> to disk and load from it. Format is described in the module docstring.
> 
> There is still a lot a work to do. In particular using standard transaction to
> manage the write and aborting.
> 
> diff -r ddd4996740c7 -r 76b72def92ce mercurial/localrepo.py
> --- a/mercurial/localrepo.py	Tue May 08 12:05:45 2012 -0500
> +++ b/mercurial/localrepo.py	Mon May 14 17:05:06 2012 +0200
> @@ -7,7 +7,7 @@
> 
> from node import bin, hex, nullid, nullrev, short
> from i18n import _
> -import repo, changegroup, subrepo, discovery, pushkey
> +import repo, changegroup, subrepo, discovery, pushkey, obsolete
> import changelog, dirstate, filelog, manifest, context, bookmarks, phases
> import lock, transaction, store, encoding
> import scmutil, util, extensions, hook, error, revset
> @@ -200,6 +200,10 @@
>                    cache[rev] = phase
>        return cache
> 
> +    @storecache('obsmarkers')
> +    def obsstore(self):
> +        return obsolete.readmarkers(self)
> +
>    @storecache('00changelog.i')
>    def changelog(self):
>        c = changelog.changelog(self.sopener)
> @@ -935,6 +939,8 @@
>            if self._dirtyphases:
>                phases.writeroots(self)
>                self._dirtyphases = False
> +            if 'obsstore' in vars(self) and self.obsstore._new:
> +                obsolete.flushmarkers(self)
>            for k, ce in self._filecache.items():
>                if k == 'dirstate':
>                    continue
> diff -r ddd4996740c7 -r 76b72def92ce mercurial/obsolete.py
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/mercurial/obsolete.py	Mon May 14 17:05:06 2012 +0200
> 
> +def readmarkers(repo):
> +    """Read obsolete markers from disk"""
> +    store = obsstore()
> +    try:
> +        f = repo.sopener('obsmarkers', 'rb')
> +        try:
> +            data = f.read()
> +        finally:
> +            f.close()
> +        store.loadmarkers(data)
> +    except IOError:
> +        pass
> +    return store
> +
> +
> +
> +def flushmarkers(repo):
> +    """Write obsolete markers to disk
> +
> +    Transaction logic should be used here. But for now rewritting the whole
> +    file is good enough."""
> +    f = repo.sopener('obsmarkers', 'wb', atomictemp=True)
> +    store = repo.obsstore
> +    try:
> +        store.flushmarkers(f)
> +    finally:
> +        f.close()

I've inlined readmarkers and flushmarkers in local repo call site. newer version take pmezard review in account.

Newer version available here as usual. http://hg-lab.logilab.org/wip/hg/bookmarks

I'll resend the whole series after Matt review

-- 
Pierre-Yves


More information about the Mercurial-devel mailing list