Commits

Alexander Solovyov committed b18924b

support for paths shortened through schemes extension

Comments (0)

Files changed (1)

-from mercurial import localrepo, bookmarks, error
+from mercurial import localrepo, bookmarks, error, extensions
+
+from hgext import schemes
 
 def reposetup(ui, repo):
     if not isinstance(repo, localrepo.localrepository):
     class remotebookmarksrepo(repo.__class__):
         def pull(self, remote, heads=None, force=False):
             out = super(remotebookmarksrepo, self).pull(remote, heads, force)
+            url = (getattr(remote, '_original_url', None) or
+                   getattr(remote, '_url', None))
+            if not url:
+                return out
 
             name = None
             for k, v in self.ui.configitems('paths'):
-                if hasattr(remote, '_url') and v == remote._url:
+                if v == url:
                     name = k
                     break
 
                     continue
 
                 key = 'remote/%s/%s' % (name, k)
-                self._bookmarks[key] = rev
-                changed = True
+                if self._bookmarks.get(key) != rev:
+                    self._bookmarks[key] = rev
+                    ui.write('pulled remote bookmark %s/%s\n' % (name, k))
+                    changed = True
 
             if changed:
                 bookmarks.write(self)
             return out
 
     repo.__class__ = remotebookmarksrepo
+
+
+def schemewrapper(orig, self, ui, url, create):
+    instance = orig(self, ui, url, create)
+    instance._original_url = url
+    return instance
+
+def extsetup(ui):
+    extensions.wrapfunction(schemes.ShortRepository, 'instance', schemewrapper)