##// END OF EJS Templates
pull: move bookmark pulling into its own function...
Pierre-Yves David -
r22654:02e0a574 default
parent child Browse files
Show More
@@ -777,13 +777,15 b' class pulloperation(object):'
777 afterward.
777 afterward.
778 """
778 """
779
779
780 def __init__(self, repo, remote, heads=None, force=False):
780 def __init__(self, repo, remote, heads=None, force=False, bookmarks=()):
781 # repo we pull into
781 # repo we pull into
782 self.repo = repo
782 self.repo = repo
783 # repo we pull from
783 # repo we pull from
784 self.remote = remote
784 self.remote = remote
785 # revision we try to pull (None is "all")
785 # revision we try to pull (None is "all")
786 self.heads = heads
786 self.heads = heads
787 # bookmark pulled explicitly
788 self.explicitbookmarks = bookmarks
787 # do we force pull?
789 # do we force pull?
788 self.force = force
790 self.force = force
789 # the name the pull transaction
791 # the name the pull transaction
@@ -796,10 +798,13 b' class pulloperation(object):'
796 self.rheads = None
798 self.rheads = None
797 # list of missing changeset to fetch remotely
799 # list of missing changeset to fetch remotely
798 self.fetch = None
800 self.fetch = None
801 # remote bookmarks data
802 self.remotebookmarks = None
799 # result of changegroup pulling (used as return code by pull)
803 # result of changegroup pulling (used as return code by pull)
800 self.cgresult = None
804 self.cgresult = None
801 # list of step remaining todo (related to future bundle2 usage)
805 # list of step remaining todo (related to future bundle2 usage)
802 self.todosteps = set(['changegroup', 'phases', 'obsmarkers'])
806 self.todosteps = set(['changegroup', 'phases', 'obsmarkers',
807 'bookmarks'])
803
808
804 @util.propertycache
809 @util.propertycache
805 def pulledsubset(self):
810 def pulledsubset(self):
@@ -836,7 +841,7 b' class pulloperation(object):'
836 self._tr.release()
841 self._tr.release()
837
842
838 def pull(repo, remote, heads=None, force=False, bookmarks=()):
843 def pull(repo, remote, heads=None, force=False, bookmarks=()):
839 pullop = pulloperation(repo, remote, heads, force)
844 pullop = pulloperation(repo, remote, heads, force, bookmarks=bookmarks)
840 if pullop.remote.local():
845 if pullop.remote.local():
841 missing = set(pullop.remote.requirements) - pullop.repo.supported
846 missing = set(pullop.remote.requirements) - pullop.repo.supported
842 if missing:
847 if missing:
@@ -845,7 +850,7 b' def pull(repo, remote, heads=None, force'
845 " %s") % (', '.join(sorted(missing)))
850 " %s") % (', '.join(sorted(missing)))
846 raise util.Abort(msg)
851 raise util.Abort(msg)
847
852
848 remotebookmarks = remote.listkeys('bookmarks')
853 pullop.remotebookmarks = remote.listkeys('bookmarks')
849 lock = pullop.repo.lock()
854 lock = pullop.repo.lock()
850 try:
855 try:
851 _pulldiscovery(pullop)
856 _pulldiscovery(pullop)
@@ -855,22 +860,11 b' def pull(repo, remote, heads=None, force'
855 _pullchangeset(pullop)
860 _pullchangeset(pullop)
856 _pullphase(pullop)
861 _pullphase(pullop)
857 _pullobsolete(pullop)
862 _pullobsolete(pullop)
863 _pullbookmarks(pullop)
858 pullop.closetransaction()
864 pullop.closetransaction()
859 finally:
865 finally:
860 pullop.releasetransaction()
866 pullop.releasetransaction()
861 lock.release()
867 lock.release()
862 bookmod.updatefromremote(repo.ui, repo, remotebookmarks, remote.url())
863 # update specified bookmarks
864 if bookmarks:
865 marks = repo._bookmarks
866 writer = repo.ui.status
867 if repo.ui.configbool('ui', 'quietbookmarkmove', False):
868 writer = repo.ui.debug
869 for b in bookmarks:
870 # explicit pull overrides local bookmark if any
871 writer(_("importing bookmark %s\n") % b)
872 marks[b] = repo[remotebookmarks[b]].node()
873 marks.write()
874
868
875 return pullop.cgresult
869 return pullop.cgresult
876
870
@@ -1006,6 +1000,27 b' def _pullapplyphases(pullop, remotephase'
1006 tr = pullop.gettransaction()
1000 tr = pullop.gettransaction()
1007 phases.advanceboundary(pullop.repo, tr, draft, dheads)
1001 phases.advanceboundary(pullop.repo, tr, draft, dheads)
1008
1002
1003 def _pullbookmarks(pullop):
1004 """process the remote bookmark information to update the local one"""
1005 if 'bookmarks' not in pullop.todosteps:
1006 return
1007 pullop.todosteps.remove('bookmarks')
1008 repo = pullop.repo
1009 remotebookmarks = pullop.remotebookmarks
1010 bookmod.updatefromremote(repo.ui, repo, remotebookmarks,
1011 pullop.remote.url())
1012 # update specified bookmarks
1013 if pullop.explicitbookmarks:
1014 marks = repo._bookmarks
1015 writer = repo.ui.status
1016 if repo.ui.configbool('ui', 'quietbookmarkmove', False):
1017 writer = repo.ui.debug
1018 for b in pullop.explicitbookmarks:
1019 # explicit pull overrides local bookmark if any
1020 writer(_("importing bookmark %s\n") % b)
1021 marks[b] = repo[remotebookmarks[b]].node()
1022 marks.write()
1023
1009 def _pullobsolete(pullop):
1024 def _pullobsolete(pullop):
1010 """utility function to pull obsolete markers from a remote
1025 """utility function to pull obsolete markers from a remote
1011
1026
General Comments 0
You need to be logged in to leave comments. Login now