# HG changeset patch # User Kevin Bullock # Date 1518064217 21600 # Node ID 8e03a8ba04afc1ebeb65e307c5345e3dec56ebd1 # Parent c693541ee210bcfcc4eb58328275d8b30d7f374a compat: find the right method to set active bookmark once diff -r c693541ee210 -r 8e03a8ba04af hggit/compat.py --- a/hggit/compat.py Wed Feb 07 22:18:35 2018 -0600 +++ b/hggit/compat.py Wed Feb 07 22:30:17 2018 -0600 @@ -1,4 +1,5 @@ from mercurial import ( + bookmarks, context, url, util as hgutil, @@ -68,6 +69,12 @@ # compat with hg < 3.9 return url.passwordmgr(ui) +# bookmarks.setcurrent was renamed to activate in hg 3.5 +if hgutil.safehasattr(bookmarks, 'activate'): + activatebookmark = bookmarks.activate +else: + activatebookmark = bookmarks.setcurrent + try: import dulwich.client diff -r c693541ee210 -r 8e03a8ba04af hggit/git_handler.py --- a/hggit/git_handler.py Wed Feb 07 22:18:35 2018 -0600 +++ b/hggit/git_handler.py Wed Feb 07 22:30:17 2018 -0600 @@ -18,7 +18,6 @@ from mercurial.i18n import _ from mercurial.node import hex, bin, nullid from mercurial import ( - bookmarks, commands, context, encoding, @@ -324,11 +323,7 @@ bms = [rhead + suffix] if bms: - # COMPAT: hg 3.5 - bookmarks.setcurrent renamed to activate - try: - bookmarks.activate(self.repo, bms[0]) - except AttributeError: - bookmarks.setcurrent(self.repo, bms[0]) + compat.activatebookmark(self.repo, bms[0]) self.save_map(self.map_file) @@ -1156,11 +1151,7 @@ tip = hex(tip) commands.bookmark(self.ui, self.repo, 'master', rev=tip, force=True) - # COMPAT: hg 3.5 - bookmarks.setcurrent renamed to activate - try: - bookmarks.activate(self.repo, 'master') - except AttributeError: - bookmarks.setcurrent(self.repo, 'master') + compat.activatebookmark(self.repo, 'master') new_refs['refs/heads/master'] = self.map_git_get(tip) # mapped nodes might be hidden