[PATCH 2 of 3] share: use the 'sharedpath' attr on repo instead of reloading from the file
Angel Ezquerra
angel.ezquerra at gmail.com
Sat Dec 20 17:14:42 CST 2014
On Fri, Dec 19, 2014 at 6:19 AM, Matt Harbison <mharbison72 at gmail.com> wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1418963057 18000
> # Thu Dec 18 23:24:17 2014 -0500
> # Node ID a2dd116c635236b8d37f5ac20a07b185233cca07
> # Parent 2e2ea8cb73c5a1861c8b249eaf74336513bba263
> share: use the 'sharedpath' attr on repo instead of reloading from the file
>
> Seems like a useful optimization, and now the exact file content is not a
> concern.
>
> diff --git a/hgext/share.py b/hgext/share.py
> --- a/hgext/share.py
> +++ b/hgext/share.py
> @@ -90,18 +90,13 @@
> Returns the source repository object for a given shared repository.
> If repo is not a shared repository, return None.
> """
> - srcrepo = None
> - try:
> - # strip because some tools write with newline after
> - sharedpath = repo.vfs.read('sharedpath').strip()
> - # the sharedpath always ends in the .hg; we want the path to the repo
> - source = repo.vfs.split(sharedpath)[0]
> - srcurl, branches = parseurl(source)
> - srcrepo = repository(repo.ui, srcurl)
> - except IOError, inst:
> - if inst.errno != errno.ENOENT:
> - raise
> - return srcrepo
> + if repo.sharedpath == repo.path:
> + return None
A bit unrelated to the body of this patch, but I think that we should
encapsulate this check to tell if a repository is shared into a
localrepo method (e.g. localrepo.shared()). IMHO this sort of check
feels too much like using an implementation detail. I will send a
patch for this soon.
Other than that the patch seems to make sense.
Cheers,
Angel
More information about the Mercurial-devel
mailing list