hgext/infinitepush/indexapi.py
changeset 37189 03ff17a4bf53
child 43076 2372284d9457
equal deleted inserted replaced
37188:6d43b39fbaa0 37189:03ff17a4bf53
       
     1 # Infinite push
       
     2 #
       
     3 # Copyright 2016 Facebook, Inc.
       
     4 #
       
     5 # This software may be used and distributed according to the terms of the
       
     6 # GNU General Public License version 2 or any later version.
       
     7 
       
     8 from __future__ import absolute_import
       
     9 
       
    10 class indexapi(object):
       
    11     """Class that manages access to infinitepush index.
       
    12 
       
    13     This class is a context manager and all write operations (like
       
    14     deletebookmarks, addbookmark etc) should use `with` statement:
       
    15 
       
    16       with index:
       
    17           index.deletebookmarks(...)
       
    18           ...
       
    19     """
       
    20 
       
    21     def __init__(self):
       
    22         """Initializes the metadata store connection."""
       
    23 
       
    24     def close(self):
       
    25         """Cleans up the metadata store connection."""
       
    26 
       
    27     def __enter__(self):
       
    28         return self
       
    29 
       
    30     def __exit__(self, exc_type, exc_val, exc_tb):
       
    31         pass
       
    32 
       
    33     def addbundle(self, bundleid, nodesctx):
       
    34         """Takes a bundleid and a list of node contexts for each node
       
    35         in that bundle and records that."""
       
    36         raise NotImplementedError()
       
    37 
       
    38     def addbookmark(self, bookmark, node):
       
    39         """Takes a bookmark name and hash, and records mapping in the metadata
       
    40         store."""
       
    41         raise NotImplementedError()
       
    42 
       
    43     def addmanybookmarks(self, bookmarks):
       
    44         """Takes a dict with mapping from bookmark to hash and records mapping
       
    45         in the metadata store."""
       
    46         raise NotImplementedError()
       
    47 
       
    48     def deletebookmarks(self, patterns):
       
    49         """Accepts list of bookmarks and deletes them.
       
    50         """
       
    51         raise NotImplementedError()
       
    52 
       
    53     def getbundle(self, node):
       
    54         """Returns the bundleid for the bundle that contains the given node."""
       
    55         raise NotImplementedError()
       
    56 
       
    57     def getnode(self, bookmark):
       
    58         """Returns the node for the given bookmark. None if it doesn't exist."""
       
    59         raise NotImplementedError()
       
    60 
       
    61     def getbookmarks(self, query):
       
    62         """Returns bookmarks that match the query"""
       
    63         raise NotImplementedError()
       
    64 
       
    65     def saveoptionaljsonmetadata(self, node, jsonmetadata):
       
    66         """Saves optional metadata for a given node"""
       
    67         raise NotImplementedError()
       
    68 
       
    69 class indexexception(Exception):
       
    70     pass