diff hgext/rebase.py @ 27586:42910f9fffeb

revset: use delayregistrar to register predicate in extension easily Previous patch introduced 'revset.predicate' decorator to register revset predicate function easily. But it shouldn't be used in extension directly, because it registers specified function immediately. Registration itself can't be restored, even if extension loading fails after that. Therefore, registration should be delayed until 'uisetup()' or so. This patch uses 'extpredicate' decorator derived from 'delayregistrar' to register predicate in extension easily. This patch also tests whether 'registrar.delayregistrar' avoids function registration if 'setup()' isn't invoked on it, because 'extpredicate' is the first user of it.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 29 Dec 2015 23:58:30 +0900
parents f9e755736b0e
children 157675d0f600
line wrap: on
line diff
--- a/hgext/rebase.py	Tue Dec 29 23:58:30 2015 +0900
+++ b/hgext/rebase.py	Tue Dec 29 23:58:30 2015 +0900
@@ -64,6 +64,9 @@
     branch = repo[None].branch()
     return repo[branch].rev()
 
+revsetpredicate = revset.extpredicate()
+
+@revsetpredicate('_destrebase')
 def _revsetdestrebase(repo, subset, x):
     # ``_rebasedefaultdest()``
 
@@ -1238,4 +1241,4 @@
          _("use 'hg rebase --continue' or 'hg rebase --abort'")])
     # ensure rebased rev are not hidden
     extensions.wrapfunction(repoview, '_getdynamicblockers', _rebasedvisible)
-    revset.symbols['_destrebase'] = _revsetdestrebase
+    revsetpredicate.setup()