Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bookmarks.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 | e95ec38f86b0 |
children | a7b3fdaf768d |
line wrap: on
line diff
--- a/mercurial/bookmarks.py Sun Aug 26 00:27:44 2012 +0200 +++ b/mercurial/bookmarks.py Sun Aug 26 00:28:56 2012 +0200 @@ -209,7 +209,7 @@ cl = repo[nl] if cl.rev() >= cr.rev(): continue - if cr in cl.descendants(): + if validdest(repo, cl, cr): repo._bookmarks[k] = cr.node() changed = True ui.status(_("updating bookmark %s\n") % k) @@ -252,3 +252,7 @@ ui.status(_("no changed bookmarks found\n")) return 1 return 0 + +def validdest(repo, old, new): + """Is the new bookmark destination a valid update from the old one""" + return new in old.descendants()