[PATCH 09 of 14] localrepo: add shallow awareness
Nicolas Dumazet
nicdumz at gmail.com
Fri Jul 16 03:05:47 CDT 2010
On Fri, 16 Jul 2010 12:45:17 +0530
Vishakh H <vsh426 at gmail.com> wrote:
> # HG changeset patch
> # User Vishakh H <vsh426 at gmail.com>
> # Date 1279263210 -19800
> # Node ID 6235071ccd5e7973389a890abb64a88c6d8ccb27
> # Parent 0218b69c65e2014af11f287cac005ffd206d45c5
> localrepo: add shallow awareness
>
> when a shallow repo is created we store the shallowroot in shallow file
> under .hg. when the repo is instantiated it reads the file find shallowroot.
"to find shallowroot" I guess?
> the shallow root is passed to the changelog so it can keep track of all
> nodes available in repo and create revlogs with shallow flag.
>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -23,7 +23,7 @@
> capabilities = set(('lookup', 'changegroupsubset', 'branchmap', 'pushkey'))
> supported = set('revlogv1 store fncache shared'.split())
>
> - def __init__(self, baseui, path=None, create=0):
> + def __init__(self, baseui, path=None, create=False, shallow=None):
So what kind of data will be passed in "shallow"?
Is it fundamentally different from what you call elsewhere "shallowroot"?
If not, you might want to use the name everywhere.
-Nicolas.
> repo.repository.__init__(self)
> self.root = os.path.realpath(util.expandpath(path))
> self.path = os.path.join(self.root, ".hg")
> @@ -32,6 +32,7 @@
> self.wopener = util.opener(self.root)
> self.baseui = baseui
> self.ui = baseui.copy()
> + self._shallowroot = shallow
>
> try:
> self.ui.readconfig(self.join("hgrc"), self.root)
> @@ -59,6 +60,10 @@
> for r in requirements:
> reqfile.write("%s\n" % r)
> reqfile.close()
> + if shallow is not None:
> + shallowfile = self.opener("shallow", "w")
> + shallowfile.write(shallow)
> + shallowfile.close()
> else:
> raise error.RepoError(_("repository %s not found") % path)
> elif create:
> @@ -68,6 +73,7 @@
> requirements = set()
> try:
> requirements = set(self.opener("requires").read().splitlines())
> + self._shallowroot = self.opener("shallow").read()
> except IOError, inst:
> if inst.errno != errno.ENOENT:
> raise
> @@ -109,7 +115,7 @@
>
> @propertycache
> def changelog(self):
> - c = changelog.changelog(self.sopener)
> + c = changelog.changelog(self.sopener, self._shallowroot)
> if 'HG_PENDING' in os.environ:
> p = os.environ['HG_PENDING']
> if p.startswith(self.root):
> @@ -1203,6 +1209,7 @@
> raise util.Abort(_("Partial pull cannot be done because "
> "other repository doesn't support "
> "changegroupsubset."))
> + shallowroot = shallowroot or self._shallowroot
> cg = remote.changegroupsubset(fetch, heads, 'pull',
> shallowroot=shallowroot)
> return self.addchangegroup(cg, 'pull', remote.url(), lock=lock)
> @@ -1869,8 +1876,8 @@
> util.rename(src, dest)
> return a
>
> -def instance(ui, path, create):
> - return localrepository(ui, util.drop_scheme('file', path), create)
> +def instance(ui, path, create, shallow):
> + return localrepository(ui, util.drop_scheme('file', path), create, shallow)
>
> def islocal(path):
> return True
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
--
Nicolas Dumazet — NicDumZ
More information about the Mercurial-devel
mailing list