mercurial/interfaces/repository.py
changeset 43076 2372284d9457
parent 43032 a12a9af7536c
child 43077 687b865b95ad
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
     6 # GNU General Public License version 2 or any later version.
     6 # GNU General Public License version 2 or any later version.
     7 
     7 
     8 from __future__ import absolute_import
     8 from __future__ import absolute_import
     9 
     9 
    10 from ..i18n import _
    10 from ..i18n import _
    11 from .. import (
    11 from .. import error
    12     error,
    12 from . import util as interfaceutil
    13 )
       
    14 from . import (
       
    15     util as interfaceutil,
       
    16 )
       
    17 
    13 
    18 # When narrowing is finalized and no longer subject to format changes,
    14 # When narrowing is finalized and no longer subject to format changes,
    19 # we should move this to just "narrow" or similar.
    15 # we should move this to just "narrow" or similar.
    20 NARROW_REQUIREMENT = 'narrowhg-experimental'
    16 NARROW_REQUIREMENT = 'narrowhg-experimental'
    21 
    17 
    36 REVISION_FLAG_ELLIPSIS = 1 << 14
    32 REVISION_FLAG_ELLIPSIS = 1 << 14
    37 REVISION_FLAG_EXTSTORED = 1 << 13
    33 REVISION_FLAG_EXTSTORED = 1 << 13
    38 REVISION_FLAG_SIDEDATA = 1 << 12
    34 REVISION_FLAG_SIDEDATA = 1 << 12
    39 
    35 
    40 REVISION_FLAGS_KNOWN = (
    36 REVISION_FLAGS_KNOWN = (
    41     REVISION_FLAG_CENSORED | REVISION_FLAG_ELLIPSIS | REVISION_FLAG_EXTSTORED
    37     REVISION_FLAG_CENSORED
       
    38     | REVISION_FLAG_ELLIPSIS
       
    39     | REVISION_FLAG_EXTSTORED
    42     | REVISION_FLAG_SIDEDATA
    40     | REVISION_FLAG_SIDEDATA
    43 )
    41 )
    44 
    42 
    45 CG_DELTAMODE_STD = b'default'
    43 CG_DELTAMODE_STD = b'default'
    46 CG_DELTAMODE_PREV = b'previous'
    44 CG_DELTAMODE_PREV = b'previous'
    47 CG_DELTAMODE_FULL = b'fulltext'
    45 CG_DELTAMODE_FULL = b'fulltext'
    48 CG_DELTAMODE_P1 = b'p1'
    46 CG_DELTAMODE_P1 = b'p1'
    49 
    47 
       
    48 
    50 class ipeerconnection(interfaceutil.Interface):
    49 class ipeerconnection(interfaceutil.Interface):
    51     """Represents a "connection" to a repository.
    50     """Represents a "connection" to a repository.
    52 
    51 
    53     This is the base interface for representing a connection to a repository.
    52     This is the base interface for representing a connection to a repository.
    54     It holds basic properties and methods applicable to all peer types.
    53     It holds basic properties and methods applicable to all peer types.
    55 
    54 
    56     This is not a complete interface definition and should not be used
    55     This is not a complete interface definition and should not be used
    57     outside of this module.
    56     outside of this module.
    58     """
    57     """
       
    58 
    59     ui = interfaceutil.Attribute("""ui.ui instance""")
    59     ui = interfaceutil.Attribute("""ui.ui instance""")
    60 
    60 
    61     def url():
    61     def url():
    62         """Returns a URL string representing this peer.
    62         """Returns a URL string representing this peer.
    63 
    63 
    91 
    91 
    92         This is called when the peer will no longer be used. Resources
    92         This is called when the peer will no longer be used. Resources
    93         associated with the peer should be cleaned up.
    93         associated with the peer should be cleaned up.
    94         """
    94         """
    95 
    95 
       
    96 
    96 class ipeercapabilities(interfaceutil.Interface):
    97 class ipeercapabilities(interfaceutil.Interface):
    97     """Peer sub-interface related to capabilities."""
    98     """Peer sub-interface related to capabilities."""
    98 
    99 
    99     def capable(name):
   100     def capable(name):
   100         """Determine support for a named capability.
   101         """Determine support for a named capability.
   110     def requirecap(name, purpose):
   111     def requirecap(name, purpose):
   111         """Require a capability to be present.
   112         """Require a capability to be present.
   112 
   113 
   113         Raises a ``CapabilityError`` if the capability isn't present.
   114         Raises a ``CapabilityError`` if the capability isn't present.
   114         """
   115         """
       
   116 
   115 
   117 
   116 class ipeercommands(interfaceutil.Interface):
   118 class ipeercommands(interfaceutil.Interface):
   117     """Client-side interface for communicating over the wire protocol.
   119     """Client-side interface for communicating over the wire protocol.
   118 
   120 
   119     This interface is used as a gateway to the Mercurial wire protocol.
   121     This interface is used as a gateway to the Mercurial wire protocol.
   199 
   201 
   200         This is how the bulk of data during a push is transferred.
   202         This is how the bulk of data during a push is transferred.
   201 
   203 
   202         Returns the integer number of heads added to the peer.
   204         Returns the integer number of heads added to the peer.
   203         """
   205         """
       
   206 
   204 
   207 
   205 class ipeerlegacycommands(interfaceutil.Interface):
   208 class ipeerlegacycommands(interfaceutil.Interface):
   206     """Interface for implementing support for legacy wire protocol commands.
   209     """Interface for implementing support for legacy wire protocol commands.
   207 
   210 
   208     Wire protocol commands transition to legacy status when they are no longer
   211     Wire protocol commands transition to legacy status when they are no longer
   231     def changegroup(nodes, source):
   234     def changegroup(nodes, source):
   232         """Obtain a changegroup with data for descendants of specified nodes."""
   235         """Obtain a changegroup with data for descendants of specified nodes."""
   233 
   236 
   234     def changegroupsubset(bases, heads, source):
   237     def changegroupsubset(bases, heads, source):
   235         pass
   238         pass
       
   239 
   236 
   240 
   237 class ipeercommandexecutor(interfaceutil.Interface):
   241 class ipeercommandexecutor(interfaceutil.Interface):
   238     """Represents a mechanism to execute remote commands.
   242     """Represents a mechanism to execute remote commands.
   239 
   243 
   240     This is the primary interface for requesting that wire protocol commands
   244     This is the primary interface for requesting that wire protocol commands
   288         When used as a context manager, this method is called when exiting the
   292         When used as a context manager, this method is called when exiting the
   289         context manager.
   293         context manager.
   290 
   294 
   291         This method may call ``sendcommands()`` if there are buffered commands.
   295         This method may call ``sendcommands()`` if there are buffered commands.
   292         """
   296         """
       
   297 
   293 
   298 
   294 class ipeerrequests(interfaceutil.Interface):
   299 class ipeerrequests(interfaceutil.Interface):
   295     """Interface for executing commands on a peer."""
   300     """Interface for executing commands on a peer."""
   296 
   301 
   297     limitedarguments = interfaceutil.Attribute(
   302     limitedarguments = interfaceutil.Attribute(
   318         called commands until they are told to send them and that each
   323         called commands until they are told to send them and that each
   319         command executor could result in a new connection or wire-level request
   324         command executor could result in a new connection or wire-level request
   320         being issued.
   325         being issued.
   321         """
   326         """
   322 
   327 
       
   328 
   323 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
   329 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
   324     """Unified interface for peer repositories.
   330     """Unified interface for peer repositories.
   325 
   331 
   326     All peer instances must conform to this interface.
   332     All peer instances must conform to this interface.
   327     """
   333     """
   328 
   334 
       
   335 
   329 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests):
   336 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests):
   330     """Unified peer interface for wire protocol version 2 peers."""
   337     """Unified peer interface for wire protocol version 2 peers."""
   331 
   338 
   332     apidescriptor = interfaceutil.Attribute(
   339     apidescriptor = interfaceutil.Attribute(
   333         """Data structure holding description of server API.""")
   340         """Data structure holding description of server API."""
       
   341     )
       
   342 
   334 
   343 
   335 @interfaceutil.implementer(ipeerbase)
   344 @interfaceutil.implementer(ipeerbase)
   336 class peer(object):
   345 class peer(object):
   337     """Base class for peer repositories."""
   346     """Base class for peer repositories."""
   338 
   347 
   344             return True
   353             return True
   345 
   354 
   346         name = '%s=' % name
   355         name = '%s=' % name
   347         for cap in caps:
   356         for cap in caps:
   348             if cap.startswith(name):
   357             if cap.startswith(name):
   349                 return cap[len(name):]
   358                 return cap[len(name) :]
   350 
   359 
   351         return False
   360         return False
   352 
   361 
   353     def requirecap(self, name, purpose):
   362     def requirecap(self, name, purpose):
   354         if self.capable(name):
   363         if self.capable(name):
   355             return
   364             return
   356 
   365 
   357         raise error.CapabilityError(
   366         raise error.CapabilityError(
   358             _('cannot %s; remote repository does not support the '
   367             _(
   359               '\'%s\' capability') % (purpose, name))
   368                 'cannot %s; remote repository does not support the '
       
   369                 '\'%s\' capability'
       
   370             )
       
   371             % (purpose, name)
       
   372         )
       
   373 
   360 
   374 
   361 class iverifyproblem(interfaceutil.Interface):
   375 class iverifyproblem(interfaceutil.Interface):
   362     """Represents a problem with the integrity of the repository.
   376     """Represents a problem with the integrity of the repository.
   363 
   377 
   364     Instances of this interface are emitted to describe an integrity issue
   378     Instances of this interface are emitted to describe an integrity issue
   365     with a repository (e.g. corrupt storage, missing data, etc).
   379     with a repository (e.g. corrupt storage, missing data, etc).
   366 
   380 
   367     Instances are essentially messages associated with severity.
   381     Instances are essentially messages associated with severity.
   368     """
   382     """
       
   383 
   369     warning = interfaceutil.Attribute(
   384     warning = interfaceutil.Attribute(
   370         """Message indicating a non-fatal problem.""")
   385         """Message indicating a non-fatal problem."""
   371 
   386     )
   372     error = interfaceutil.Attribute(
   387 
   373         """Message indicating a fatal problem.""")
   388     error = interfaceutil.Attribute("""Message indicating a fatal problem.""")
   374 
   389 
   375     node = interfaceutil.Attribute(
   390     node = interfaceutil.Attribute(
   376         """Revision encountering the problem.
   391         """Revision encountering the problem.
   377 
   392 
   378         ``None`` means the problem doesn't apply to a single revision.
   393         ``None`` means the problem doesn't apply to a single revision.
   379         """)
   394         """
       
   395     )
       
   396 
   380 
   397 
   381 class irevisiondelta(interfaceutil.Interface):
   398 class irevisiondelta(interfaceutil.Interface):
   382     """Represents a delta between one revision and another.
   399     """Represents a delta between one revision and another.
   383 
   400 
   384     Instances convey enough information to allow a revision to be exchanged
   401     Instances convey enough information to allow a revision to be exchanged
   389     are mutually exclusive.
   406     are mutually exclusive.
   390 
   407 
   391     Typically used for changegroup generation.
   408     Typically used for changegroup generation.
   392     """
   409     """
   393 
   410 
   394     node = interfaceutil.Attribute(
   411     node = interfaceutil.Attribute("""20 byte node of this revision.""")
   395         """20 byte node of this revision.""")
       
   396 
   412 
   397     p1node = interfaceutil.Attribute(
   413     p1node = interfaceutil.Attribute(
   398         """20 byte node of 1st parent of this revision.""")
   414         """20 byte node of 1st parent of this revision."""
       
   415     )
   399 
   416 
   400     p2node = interfaceutil.Attribute(
   417     p2node = interfaceutil.Attribute(
   401         """20 byte node of 2nd parent of this revision.""")
   418         """20 byte node of 2nd parent of this revision."""
       
   419     )
   402 
   420 
   403     linknode = interfaceutil.Attribute(
   421     linknode = interfaceutil.Attribute(
   404         """20 byte node of the changelog revision this node is linked to.""")
   422         """20 byte node of the changelog revision this node is linked to."""
       
   423     )
   405 
   424 
   406     flags = interfaceutil.Attribute(
   425     flags = interfaceutil.Attribute(
   407         """2 bytes of integer flags that apply to this revision.
   426         """2 bytes of integer flags that apply to this revision.
   408 
   427 
   409         This is a bitwise composition of the ``REVISION_FLAG_*`` constants.
   428         This is a bitwise composition of the ``REVISION_FLAG_*`` constants.
   410         """)
   429         """
       
   430     )
   411 
   431 
   412     basenode = interfaceutil.Attribute(
   432     basenode = interfaceutil.Attribute(
   413         """20 byte node of the revision this data is a delta against.
   433         """20 byte node of the revision this data is a delta against.
   414 
   434 
   415         ``nullid`` indicates that the revision is a full revision and not
   435         ``nullid`` indicates that the revision is a full revision and not
   416         a delta.
   436         a delta.
   417         """)
   437         """
       
   438     )
   418 
   439 
   419     baserevisionsize = interfaceutil.Attribute(
   440     baserevisionsize = interfaceutil.Attribute(
   420         """Size of base revision this delta is against.
   441         """Size of base revision this delta is against.
   421 
   442 
   422         May be ``None`` if ``basenode`` is ``nullid``.
   443         May be ``None`` if ``basenode`` is ``nullid``.
   423         """)
   444         """
       
   445     )
   424 
   446 
   425     revision = interfaceutil.Attribute(
   447     revision = interfaceutil.Attribute(
   426         """Raw fulltext of revision data for this node.""")
   448         """Raw fulltext of revision data for this node."""
       
   449     )
   427 
   450 
   428     delta = interfaceutil.Attribute(
   451     delta = interfaceutil.Attribute(
   429         """Delta between ``basenode`` and ``node``.
   452         """Delta between ``basenode`` and ``node``.
   430 
   453 
   431         Stored in the bdiff delta format.
   454         Stored in the bdiff delta format.
   432         """)
   455         """
       
   456     )
       
   457 
   433 
   458 
   434 class ifilerevisionssequence(interfaceutil.Interface):
   459 class ifilerevisionssequence(interfaceutil.Interface):
   435     """Contains index data for all revisions of a file.
   460     """Contains index data for all revisions of a file.
   436 
   461 
   437     Types implementing this behave like lists of tuples. The index
   462     Types implementing this behave like lists of tuples. The index
   480         """Whether a revision number exists."""
   505         """Whether a revision number exists."""
   481 
   506 
   482     def insert(self, i, entry):
   507     def insert(self, i, entry):
   483         """Add an item to the index at specific revision."""
   508         """Add an item to the index at specific revision."""
   484 
   509 
       
   510 
   485 class ifileindex(interfaceutil.Interface):
   511 class ifileindex(interfaceutil.Interface):
   486     """Storage interface for index data of a single file.
   512     """Storage interface for index data of a single file.
   487 
   513 
   488     File storage data is divided into index metadata and data storage.
   514     File storage data is divided into index metadata and data storage.
   489     This interface defines the index portion of the interface.
   515     This interface defines the index portion of the interface.
   492 
   518 
   493     * A mapping between revision numbers and nodes.
   519     * A mapping between revision numbers and nodes.
   494     * DAG data (storing and querying the relationship between nodes).
   520     * DAG data (storing and querying the relationship between nodes).
   495     * Metadata to facilitate storage.
   521     * Metadata to facilitate storage.
   496     """
   522     """
       
   523 
   497     def __len__():
   524     def __len__():
   498         """Obtain the number of revisions stored for this file."""
   525         """Obtain the number of revisions stored for this file."""
   499 
   526 
   500     def __iter__():
   527     def __iter__():
   501         """Iterate over revision numbers for this file."""
   528         """Iterate over revision numbers for this file."""
   575         """Obtain nodes that are children of a node.
   602         """Obtain nodes that are children of a node.
   576 
   603 
   577         Returns a list of nodes.
   604         Returns a list of nodes.
   578         """
   605         """
   579 
   606 
       
   607 
   580 class ifiledata(interfaceutil.Interface):
   608 class ifiledata(interfaceutil.Interface):
   581     """Storage interface for data storage of a specific file.
   609     """Storage interface for data storage of a specific file.
   582 
   610 
   583     This complements ``ifileindex`` and provides an interface for accessing
   611     This complements ``ifileindex`` and provides an interface for accessing
   584     data for a tracked file.
   612     data for a tracked file.
   585     """
   613     """
       
   614 
   586     def size(rev):
   615     def size(rev):
   587         """Obtain the fulltext size of file data.
   616         """Obtain the fulltext size of file data.
   588 
   617 
   589         Any metadata is excluded from size measurements.
   618         Any metadata is excluded from size measurements.
   590         """
   619         """
   626         This takes copy metadata into account.
   655         This takes copy metadata into account.
   627 
   656 
   628         TODO better document the copy metadata and censoring logic.
   657         TODO better document the copy metadata and censoring logic.
   629         """
   658         """
   630 
   659 
   631     def emitrevisions(nodes,
   660     def emitrevisions(
   632                       nodesorder=None,
   661         nodes,
   633                       revisiondata=False,
   662         nodesorder=None,
   634                       assumehaveparentrevisions=False,
   663         revisiondata=False,
   635                       deltamode=CG_DELTAMODE_STD):
   664         assumehaveparentrevisions=False,
       
   665         deltamode=CG_DELTAMODE_STD,
       
   666     ):
   636         """Produce ``irevisiondelta`` for revisions.
   667         """Produce ``irevisiondelta`` for revisions.
   637 
   668 
   638         Given an iterable of nodes, emits objects conforming to the
   669         Given an iterable of nodes, emits objects conforming to the
   639         ``irevisiondelta`` interface that describe revisions in storage.
   670         ``irevisiondelta`` interface that describe revisions in storage.
   640 
   671 
   679         all revision data should be emitted as deltas against the revision
   710         all revision data should be emitted as deltas against the revision
   680         emitted just prior. The initial revision should be a delta against its
   711         emitted just prior. The initial revision should be a delta against its
   681         1st parent.
   712         1st parent.
   682         """
   713         """
   683 
   714 
       
   715 
   684 class ifilemutation(interfaceutil.Interface):
   716 class ifilemutation(interfaceutil.Interface):
   685     """Storage interface for mutation events of a tracked file."""
   717     """Storage interface for mutation events of a tracked file."""
   686 
   718 
   687     def add(filedata, meta, transaction, linkrev, p1, p2):
   719     def add(filedata, meta, transaction, linkrev, p1, p2):
   688         """Add a new revision to the store.
   720         """Add a new revision to the store.
   693         Returns the node that was added.
   725         Returns the node that was added.
   694 
   726 
   695         May no-op if a revision matching the supplied data is already stored.
   727         May no-op if a revision matching the supplied data is already stored.
   696         """
   728         """
   697 
   729 
   698     def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
   730     def addrevision(
   699                     flags=0, cachedelta=None):
   731         revisiondata,
       
   732         transaction,
       
   733         linkrev,
       
   734         p1,
       
   735         p2,
       
   736         node=None,
       
   737         flags=0,
       
   738         cachedelta=None,
       
   739     ):
   700         """Add a new revision to the store.
   740         """Add a new revision to the store.
   701 
   741 
   702         This is similar to ``add()`` except it operates at a lower level.
   742         This is similar to ``add()`` except it operates at a lower level.
   703 
   743 
   704         The data passed in already contains a metadata header, if any.
   744         The data passed in already contains a metadata header, if any.
   711         directory. ``addrevision()`` is often called by ``add()`` and for
   751         directory. ``addrevision()`` is often called by ``add()`` and for
   712         scenarios where revision data has already been computed, such as when
   752         scenarios where revision data has already been computed, such as when
   713         applying raw data from a peer repo.
   753         applying raw data from a peer repo.
   714         """
   754         """
   715 
   755 
   716     def addgroup(deltas, linkmapper, transaction, addrevisioncb=None,
   756     def addgroup(
   717                  maybemissingparents=False):
   757         deltas,
       
   758         linkmapper,
       
   759         transaction,
       
   760         addrevisioncb=None,
       
   761         maybemissingparents=False,
       
   762     ):
   718         """Process a series of deltas for storage.
   763         """Process a series of deltas for storage.
   719 
   764 
   720         ``deltas`` is an iterable of 7-tuples of
   765         ``deltas`` is an iterable of 7-tuples of
   721         (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
   766         (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
   722         to add.
   767         to add.
   772 
   817 
   773         TODO this is highly revlog centric and should be abstracted into a
   818         TODO this is highly revlog centric and should be abstracted into a
   774         higher-level deletion API.
   819         higher-level deletion API.
   775         """
   820         """
   776 
   821 
       
   822 
   777 class ifilestorage(ifileindex, ifiledata, ifilemutation):
   823 class ifilestorage(ifileindex, ifiledata, ifilemutation):
   778     """Complete storage interface for a single tracked file."""
   824     """Complete storage interface for a single tracked file."""
   779 
   825 
   780     def files():
   826     def files():
   781         """Obtain paths that are backing storage for this file.
   827         """Obtain paths that are backing storage for this file.
   782 
   828 
   783         TODO this is used heavily by verify code and there should probably
   829         TODO this is used heavily by verify code and there should probably
   784         be a better API for that.
   830         be a better API for that.
   785         """
   831         """
   786 
   832 
   787     def storageinfo(exclusivefiles=False, sharedfiles=False,
   833     def storageinfo(
   788                     revisionscount=False, trackedsize=False,
   834         exclusivefiles=False,
   789                     storedsize=False):
   835         sharedfiles=False,
       
   836         revisionscount=False,
       
   837         trackedsize=False,
       
   838         storedsize=False,
       
   839     ):
   790         """Obtain information about storage for this file's data.
   840         """Obtain information about storage for this file's data.
   791 
   841 
   792         Returns a dict describing storage for this tracked path. The keys
   842         Returns a dict describing storage for this tracked path. The keys
   793         in the dict map to arguments of the same. The arguments are bools
   843         in the dict map to arguments of the same. The arguments are bools
   794         indicating whether to calculate and obtain that data.
   844         indicating whether to calculate and obtain that data.
   832 
   882 
   833         The method yields objects conforming to the ``iverifyproblem``
   883         The method yields objects conforming to the ``iverifyproblem``
   834         interface.
   884         interface.
   835         """
   885         """
   836 
   886 
       
   887 
   837 class idirs(interfaceutil.Interface):
   888 class idirs(interfaceutil.Interface):
   838     """Interface representing a collection of directories from paths.
   889     """Interface representing a collection of directories from paths.
   839 
   890 
   840     This interface is essentially a derived data structure representing
   891     This interface is essentially a derived data structure representing
   841     directories from a collection of paths.
   892     directories from a collection of paths.
   857     def __iter__():
   908     def __iter__():
   858         """Iterate over the directories in this collection of paths."""
   909         """Iterate over the directories in this collection of paths."""
   859 
   910 
   860     def __contains__(path):
   911     def __contains__(path):
   861         """Whether a specific directory is in this collection."""
   912         """Whether a specific directory is in this collection."""
       
   913 
   862 
   914 
   863 class imanifestdict(interfaceutil.Interface):
   915 class imanifestdict(interfaceutil.Interface):
   864     """Interface representing a manifest data structure.
   916     """Interface representing a manifest data structure.
   865 
   917 
   866     A manifest is effectively a dict mapping paths to entries. Each entry
   918     A manifest is effectively a dict mapping paths to entries. Each entry
  1007 
  1059 
  1008         Returns a 2-tuple containing ``bytearray(self.text())`` and the
  1060         Returns a 2-tuple containing ``bytearray(self.text())`` and the
  1009         delta between ``base`` and this manifest.
  1061         delta between ``base`` and this manifest.
  1010         """
  1062         """
  1011 
  1063 
       
  1064 
  1012 class imanifestrevisionbase(interfaceutil.Interface):
  1065 class imanifestrevisionbase(interfaceutil.Interface):
  1013     """Base interface representing a single revision of a manifest.
  1066     """Base interface representing a single revision of a manifest.
  1014 
  1067 
  1015     Should not be used as a primary interface: should always be inherited
  1068     Should not be used as a primary interface: should always be inherited
  1016     as part of a larger interface.
  1069     as part of a larger interface.
  1036         """Obtain the parsed manifest data structure.
  1089         """Obtain the parsed manifest data structure.
  1037 
  1090 
  1038         The returned object conforms to the ``imanifestdict`` interface.
  1091         The returned object conforms to the ``imanifestdict`` interface.
  1039         """
  1092         """
  1040 
  1093 
       
  1094 
  1041 class imanifestrevisionstored(imanifestrevisionbase):
  1095 class imanifestrevisionstored(imanifestrevisionbase):
  1042     """Interface representing a manifest revision committed to storage."""
  1096     """Interface representing a manifest revision committed to storage."""
  1043 
  1097 
  1044     def node():
  1098     def node():
  1045         """The binary node for this manifest."""
  1099         """The binary node for this manifest."""
  1066     def find(key):
  1120     def find(key):
  1067         """Calls self.read().find(key)``.
  1121         """Calls self.read().find(key)``.
  1068 
  1122 
  1069         Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
  1123         Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
  1070         """
  1124         """
       
  1125 
  1071 
  1126 
  1072 class imanifestrevisionwritable(imanifestrevisionbase):
  1127 class imanifestrevisionwritable(imanifestrevisionbase):
  1073     """Interface representing a manifest revision that can be committed."""
  1128     """Interface representing a manifest revision that can be committed."""
  1074 
  1129 
  1075     def write(transaction, linkrev, p1node, p2node, added, removed, match=None):
  1130     def write(transaction, linkrev, p1node, p2node, added, removed, match=None):
  1085         manifests should not be "narrowed on disk").
  1140         manifests should not be "narrowed on disk").
  1086 
  1141 
  1087         Returns the binary node of the created revision.
  1142         Returns the binary node of the created revision.
  1088         """
  1143         """
  1089 
  1144 
       
  1145 
  1090 class imanifeststorage(interfaceutil.Interface):
  1146 class imanifeststorage(interfaceutil.Interface):
  1091     """Storage interface for manifest data."""
  1147     """Storage interface for manifest data."""
  1092 
  1148 
  1093     tree = interfaceutil.Attribute(
  1149     tree = interfaceutil.Attribute(
  1094         """The path to the directory this manifest tracks.
  1150         """The path to the directory this manifest tracks.
  1095 
  1151 
  1096         The empty bytestring represents the root manifest.
  1152         The empty bytestring represents the root manifest.
  1097         """)
  1153         """
       
  1154     )
  1098 
  1155 
  1099     index = interfaceutil.Attribute(
  1156     index = interfaceutil.Attribute(
  1100         """An ``ifilerevisionssequence`` instance.""")
  1157         """An ``ifilerevisionssequence`` instance."""
       
  1158     )
  1101 
  1159 
  1102     indexfile = interfaceutil.Attribute(
  1160     indexfile = interfaceutil.Attribute(
  1103         """Path of revlog index file.
  1161         """Path of revlog index file.
  1104 
  1162 
  1105         TODO this is revlog specific and should not be exposed.
  1163         TODO this is revlog specific and should not be exposed.
  1106         """)
  1164         """
       
  1165     )
  1107 
  1166 
  1108     opener = interfaceutil.Attribute(
  1167     opener = interfaceutil.Attribute(
  1109         """VFS opener to use to access underlying files used for storage.
  1168         """VFS opener to use to access underlying files used for storage.
  1110 
  1169 
  1111         TODO this is revlog specific and should not be exposed.
  1170         TODO this is revlog specific and should not be exposed.
  1112         """)
  1171         """
       
  1172     )
  1113 
  1173 
  1114     version = interfaceutil.Attribute(
  1174     version = interfaceutil.Attribute(
  1115         """Revlog version number.
  1175         """Revlog version number.
  1116 
  1176 
  1117         TODO this is revlog specific and should not be exposed.
  1177         TODO this is revlog specific and should not be exposed.
  1118         """)
  1178         """
       
  1179     )
  1119 
  1180 
  1120     _generaldelta = interfaceutil.Attribute(
  1181     _generaldelta = interfaceutil.Attribute(
  1121         """Whether generaldelta storage is being used.
  1182         """Whether generaldelta storage is being used.
  1122 
  1183 
  1123         TODO this is revlog specific and should not be exposed.
  1184         TODO this is revlog specific and should not be exposed.
  1124         """)
  1185         """
       
  1186     )
  1125 
  1187 
  1126     fulltextcache = interfaceutil.Attribute(
  1188     fulltextcache = interfaceutil.Attribute(
  1127         """Dict with cache of fulltexts.
  1189         """Dict with cache of fulltexts.
  1128 
  1190 
  1129         TODO this doesn't feel appropriate for the storage interface.
  1191         TODO this doesn't feel appropriate for the storage interface.
  1130         """)
  1192         """
       
  1193     )
  1131 
  1194 
  1132     def __len__():
  1195     def __len__():
  1133         """Obtain the number of revisions stored for this manifest."""
  1196         """Obtain the number of revisions stored for this manifest."""
  1134 
  1197 
  1135     def __iter__():
  1198     def __iter__():
  1185         """Compare fulltext to another revision.
  1248         """Compare fulltext to another revision.
  1186 
  1249 
  1187         Returns True if the fulltext is different from what is stored.
  1250         Returns True if the fulltext is different from what is stored.
  1188         """
  1251         """
  1189 
  1252 
  1190     def emitrevisions(nodes,
  1253     def emitrevisions(
  1191                       nodesorder=None,
  1254         nodes,
  1192                       revisiondata=False,
  1255         nodesorder=None,
  1193                       assumehaveparentrevisions=False):
  1256         revisiondata=False,
       
  1257         assumehaveparentrevisions=False,
       
  1258     ):
  1194         """Produce ``irevisiondelta`` describing revisions.
  1259         """Produce ``irevisiondelta`` describing revisions.
  1195 
  1260 
  1196         See the documentation for ``ifiledata`` for more.
  1261         See the documentation for ``ifiledata`` for more.
  1197         """
  1262         """
  1198 
  1263 
  1249         """Clear any caches associated with this instance."""
  1314         """Clear any caches associated with this instance."""
  1250 
  1315 
  1251     def dirlog(d):
  1316     def dirlog(d):
  1252         """Obtain a manifest storage instance for a tree."""
  1317         """Obtain a manifest storage instance for a tree."""
  1253 
  1318 
  1254     def add(m, transaction, link, p1, p2, added, removed, readtree=None,
  1319     def add(
  1255             match=None):
  1320         m, transaction, link, p1, p2, added, removed, readtree=None, match=None
       
  1321     ):
  1256         """Add a revision to storage.
  1322         """Add a revision to storage.
  1257 
  1323 
  1258         ``m`` is an object conforming to ``imanifestdict``.
  1324         ``m`` is an object conforming to ``imanifestdict``.
  1259 
  1325 
  1260         ``link`` is the linkrev revision number.
  1326         ``link`` is the linkrev revision number.
  1272         paths must be inspected; this is an optimization and can be safely
  1338         paths must be inspected; this is an optimization and can be safely
  1273         ignored. Note that the storage must still be able to reproduce a full
  1339         ignored. Note that the storage must still be able to reproduce a full
  1274         manifest including files that did not match.
  1340         manifest including files that did not match.
  1275         """
  1341         """
  1276 
  1342 
  1277     def storageinfo(exclusivefiles=False, sharedfiles=False,
  1343     def storageinfo(
  1278                     revisionscount=False, trackedsize=False,
  1344         exclusivefiles=False,
  1279                     storedsize=False):
  1345         sharedfiles=False,
       
  1346         revisionscount=False,
       
  1347         trackedsize=False,
       
  1348         storedsize=False,
       
  1349     ):
  1280         """Obtain information about storage for this manifest's data.
  1350         """Obtain information about storage for this manifest's data.
  1281 
  1351 
  1282         See ``ifilestorage.storageinfo()`` for a description of this method.
  1352         See ``ifilestorage.storageinfo()`` for a description of this method.
  1283         This one behaves the same way, except for manifest data.
  1353         This one behaves the same way, except for manifest data.
  1284         """
  1354         """
       
  1355 
  1285 
  1356 
  1286 class imanifestlog(interfaceutil.Interface):
  1357 class imanifestlog(interfaceutil.Interface):
  1287     """Interface representing a collection of manifest snapshots.
  1358     """Interface representing a collection of manifest snapshots.
  1288 
  1359 
  1289     Represents the root manifest in a repository.
  1360     Represents the root manifest in a repository.
  1334         """Obtain the revision number for a binary node.
  1405         """Obtain the revision number for a binary node.
  1335 
  1406 
  1336         Raises ``error.LookupError`` if the node is not known.
  1407         Raises ``error.LookupError`` if the node is not known.
  1337         """
  1408         """
  1338 
  1409 
       
  1410 
  1339 class ilocalrepositoryfilestorage(interfaceutil.Interface):
  1411 class ilocalrepositoryfilestorage(interfaceutil.Interface):
  1340     """Local repository sub-interface providing access to tracked file storage.
  1412     """Local repository sub-interface providing access to tracked file storage.
  1341 
  1413 
  1342     This interface defines how a repository accesses storage for a single
  1414     This interface defines how a repository accesses storage for a single
  1343     tracked file path.
  1415     tracked file path.
  1347         """Obtain a filelog for a tracked path.
  1419         """Obtain a filelog for a tracked path.
  1348 
  1420 
  1349         The returned type conforms to the ``ifilestorage`` interface.
  1421         The returned type conforms to the ``ifilestorage`` interface.
  1350         """
  1422         """
  1351 
  1423 
       
  1424 
  1352 class ilocalrepositorymain(interfaceutil.Interface):
  1425 class ilocalrepositorymain(interfaceutil.Interface):
  1353     """Main interface for local repositories.
  1426     """Main interface for local repositories.
  1354 
  1427 
  1355     This currently captures the reality of things - not how things should be.
  1428     This currently captures the reality of things - not how things should be.
  1356     """
  1429     """
  1357 
  1430 
  1358     supportedformats = interfaceutil.Attribute(
  1431     supportedformats = interfaceutil.Attribute(
  1359         """Set of requirements that apply to stream clone.
  1432         """Set of requirements that apply to stream clone.
  1360 
  1433 
  1361         This is actually a class attribute and is shared among all instances.
  1434         This is actually a class attribute and is shared among all instances.
  1362         """)
  1435         """
       
  1436     )
  1363 
  1437 
  1364     supported = interfaceutil.Attribute(
  1438     supported = interfaceutil.Attribute(
  1365         """Set of requirements that this repo is capable of opening.""")
  1439         """Set of requirements that this repo is capable of opening."""
       
  1440     )
  1366 
  1441 
  1367     requirements = interfaceutil.Attribute(
  1442     requirements = interfaceutil.Attribute(
  1368         """Set of requirements this repo uses.""")
  1443         """Set of requirements this repo uses."""
       
  1444     )
  1369 
  1445 
  1370     features = interfaceutil.Attribute(
  1446     features = interfaceutil.Attribute(
  1371         """Set of "features" this repository supports.
  1447         """Set of "features" this repository supports.
  1372 
  1448 
  1373         A "feature" is a loosely-defined term. It can refer to a feature
  1449         A "feature" is a loosely-defined term. It can refer to a feature
  1381 
  1457 
  1382         Features are similar to ``requirements``. The main difference is that
  1458         Features are similar to ``requirements``. The main difference is that
  1383         requirements are stored on-disk and represent requirements to open the
  1459         requirements are stored on-disk and represent requirements to open the
  1384         repository. Features are more run-time capabilities of the repository
  1460         repository. Features are more run-time capabilities of the repository
  1385         and more granular capabilities (which may be derived from requirements).
  1461         and more granular capabilities (which may be derived from requirements).
  1386         """)
  1462         """
       
  1463     )
  1387 
  1464 
  1388     filtername = interfaceutil.Attribute(
  1465     filtername = interfaceutil.Attribute(
  1389         """Name of the repoview that is active on this repo.""")
  1466         """Name of the repoview that is active on this repo."""
       
  1467     )
  1390 
  1468 
  1391     wvfs = interfaceutil.Attribute(
  1469     wvfs = interfaceutil.Attribute(
  1392         """VFS used to access the working directory.""")
  1470         """VFS used to access the working directory."""
       
  1471     )
  1393 
  1472 
  1394     vfs = interfaceutil.Attribute(
  1473     vfs = interfaceutil.Attribute(
  1395         """VFS rooted at the .hg directory.
  1474         """VFS rooted at the .hg directory.
  1396 
  1475 
  1397         Used to access repository data not in the store.
  1476         Used to access repository data not in the store.
  1398         """)
  1477         """
       
  1478     )
  1399 
  1479 
  1400     svfs = interfaceutil.Attribute(
  1480     svfs = interfaceutil.Attribute(
  1401         """VFS rooted at the store.
  1481         """VFS rooted at the store.
  1402 
  1482 
  1403         Used to access repository data in the store. Typically .hg/store.
  1483         Used to access repository data in the store. Typically .hg/store.
  1404         But can point elsewhere if the store is shared.
  1484         But can point elsewhere if the store is shared.
  1405         """)
  1485         """
       
  1486     )
  1406 
  1487 
  1407     root = interfaceutil.Attribute(
  1488     root = interfaceutil.Attribute(
  1408         """Path to the root of the working directory.""")
  1489         """Path to the root of the working directory."""
  1409 
  1490     )
  1410     path = interfaceutil.Attribute(
  1491 
  1411         """Path to the .hg directory.""")
  1492     path = interfaceutil.Attribute("""Path to the .hg directory.""")
  1412 
  1493 
  1413     origroot = interfaceutil.Attribute(
  1494     origroot = interfaceutil.Attribute(
  1414         """The filesystem path that was used to construct the repo.""")
  1495         """The filesystem path that was used to construct the repo."""
       
  1496     )
  1415 
  1497 
  1416     auditor = interfaceutil.Attribute(
  1498     auditor = interfaceutil.Attribute(
  1417         """A pathauditor for the working directory.
  1499         """A pathauditor for the working directory.
  1418 
  1500 
  1419         This checks if a path refers to a nested repository.
  1501         This checks if a path refers to a nested repository.
  1420 
  1502 
  1421         Operates on the filesystem.
  1503         Operates on the filesystem.
  1422         """)
  1504         """
       
  1505     )
  1423 
  1506 
  1424     nofsauditor = interfaceutil.Attribute(
  1507     nofsauditor = interfaceutil.Attribute(
  1425         """A pathauditor for the working directory.
  1508         """A pathauditor for the working directory.
  1426 
  1509 
  1427         This is like ``auditor`` except it doesn't do filesystem checks.
  1510         This is like ``auditor`` except it doesn't do filesystem checks.
  1428         """)
  1511         """
       
  1512     )
  1429 
  1513 
  1430     baseui = interfaceutil.Attribute(
  1514     baseui = interfaceutil.Attribute(
  1431         """Original ui instance passed into constructor.""")
  1515         """Original ui instance passed into constructor."""
  1432 
  1516     )
  1433     ui = interfaceutil.Attribute(
  1517 
  1434         """Main ui instance for this instance.""")
  1518     ui = interfaceutil.Attribute("""Main ui instance for this instance.""")
  1435 
  1519 
  1436     sharedpath = interfaceutil.Attribute(
  1520     sharedpath = interfaceutil.Attribute(
  1437         """Path to the .hg directory of the repo this repo was shared from.""")
  1521         """Path to the .hg directory of the repo this repo was shared from."""
  1438 
  1522     )
  1439     store = interfaceutil.Attribute(
  1523 
  1440         """A store instance.""")
  1524     store = interfaceutil.Attribute("""A store instance.""")
  1441 
  1525 
  1442     spath = interfaceutil.Attribute(
  1526     spath = interfaceutil.Attribute("""Path to the store.""")
  1443         """Path to the store.""")
  1527 
  1444 
  1528     sjoin = interfaceutil.Attribute("""Alias to self.store.join.""")
  1445     sjoin = interfaceutil.Attribute(
       
  1446         """Alias to self.store.join.""")
       
  1447 
  1529 
  1448     cachevfs = interfaceutil.Attribute(
  1530     cachevfs = interfaceutil.Attribute(
  1449         """A VFS used to access the cache directory.
  1531         """A VFS used to access the cache directory.
  1450 
  1532 
  1451         Typically .hg/cache.
  1533         Typically .hg/cache.
  1452         """)
  1534         """
       
  1535     )
  1453 
  1536 
  1454     wcachevfs = interfaceutil.Attribute(
  1537     wcachevfs = interfaceutil.Attribute(
  1455         """A VFS used to access the cache directory dedicated to working copy
  1538         """A VFS used to access the cache directory dedicated to working copy
  1456 
  1539 
  1457         Typically .hg/wcache.
  1540         Typically .hg/wcache.
  1458         """)
  1541         """
       
  1542     )
  1459 
  1543 
  1460     filteredrevcache = interfaceutil.Attribute(
  1544     filteredrevcache = interfaceutil.Attribute(
  1461         """Holds sets of revisions to be filtered.""")
  1545         """Holds sets of revisions to be filtered."""
  1462 
  1546     )
  1463     names = interfaceutil.Attribute(
  1547 
  1464         """A ``namespaces`` instance.""")
  1548     names = interfaceutil.Attribute("""A ``namespaces`` instance.""")
  1465 
  1549 
  1466     def close():
  1550     def close():
  1467         """Close the handle on this repository."""
  1551         """Close the handle on this repository."""
  1468 
  1552 
  1469     def peer():
  1553     def peer():
  1473         """Obtain an unfiltered/raw view of this repo."""
  1557         """Obtain an unfiltered/raw view of this repo."""
  1474 
  1558 
  1475     def filtered(name, visibilityexceptions=None):
  1559     def filtered(name, visibilityexceptions=None):
  1476         """Obtain a named view of this repository."""
  1560         """Obtain a named view of this repository."""
  1477 
  1561 
  1478     obsstore = interfaceutil.Attribute(
  1562     obsstore = interfaceutil.Attribute("""A store of obsolescence data.""")
  1479         """A store of obsolescence data.""")
  1563 
  1480 
  1564     changelog = interfaceutil.Attribute("""A handle on the changelog revlog.""")
  1481     changelog = interfaceutil.Attribute(
       
  1482         """A handle on the changelog revlog.""")
       
  1483 
  1565 
  1484     manifestlog = interfaceutil.Attribute(
  1566     manifestlog = interfaceutil.Attribute(
  1485         """An instance conforming to the ``imanifestlog`` interface.
  1567         """An instance conforming to the ``imanifestlog`` interface.
  1486 
  1568 
  1487         Provides access to manifests for the repository.
  1569         Provides access to manifests for the repository.
  1488         """)
  1570         """
  1489 
  1571     )
  1490     dirstate = interfaceutil.Attribute(
  1572 
  1491         """Working directory state.""")
  1573     dirstate = interfaceutil.Attribute("""Working directory state.""")
  1492 
  1574 
  1493     narrowpats = interfaceutil.Attribute(
  1575     narrowpats = interfaceutil.Attribute(
  1494         """Matcher patterns for this repository's narrowspec.""")
  1576         """Matcher patterns for this repository's narrowspec."""
       
  1577     )
  1495 
  1578 
  1496     def narrowmatch(match=None, includeexact=False):
  1579     def narrowmatch(match=None, includeexact=False):
  1497         """Obtain a matcher for the narrowspec."""
  1580         """Obtain a matcher for the narrowspec."""
  1498 
  1581 
  1499     def setnarrowpats(newincludes, newexcludes):
  1582     def setnarrowpats(newincludes, newexcludes):
  1660         """Return the wlock if it's held or None."""
  1743         """Return the wlock if it's held or None."""
  1661 
  1744 
  1662     def checkcommitpatterns(wctx, vdirs, match, status, fail):
  1745     def checkcommitpatterns(wctx, vdirs, match, status, fail):
  1663         pass
  1746         pass
  1664 
  1747 
  1665     def commit(text='', user=None, date=None, match=None, force=False,
  1748     def commit(
  1666                editor=False, extra=None):
  1749         text='',
       
  1750         user=None,
       
  1751         date=None,
       
  1752         match=None,
       
  1753         force=False,
       
  1754         editor=False,
       
  1755         extra=None,
       
  1756     ):
  1667         """Add a new revision to the repository."""
  1757         """Add a new revision to the repository."""
  1668 
  1758 
  1669     def commitctx(ctx, error=False, origctx=None):
  1759     def commitctx(ctx, error=False, origctx=None):
  1670         """Commit a commitctx instance to the repository."""
  1760         """Commit a commitctx instance to the repository."""
  1671 
  1761 
  1673         """Inform the repository that nodes are about to be destroyed."""
  1763         """Inform the repository that nodes are about to be destroyed."""
  1674 
  1764 
  1675     def destroyed():
  1765     def destroyed():
  1676         """Inform the repository that nodes have been destroyed."""
  1766         """Inform the repository that nodes have been destroyed."""
  1677 
  1767 
  1678     def status(node1='.', node2=None, match=None, ignored=False,
  1768     def status(
  1679                clean=False, unknown=False, listsubrepos=False):
  1769         node1='.',
       
  1770         node2=None,
       
  1771         match=None,
       
  1772         ignored=False,
       
  1773         clean=False,
       
  1774         unknown=False,
       
  1775         listsubrepos=False,
       
  1776     ):
  1680         """Convenience method to call repo[x].status()."""
  1777         """Convenience method to call repo[x].status()."""
  1681 
  1778 
  1682     def addpostdsstatus(ps):
  1779     def addpostdsstatus(ps):
  1683         pass
  1780         pass
  1684 
  1781 
  1701         pass
  1798         pass
  1702 
  1799 
  1703     def checkpush(pushop):
  1800     def checkpush(pushop):
  1704         pass
  1801         pass
  1705 
  1802 
  1706     prepushoutgoinghooks = interfaceutil.Attribute(
  1803     prepushoutgoinghooks = interfaceutil.Attribute("""util.hooks instance.""")
  1707         """util.hooks instance.""")
       
  1708 
  1804 
  1709     def pushkey(namespace, key, old, new):
  1805     def pushkey(namespace, key, old, new):
  1710         pass
  1806         pass
  1711 
  1807 
  1712     def listkeys(namespace):
  1808     def listkeys(namespace):
  1716         pass
  1812         pass
  1717 
  1813 
  1718     def savecommitmessage(text):
  1814     def savecommitmessage(text):
  1719         pass
  1815         pass
  1720 
  1816 
  1721 class completelocalrepository(ilocalrepositorymain,
  1817 
  1722                               ilocalrepositoryfilestorage):
  1818 class completelocalrepository(
       
  1819     ilocalrepositorymain, ilocalrepositoryfilestorage
       
  1820 ):
  1723     """Complete interface for a local repository."""
  1821     """Complete interface for a local repository."""
       
  1822 
  1724 
  1823 
  1725 class iwireprotocolcommandcacher(interfaceutil.Interface):
  1824 class iwireprotocolcommandcacher(interfaceutil.Interface):
  1726     """Represents a caching backend for wire protocol commands.
  1825     """Represents a caching backend for wire protocol commands.
  1727 
  1826 
  1728     Wire protocol version 2 supports transparent caching of many commands.
  1827     Wire protocol version 2 supports transparent caching of many commands.
  1802     the output layer, it will need to be encoded there as well. For large
  1901     the output layer, it will need to be encoded there as well. For large
  1803     output, this redundant encoding could add overhead. Implementations
  1902     output, this redundant encoding could add overhead. Implementations
  1804     could wrap the encoded object data in ``wireprototypes.encodedresponse``
  1903     could wrap the encoded object data in ``wireprototypes.encodedresponse``
  1805     instances to avoid this overhead.
  1904     instances to avoid this overhead.
  1806     """
  1905     """
       
  1906 
  1807     def __enter__():
  1907     def __enter__():
  1808         """Marks the instance as active.
  1908         """Marks the instance as active.
  1809 
  1909 
  1810         Should return self.
  1910         Should return self.
  1811         """
  1911         """