mercurial/logexchange.py
changeset 36059 62a428bf6359
parent 35347 a29fe459fc49
child 37365 1ccd75027abb
--- a/mercurial/logexchange.py	Mon Feb 12 10:36:59 2018 -0500
+++ b/mercurial/logexchange.py	Sat Dec 23 20:27:41 2017 +0530
@@ -11,6 +11,7 @@
 from .node import hex
 
 from . import (
+    util,
     vfs as vfsmod,
 )
 
@@ -94,6 +95,30 @@
     finally:
         wlock.release()
 
+def activepath(repo, remote):
+    """returns remote path"""
+    local = None
+    # is the remote a local peer
+    local = remote.local()
+
+    # determine the remote path from the repo, if possible; else just
+    # use the string given to us
+    rpath = remote
+    if local:
+        rpath = remote._repo.root
+    elif not isinstance(remote, str):
+        rpath = remote._url
+
+    # represent the remotepath with user defined path name if exists
+    for path, url in repo.ui.configitems('paths'):
+        # remove auth info from user defined url
+        url = util.removeauth(url)
+        if url == rpath:
+            rpath = path
+            break
+
+    return rpath
+
 def pullremotenames(localrepo, remoterepo):
     """
     pulls bookmarks and branches information of the remote repo during a
@@ -101,7 +126,7 @@
     localrepo is our local repository
     remoterepo is the peer instance
     """
-    remotepath = remoterepo.url()
+    remotepath = activepath(localrepo, remoterepo)
     bookmarks = remoterepo.listkeys('bookmarks')
     # on a push, we don't want to keep obsolete heads since
     # they won't show up as heads on the next pull, so we