mercurial/interfaces/dirstate.py
author Cédric Krier <ced@b2ck.com>
Sat, 17 Jul 2021 12:47:07 +0200
changeset 47657 1bad89a67745
parent 47539 84391ddf4c78
child 47909 f89ac1ed2bc6
permissions -rw-r--r--
testing: do not stop waiting if timeout is 0 (issue6541) Differential Revision: https://phab.mercurial-scm.org/D11102
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
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
     5
from . import util as interfaceutil
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
     6
42927
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
class idirstate(interfaceutil.Interface):
47280
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
     9
    def __init__(
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    10
        opener,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    11
        ui,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    12
        root,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    13
        validate,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    14
        sparsematchfn,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    15
        nodeconstants,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    16
        use_dirstate_v2,
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47012
diff changeset
    17
    ):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    18
        """Create a new dirstate object.
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    19
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
        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
    21
        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
    22
        the dirstate.
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    23
        """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    25
    # TODO: all these private methods and attributes should be made
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    26
    # public or removed from the interface.
43008
5f8b6617e962 interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42929
diff changeset
    27
    _ignore = interfaceutil.Attribute("""Matcher for ignored files.""")
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    28
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    29
    def _ignorefiles():
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    30
        """Return a list of files containing patterns to ignore."""
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    31
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    32
    def _ignorefileandline(f):
43787
be8552f25cab cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents: 43077
diff changeset
    33
        """Given a file `f`, return the ignore file and line that ignores it."""
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    34
43008
5f8b6617e962 interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42929
diff changeset
    35
    _checklink = interfaceutil.Attribute("""Callable for checking symlinks.""")
5f8b6617e962 interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42929
diff changeset
    36
    _checkexec = interfaceutil.Attribute("""Callable for checking exec bits.""")
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
    37
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
    @contextlib.contextmanager
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
    def parentchange():
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    40
        """Context manager for handling dirstate parents.
42927
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
        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
    43
        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
    44
        released.
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    45
        """
42927
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
    def pendingparentchange():
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    48
        """Returns true if the dirstate is in the middle of a set of changes
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
        that modify the dirstate parent.
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    50
        """
42927
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 hasdir(d):
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 flagfunc(buildfallback):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
        pass
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
    def getcwd():
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    59
        """Return the path from which a canonical path is calculated.
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    61
        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
    62
        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
    63
        used to get real file paths. Use vfs functions instead.
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    64
        """
42927
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 pathto(f, cwd=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    67
        pass
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
    def __getitem__(key):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    70
        """Return the current state of key (a filename) in the dirstate.
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    71
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    72
        States are:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    73
          n  normal
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    74
          m  needs merging
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    75
          r  marked for removal
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    76
          a  marked for addition
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    77
          ?  not tracked
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
    78
        """
42927
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 __contains__(key):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    81
        """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
    82
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    83
    def __iter__():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    84
        """Iterate the dirstate's contained filenames as bytestrings."""
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
    def items():
47539
84391ddf4c78 dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47280
diff changeset
    87
        """Iterate the dirstate's entries as (filename, DirstateItem.
42927
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
        As usual, filename is a bytestring.
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
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
    92
    iteritems = items
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 parents():
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 p1():
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 p2():
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 branch():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
        pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
47012
d55b71393907 node: replace nullid and friends with nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46780
diff changeset
   106
    def setparents(p1, p2=None):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
        """Set dirstate parents to p1 and p2.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   109
        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
   110
        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
   111
        returned by the call.
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
        See localrepo.setparents()
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   114
        """
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 setbranch(branch):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
        pass
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
    def invalidate():
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   120
        """Causes the next access to reread the dirstate.
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   121
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   122
        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
   123
        rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   124
        check whether the dirstate has changed before rereading it."""
42927
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 copy(source, dest):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   127
        """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
   128
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   129
    def copied(file):
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 copies():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
        pass
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
    def normal(f, parentfiledata=None):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   136
        """Mark a file normal and clean.
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
        parentfiledata: (mode, size, mtime) of the clean file
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
        parentfiledata should be computed from memory (for mode,
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
        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
   142
        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
   143
        file having been changed by an external process between the
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   144
        moment where the file was determined to be clean and now."""
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   145
        pass
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 normallookup(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   148
        '''Mark a file normal, but possibly 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 otherparent(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   151
        '''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
   152
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   153
    def add(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   154
        '''Mark a file added.'''
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 remove(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   157
        '''Mark a file removed.'''
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 merge(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   160
        '''Mark a file merged.'''
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 drop(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   163
        '''Drop a file from the dirstate'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   164
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   165
    def normalize(path, isknown=False, ignoremissing=False):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   166
        """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   167
        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
   168
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   169
        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
   170
        disk, to avoid extra filesystem access.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   171
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   172
        If ignoremissing is True, missing path are returned
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   173
        unchanged. Otherwise, we try harder to normalize possibly
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   174
        existing path components.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   175
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   176
        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
   177
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   178
        - version of name already stored in the dirstate
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   179
        - version of name stored on disk
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   180
        - version provided via command arguments
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   181
        """
42927
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 clear():
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 rebuild(parent, allfiles, changedfiles=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   187
        pass
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
    def identity():
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   190
        """Return identity of dirstate it to detect changing in storage
42927
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
        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
   193
        changes based on the former dirstate out can keep consistency.
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   194
        """
42927
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 write(tr):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   197
        pass
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
    def addparentchangecallback(category, callback):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   200
        """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
   201
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   202
        Callback will be called with the following arguments:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   203
            dirstate, (oldp1, oldp2), (newp1, newp2)
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
        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
   206
        with a newer callback.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   207
        """
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
    def walk(match, subrepos, unknown, ignored, full=True):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   210
        """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   211
        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
   212
        matched by match.
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
        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
   215
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   216
        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
   217
        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
   218
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   219
        """
42927
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
    def status(match, subrepos, ignored, clean, unknown):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   222
        """Determine the status of the working copy relative to the
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   223
        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
   224
        scmutil.status and:
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
          unsure:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   227
            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
   228
            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
   229
            but mtime differs)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   230
          status.modified:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   231
            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
   232
            was written (different size or mode)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   233
          status.clean:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   234
            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
   235
            dirstate was written
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   236
        """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   237
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   238
    def matches(match):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   239
        """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   240
        return files in the dirstate (in whatever state) filtered by match
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
   241
        """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   242
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   243
    def savebackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   244
        '''Save current dirstate into backup file'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   245
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   246
    def restorebackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   247
        '''Restore dirstate by backup file'''
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
    def clearbackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
   250
        '''Clear backup file'''