mercurial/interfaces/dirstate.py
author Augie Fackler <augie@google.com>
Tue, 10 Sep 2019 09:21:38 -0400
changeset 42927 d459cd8ea42d
child 42928 bbd154627a72
permissions -rw-r--r--
interfaces: introduce an interface for dirstate implementations As usual with adding interface definitions, this describes the way things are, not the way we'd like things to be. There are some clear problems in the interface right now (eg ._map leaks in a few places), but I have plans to clean those up. There are also many missing docstrings, but again, we'll make a second pass to clean that up. Differential Revision: https://phab.mercurial-scm.org/D6836
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
from __future__ import absolute_import, print_function
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
import contextlib
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
from .. import (
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
    node as nodemod,
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     8
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
     9
from . import (
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    10
    util as interfaceutil,
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    11
)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    12
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    13
class idirstate(interfaceutil.Interface):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    14
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    15
    def __init__(opener, ui, root, validate, sparsematchfn):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    16
        '''Create a new dirstate object.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    17
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    18
        opener is an open()-like callable that can be used to open the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
        dirstate file; root is the root of the directory tracked by
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
        the dirstate.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    23
    @contextlib.contextmanager
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
    def parentchange():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    25
        '''Context manager for handling dirstate parents.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    26
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
        If an exception occurs in the scope of the context manager,
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    28
        the incoherent dirstate won't be written when wlock is
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
        released.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    30
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    32
    def pendingparentchange():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
        '''Returns true if the dirstate is in the middle of a set of changes
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
        that modify the dirstate parent.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    35
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    37
    _map = interfaceutil.Attribute(
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
        """Return the dirstate contents (see documentation for dirstatemap).
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    40
        TODO this should not be exposed.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
        """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
        )
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    43
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
    def hasdir(d):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    45
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    46
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    47
    _ignore = interfaceutil.Attribute('Matcher for ignored files.')
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
    _checklink = interfaceutil.Attribute('Callable for checking symlinks.')
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    50
    _checkexec = interfaceutil.Attribute('Callable for checking exec bits.')
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    51
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    52
    def flagfunc(buildfallback):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    53
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    54
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    55
    def getcwd():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
        '''Return the path from which a canonical path is calculated.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    58
        This path should be used to resolve file patterns or to convert
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    59
        canonical paths back to file paths for display. It shouldn't be
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
        used to get real file paths. Use vfs functions instead.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    61
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    62
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    63
    def pathto(f, cwd=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    64
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    65
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    66
    def __getitem__(key):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    67
        '''Return the current state of key (a filename) in the dirstate.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    68
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    69
        States are:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    70
          n  normal
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    71
          m  needs merging
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    72
          r  marked for removal
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    73
          a  marked for addition
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    74
          ?  not tracked
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    75
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    76
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    77
    def __contains__(key):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    78
        """Check if bytestring `key` is known to the dirstate."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    79
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    80
    def __iter__():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    81
        """Iterate the dirstate's contained filenames as bytestrings."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    82
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    83
    def items():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    84
        """Iterate the dirstate's entries as (filename, dirstatetuple).
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    85
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    86
        As usual, filename is a bytestring.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    87
        """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    88
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    89
    iteritems = items
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    90
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    91
    def parents():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    92
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    93
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    94
    def p1():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    95
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    96
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    97
    def p2():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    98
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    99
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   100
    def branch():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   101
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   102
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   103
    def setparents(p1, p2=nodemod.nullid):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
        """Set dirstate parents to p1 and p2.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   106
        When moving from two parents to one, 'm' merged entries a
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
        adjusted to normal and previous copy records discarded and
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
        returned by the call.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   109
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   110
        See localrepo.setparents()
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   111
        """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   112
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   113
    def setbranch(branch):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   114
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   115
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   116
    def invalidate():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
        '''Causes the next access to reread the dirstate.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   118
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   119
        This is different from localrepo.invalidatedirstate() because it always
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   120
        rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   121
        check whether the dirstate has changed before rereading it.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   122
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   123
    def copy(source, dest):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   124
        """Mark dest as a copy of source. Unmark dest if source is None."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   125
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   126
    def copied(file):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   127
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   128
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   129
    def copies():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   130
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   131
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   132
    def normal(f, parentfiledata=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
        '''Mark a file normal and clean.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   134
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   135
        parentfiledata: (mode, size, mtime) of the clean file
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   136
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
        parentfiledata should be computed from memory (for mode,
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
        size), as or close as possible from the point where we
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
        determined the file was clean, to limit the risk of the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
        file having been changed by an external process between the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
        moment where the file was determined to be clean and now.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   142
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   143
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   144
    def normallookup(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   145
        '''Mark a file normal, but possibly dirty.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   146
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   147
    def otherparent(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   148
        '''Mark as coming from the other parent, always dirty.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   149
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   150
    def add(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   151
        '''Mark a file added.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   152
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   153
    def remove(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   154
        '''Mark a file removed.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   155
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   156
    def merge(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   157
        '''Mark a file merged.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   158
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   159
    def drop(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   160
        '''Drop a file from the dirstate'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   161
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   162
    def normalize(path, isknown=False, ignoremissing=False):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   163
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   164
        normalize the case of a pathname when on a casefolding filesystem
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   165
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   166
        isknown specifies whether the filename came from walking the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   167
        disk, to avoid extra filesystem access.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   168
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   169
        If ignoremissing is True, missing path are returned
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   170
        unchanged. Otherwise, we try harder to normalize possibly
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   171
        existing path components.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   172
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   173
        The normalized case is determined based on the following precedence:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   174
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   175
        - version of name already stored in the dirstate
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   176
        - version of name stored on disk
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   177
        - version provided via command arguments
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   178
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   179
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   180
    def clear():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   181
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   182
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   183
    def rebuild(parent, allfiles, changedfiles=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   184
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   185
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   186
    def identity():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   187
        '''Return identity of dirstate it to detect changing in storage
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   188
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   189
        If identity of previous dirstate is equal to this, writing
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   190
        changes based on the former dirstate out can keep consistency.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   191
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   192
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   193
    def write(tr):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   194
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   195
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   196
    def addparentchangecallback(category, callback):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   197
        """add a callback to be called when the wd parents are changed
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   198
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   199
        Callback will be called with the following arguments:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   200
            dirstate, (oldp1, oldp2), (newp1, newp2)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   201
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   202
        Category is a unique identifier to allow overwriting an old callback
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   203
        with a newer callback.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   204
        """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   205
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   206
    def _ignorefiles():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   207
        """Return a list of files containing patterns to ignore.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   208
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   209
        TODO this should not be exposed."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   210
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   211
    def _ignorefileandline(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   212
        """Given a file `f`, return the ignore file and line that ignores it.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   213
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   214
        TODO this should not be exposed."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   215
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   216
    def walk(match, subrepos, unknown, ignored, full=True):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   217
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   218
        Walk recursively through the directory tree, finding all files
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   219
        matched by match.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   220
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   221
        If full is False, maybe skip some known-clean files.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   222
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   223
        Return a dict mapping filename to stat-like object (either
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   224
        mercurial.osutil.stat instance or return value of os.stat()).
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   225
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   226
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   227
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   228
    def status(match, subrepos, ignored, clean, unknown):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   229
        '''Determine the status of the working copy relative to the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   230
        dirstate and return a pair of (unsure, status), where status is of type
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   231
        scmutil.status and:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   232
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   233
          unsure:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   234
            files that might have been modified since the dirstate was
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   235
            written, but need to be read to be sure (size is the same
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   236
            but mtime differs)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   237
          status.modified:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   238
            files that have definitely been modified since the dirstate
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   239
            was written (different size or mode)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   240
          status.clean:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   241
            files that have definitely not been modified since the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   242
            dirstate was written
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   243
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   244
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   245
    def matches(match):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   246
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   247
        return files in the dirstate (in whatever state) filtered by match
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   248
        '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   249
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   250
    def savebackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   251
        '''Save current dirstate into backup file'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   252
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   253
    def restorebackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   254
        '''Restore dirstate by backup file'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   255
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   256
    def clearbackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   257
        '''Clear backup file'''