changeset 23626:012a7b482d68

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.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 18 Dec 2014 23:24:17 -0500
parents 3a8a85469ee8
children 7aaf987d9e88
files hgext/share.py
diffstat 1 files changed, 7 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/share.py	Thu Dec 18 23:16:37 2014 -0500
+++ b/hgext/share.py	Thu Dec 18 23:24:17 2014 -0500
@@ -91,18 +91,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
+
+    # the sharedpath always ends in the .hg; we want the path to the repo
+    source = repo.vfs.split(repo.sharedpath)[0]
+    srcurl, branches = parseurl(source)
+    return repository(repo.ui, srcurl)
 
 def getbkfile(orig, self, repo):
     if _hassharedbookmarks(repo):