changeset 1140:583ac3ddd54b

compat: extract function for differing phases.advanceboundary args
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 07 Feb 2018 22:37:28 -0600
parents 8e03a8ba04af
children 56a3fc2086b3
files hggit/compat.py hggit/git_handler.py
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/compat.py	Wed Feb 07 22:30:17 2018 -0600
+++ b/hggit/compat.py	Wed Feb 07 22:37:28 2018 -0600
@@ -1,6 +1,7 @@
 from mercurial import (
     bookmarks,
     context,
+    phases,
     url,
     util as hgutil,
 )
@@ -75,6 +76,13 @@
 else:
     activatebookmark = bookmarks.setcurrent
 
+def advancephaseboundary(repo, tr, targetphase, nodes):
+    # hg 3.2 - advanceboundary uses transaction
+    try:
+        phases.advanceboundary(repo, tr, targetphase, nodes)
+    except TypeError:
+        phases.advanceboundary(repo, targetphase, nodes)
+
 
 try:
     import dulwich.client
--- a/hggit/git_handler.py	Wed Feb 07 22:30:17 2018 -0600
+++ b/hggit/git_handler.py	Wed Feb 07 22:37:28 2018 -0600
@@ -337,13 +337,8 @@
             lock = self.repo.lock()
             try:
                 tr = self.repo.transaction("phase")
-                # COMPAT: hg 3.2 - advanceboundary uses transaction
-                try:
-                    phases.advanceboundary(self.repo, tr, phases.public,
-                                           blist)
-                except TypeError:
-                    phases.advanceboundary(self.repo, phases.public,
-                                           blist)
+                compat.advancephaseboundary(self.repo, tr, phases.public,
+                                            blist)
                 tr.close()
             finally:
                 if tr is not None: