D2999: infinitepush: use zope.interface to define indexapi interface

2018-03-31 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  Oh, when you add test coverage, watch out for `mysql.connector` being 
unavailable. You may want to register a fake module in 
`sys.modules['mysql.connector']` to ensure it always is available.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2999: infinitepush: use zope.interface to define indexapi interface

2018-03-31 Thread indygreg (Gregory Szorc)
indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  Please also add test coverage to `test-check-interfaces.py`, otherwise these 
interfaces mean practically nothing. `zope.interface` doesn't perform run-time 
interface conformance tests unless you explicitly instruct it to. For now, 
we're going to verify interfaces in `test-check-interfaces.py`.

INLINE COMMENTS

> indexapi.py:25
>  
>  def __init__(self):
>  """Initializes the metadata store connection."""

`Interface` classes don't define `self` on methods. So please drop `self` from 
all these methods.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2999: infinitepush: use zope.interface to define indexapi interface

2018-03-31 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch makes indexapi use zope.interface which is now vendored with
  mercurial.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/infinitepush/fileindexapi.py
  hgext/infinitepush/indexapi.py
  hgext/infinitepush/sqlindexapi.py

CHANGE DETAILS

diff --git a/hgext/infinitepush/sqlindexapi.py 
b/hgext/infinitepush/sqlindexapi.py
--- a/hgext/infinitepush/sqlindexapi.py
+++ b/hgext/infinitepush/sqlindexapi.py
@@ -14,6 +14,10 @@
 import warnings
 import mysql.connector
 
+from mercurial.thirdparty.zope import (
+interface as zi,
+)
+
 from . import indexapi
 
 def _convertbookmarkpattern(pattern):
@@ -23,7 +27,8 @@
 pattern = pattern[:-1] + '%'
 return pattern
 
-class sqlindexapi(indexapi.indexapi):
+@zi.implementer(indexapi.indexapi)
+class sqlindexapi(object):
 '''
 Sql backend for infinitepush index. See schema.sql
 '''
diff --git a/hgext/infinitepush/indexapi.py b/hgext/infinitepush/indexapi.py
--- a/hgext/infinitepush/indexapi.py
+++ b/hgext/infinitepush/indexapi.py
@@ -7,7 +7,11 @@
 
 from __future__ import absolute_import
 
-class indexapi(object):
+from mercurial.thirdparty.zope import (
+interface as zi,
+)
+
+class indexapi(zi.Interface):
 """Class that manages access to infinitepush index.
 
 This class is a context manager and all write operations (like
diff --git a/hgext/infinitepush/fileindexapi.py 
b/hgext/infinitepush/fileindexapi.py
--- a/hgext/infinitepush/fileindexapi.py
+++ b/hgext/infinitepush/fileindexapi.py
@@ -15,11 +15,16 @@
 
 import os
 
+from mercurial.thirdparty.zope import (
+interface as zi,
+)
+
 from mercurial.utils import stringutil
 
 from . import indexapi
 
-class fileindexapi(indexapi.indexapi):
+@zi.implementer(indexapi.indexapi)
+class fileindexapi(object):
 def __init__(self, repo):
 super(fileindexapi, self).__init__()
 self._repo = repo



To: pulkit, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel