comparison mercurial/bookmarks.py @ 36433:fc39e2bfcd70

bookmarks: calculate visibility exceptions only once In the loop "for mark in names", the rev is same in each iteration, so it does not makes sense to call unhidehashlikerevs multiple times. Thanks to Yuya for spotting this.
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 15 Jan 2018 00:16:11 +0530
parents 7336ac5e786e
children 5a2d505a9174
comparison
equal deleted inserted replaced
36432:a177c6aa055a 36433:fc39e2bfcd70
828 """ 828 """
829 marks = repo._bookmarks 829 marks = repo._bookmarks
830 cur = repo.changectx('.').node() 830 cur = repo.changectx('.').node()
831 newact = None 831 newact = None
832 changes = [] 832 changes = []
833 hiddenrevs = set() 833 hiddenrev = None
834
835 # unhide revs if any
836 if rev:
837 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
838
834 for mark in names: 839 for mark in names:
835 mark = checkformat(repo, mark) 840 mark = checkformat(repo, mark)
836 if newact is None: 841 if newact is None:
837 newact = mark 842 newact = mark
838 if inactive and mark == repo._activebookmark: 843 if inactive and mark == repo._activebookmark:
839 deactivate(repo) 844 deactivate(repo)
840 return 845 return
841 tgt = cur 846 tgt = cur
842 if rev: 847 if rev:
843 repo = scmutil.unhidehashlikerevs(repo, [rev], 'nowarn')
844 ctx = scmutil.revsingle(repo, rev) 848 ctx = scmutil.revsingle(repo, rev)
845 if ctx.hidden(): 849 if ctx.hidden():
846 hiddenrevs.add(ctx.hex()[:12]) 850 hiddenrev = ctx.hex()[:12]
847 tgt = ctx.node() 851 tgt = ctx.node()
848 for bm in marks.checkconflict(mark, force, tgt): 852 for bm in marks.checkconflict(mark, force, tgt):
849 changes.append((bm, None)) 853 changes.append((bm, None))
850 changes.append((mark, tgt)) 854 changes.append((mark, tgt))
851 if hiddenrevs: 855
852 repo.ui.warn(_("bookmarking hidden changeset %s\n") % 856 if hiddenrev:
853 ', '.join(hiddenrevs)) 857 repo.ui.warn(_("bookmarking hidden changeset %s\n") % hiddenrev)
854 marks.applychanges(repo, tr, changes) 858 marks.applychanges(repo, tr, changes)
855 if not inactive and cur == marks[newact] and not rev: 859 if not inactive and cur == marks[newact] and not rev:
856 activate(repo, newact) 860 activate(repo, newact)
857 elif cur != tgt and newact == repo._activebookmark: 861 elif cur != tgt and newact == repo._activebookmark:
858 deactivate(repo) 862 deactivate(repo)