D937: remotenames: move function to pull remotenames from the remoterepo to core

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Oct 4 21:52:55 UTC 2017


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch moves the functionality to pull branches and bookmarks from a
  server from which we are pulling to core. The function used to exist in
  remotenames repo.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D937

AFFECTED FILES
  mercurial/remotenames.py

CHANGE DETAILS

diff --git a/mercurial/remotenames.py b/mercurial/remotenames.py
new file mode 100644
--- /dev/null
+++ b/mercurial/remotenames.py
@@ -0,0 +1,28 @@
+# remotenames.py
+#
+# Copyright 2017 Facebook, Inc.
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+def pullremotenames(localrepo, remoterepo, remotepath):
+    """ pulls bookmarks and branches information of the remote repo during a
+    pull or clone operation.
+    localrepo is our local repository
+    remoterepo is the repo from which we are pulling or cloning
+    remotepath is the path of the remote repository
+    """
+    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
+    # remove them here otherwise we would require the user
+    # to issue a pull to refresh the storage
+    bmap = {}
+    repo = localrepo.unfiltered()
+    for branch, nodes in remoterepo.branchmap().iteritems():
+        bmap[branch] = []
+        for node in nodes:
+            if node in repo and not repo[node].obsolete():
+                bmap[branch].append(node)



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list