comparison mercurial/discovery.py @ 17550:fc530080013b

bookmarks: extract valid destination logic in a dedicated function We usually update bookmarks only if the new location is descendant of the old bookmarks location. We extract this logic into a function. This is the first step to allow more complex logic using obsolescence in this validation of the bookmark movement.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Sun, 26 Aug 2012 00:28:56 +0200
parents be0fcbb1c92f
children 46e1a4e24225
comparison
equal deleted inserted replaced
17549:be0fcbb1c92f 17550:fc530080013b
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from node import nullid, short 8 from node import nullid, short
9 from i18n import _ 9 from i18n import _
10 import util, setdiscovery, treediscovery, phases, obsolete 10 import util, setdiscovery, treediscovery, phases, obsolete, bookmarks
11 11
12 def findcommonincoming(repo, remote, heads=None, force=False): 12 def findcommonincoming(repo, remote, heads=None, force=False):
13 """Return a tuple (common, anyincoming, heads) used to identify the common 13 """Return a tuple (common, anyincoming, heads) used to identify the common
14 subset of nodes between repo and remote. 14 subset of nodes between repo and remote.
15 15
253 bookmarkedheads = set() 253 bookmarkedheads = set()
254 for bm in localbookmarks: 254 for bm in localbookmarks:
255 rnode = remotebookmarks.get(bm) 255 rnode = remotebookmarks.get(bm)
256 if rnode and rnode in repo: 256 if rnode and rnode in repo:
257 lctx, rctx = repo[bm], repo[rnode] 257 lctx, rctx = repo[bm], repo[rnode]
258 if rctx == lctx.ancestor(rctx): 258 if bookmarks.validdest(repo, rctx, lctx):
259 bookmarkedheads.add(lctx.node()) 259 bookmarkedheads.add(lctx.node())
260 260
261 # 3. Check for new heads. 261 # 3. Check for new heads.
262 # If there are more heads after the push than before, a suitable 262 # If there are more heads after the push than before, a suitable
263 # error message, depending on unsynced status, is displayed. 263 # error message, depending on unsynced status, is displayed.