[PATCH 1 of 2] bundlerevlog: extract 'baserevision' method

Augie Fackler raf at durin42.com
Tue Aug 27 14:05:24 CDT 2013


On Mon, Aug 26, 2013 at 05:47:33PM -0700, Wojciech Lopata wrote:
> # HG changeset patch
> # User Wojciech Lopata <lopek at fb.com>
> # Date 1377561031 25200
> #      Mon Aug 26 16:50:31 2013 -0700
> # Node ID 05999156c4f06d3ec4da91303d5d6952523b038d
> # Parent  1c7cf12674ecf5a8561a94cf93828ace0cd63027
> bundlerevlog: extract 'baserevision' method

Closing this thread: I'm not good at reading, and lopek has convinced
me (in IRC) that this is the right change. I'd kind of like some other
crew member to eyeball it since I'm evidently unable to read code
today, however.

>
> This makes possible to use bundlerevlog class with subclasses of revlog
> that override revlog's 'revision' method. In particular this change is necessary
> to implement manifest compression, as it allows extension to replace manifest
> class and override 'revision' method there.
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -120,7 +120,7 @@
>              chain.append(iterrev)
>              iterrev = self.index[iterrev][3]
>          if text is None:
> -            text = revlog.revlog.revision(self, iterrev)
> +            text = self.baserevision(iterrev)
>
>          while chain:
>              delta = self._chunk(chain.pop())
> @@ -130,6 +130,12 @@
>          self._cache = (node, rev, text)
>          return text
>
> +    def baserevision(self, nodeorrev):
> +        # Revlog subclasses may override 'revision' method to modify format of
> +        # content retrieved from revlog. To use bundlerevlog with such class one
> +        # needs to override 'baserevision' and make more specific call here.
> +        return revlog.revlog.revision(self, nodeorrev)
> +
>      def addrevision(self, text, transaction, link, p1=None, p2=None, d=None):
>          raise NotImplementedError
>      def addgroup(self, revs, linkmapper, transaction):
> @@ -146,12 +152,21 @@
>          bundlerevlog.__init__(self, opener, self.indexfile, bundle,
>                                linkmapper)
>
> +    def baserevision(self, nodeorrev):
> +        # Although changelog doesn't override 'revision' method, some extensions
> +        # may replace this class with another that does. Same story with
> +        # manifest and filelog classes.
> +        return changelog.changelog.revision(self, nodeorrev)
> +
>  class bundlemanifest(bundlerevlog, manifest.manifest):
>      def __init__(self, opener, bundle, linkmapper):
>          manifest.manifest.__init__(self, opener)
>          bundlerevlog.__init__(self, opener, self.indexfile, bundle,
>                                linkmapper)
>
> +    def baserevision(self, nodeorrev):
> +        return manifest.manifest.revision(self, nodeorrev)
> +
>  class bundlefilelog(bundlerevlog, filelog.filelog):
>      def __init__(self, opener, path, bundle, linkmapper, repo):
>          filelog.filelog.__init__(self, opener, path)
> @@ -159,6 +174,9 @@
>                                linkmapper)
>          self._repo = repo
>
> +    def baserevision(self, nodeorrev):
> +        return filelog.filelog.revision(self, nodeorrev)
> +
>      def _file(self, f):
>          self._repo.file(f)
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list