Patchwork D3422: firefoxtree: declare permissions via @wireprotocommand (bug 1456213); r?sheehan

login
register
mail settings
Submitter phabricator
Date April 23, 2018, 6:28 p.m.
Message ID <differential-rev-PHID-DREV-zizcanxxbfcms5he66pe-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/31212/
State Superseded
Headers show

Comments

phabricator - April 23, 2018, 6:28 p.m.
indygreg created this revision.
indygreg added a reviewer: sheehan.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Mercurial 4.6 moved permissions declaration into the
  @wireprotocommand decorator. This commit sniffs for and uses that
  argument, if available.
  
  This unbusts the wire protocol command on Mercurial 4.6.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3422

AFFECTED FILES
  hgext/firefoxtree/__init__.py

CHANGE DETAILS




To: indygreg, sheehan, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/hgext/firefoxtree/__init__.py b/hgext/firefoxtree/__init__.py
--- a/hgext/firefoxtree/__init__.py
+++ b/hgext/firefoxtree/__init__.py
@@ -73,6 +73,7 @@ 
 """
 
 import errno
+import inspect
 import os
 
 from mercurial import (
@@ -301,7 +302,6 @@ 
         yield tag, node, tree, uri
 
 
-@wireproto.wireprotocommand('firefoxtrees', '')
 def firefoxtrees(repo, proto):
     lines = []
 
@@ -318,8 +318,19 @@ 
 
     return '\n'.join(lines)
 
-if util.safehasattr(wireproto, 'permissions'):
-    wireproto.permissions['firefoxtrees'] = 'pull'
+# Mercurial 4.5.2 added a "permissions" dict. 4.6 moved this into the
+# @wireprotocommand decorator.
+
+# TRACKING hg46
+if 'permission' in inspect.getargspec(wireproto.wireprotocommand).args:
+    firefoxtrees = wireproto.wireprotocommand('firefoxtrees', '',
+                                              permission='pull')(firefoxtrees)
+else:
+    firefoxtrees = wireproto.wireprotocommand('firefoxtrees', '')(firefoxtrees)
+
+    # TRACKING hg45
+    if util.safehasattr(wireproto, 'permissions'):
+        wireproto.permissions['firefoxtrees'] = 'pull'
 
 def push(orig, repo, remote, force=False, revs=None, newbranch=False, **kwargs):
     # If no arguments are specified to `hg push`, Mercurial's default