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)