annotate mercurial/interfaces/dirstate.py @ 51918:13aa17512583

interfaces: add the missing `self` arg to the dirstate Protocol class This clears all of the errors that PyCharm has been flagging in this file, since the zope interface was declared here.
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 26 Sep 2024 18:09:33 -0400
parents 382d9629cede
children b455dfddfed0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51859
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51270
diff changeset
1 from __future__ import annotations
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51270
diff changeset
2
42927
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
51917
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
5 from typing import (
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
6 Protocol,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
7 )
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
8
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
9 from . import util as interfaceutil
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
10
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
11
51917
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
12 class idirstate(Protocol):
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
13 # TODO: convert these constructor args to fields?
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
14 # def __init__(
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
15 # self,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
16 # opener,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
17 # ui,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
18 # root,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
19 # validate,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
20 # sparsematchfn,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
21 # nodeconstants,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
22 # use_dirstate_v2,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
23 # use_tracked_hint=False,
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
24 # ):
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
25 # """Create a new dirstate object.
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
26 #
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
27 # opener is an open()-like callable that can be used to open the
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
28 # dirstate file; root is the root of the directory tracked by
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
29 # the dirstate.
382d9629cede interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51859
diff changeset
30 # """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
31
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
32 # 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
33 # 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
34 _ignore = interfaceutil.Attribute("""Matcher for ignored files.""")
50023
e1cff85484e2 dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50022
diff changeset
35 is_changing_any = interfaceutil.Attribute(
e1cff85484e2 dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50022
diff changeset
36 """True if any changes in progress."""
e1cff85484e2 dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50022
diff changeset
37 )
50022
e333cc169c45 dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49961
diff changeset
38 is_changing_parents = interfaceutil.Attribute(
e333cc169c45 dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49961
diff changeset
39 """True if parents changes in progress."""
e333cc169c45 dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49961
diff changeset
40 )
50026
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
41 is_changing_files = interfaceutil.Attribute(
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
42 """True if file tracking changes in progress."""
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
43 )
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
44
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
45 def _ignorefiles(self):
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
46 """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
47
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
48 def _ignorefileandline(self, f):
43787
be8552f25cab cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents: 43077
diff changeset
49 """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
50
43008
5f8b6617e962 interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42929
diff changeset
51 _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
52 _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
53
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
54 @contextlib.contextmanager
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
55 def changing_parents(self, repo):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
56 """Context manager for handling dirstate parents.
42927
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 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
59 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
60 released.
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
61 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
62
50026
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
63 @contextlib.contextmanager
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
64 def changing_files(self, repo):
50026
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
65 """Context manager for handling dirstate files.
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
66
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
67 If an exception occurs in the scope of the context manager,
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
68 the incoherent dirstate won't be written when wlock is
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
69 released.
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
70 """
3550e4a88ccd dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50023
diff changeset
71
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
72 def hasdir(self, d):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
73 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
74
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
75 def flagfunc(self, buildfallback):
49880
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
76 """build a callable that returns flags associated with a filename
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
77
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
78 The information is extracted from three possible layers:
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
79 1. the file system if it supports the information
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
80 2. the "fallback" information stored in the dirstate if any
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
81 3. a more expensive mechanism inferring the flags from the parents.
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
82 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
83
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
84 def getcwd(self):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
85 """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
86
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
87 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
88 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
89 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
90 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
91
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
92 def pathto(self, f, cwd=None):
49881
b3ae17037b54 dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49880
diff changeset
93 pass
b3ae17037b54 dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49880
diff changeset
94
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
95 def get_entry(self, path):
49076
9c8d67a3af5e idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents: 48875
diff changeset
96 """return a DirstateItem for the associated path"""
9c8d67a3af5e idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents: 48875
diff changeset
97
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
98 def __contains__(self, key):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
99 """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
100
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
101 def __iter__(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
102 """Iterate the dirstate's contained filenames as bytestrings."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
103
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
104 def items(self):
47539
84391ddf4c78 dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47280
diff changeset
105 """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
106
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
107 As usual, filename is a bytestring.
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
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
110 iteritems = items
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
111
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
112 def parents(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
113 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
114
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
115 def p1(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
116 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
117
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
118 def p2(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
119 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
120
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
121 def branch(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
122 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
123
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
124 def setparents(self, p1, p2=None):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
125 """Set dirstate parents to p1 and p2.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
126
49880
9ea66d166ec7 dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents: 49076
diff changeset
127 When moving from two parents to one, "merged" entries a
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
128 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
129 returned by the call.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
130
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
131 See localrepo.setparents()
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
132 """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
133
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
134 def setbranch(self, branch, transaction):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
135 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
136
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
137 def invalidate(self):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
138 """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
139
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
140 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
141 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
142 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
143
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
144 def copy(self, source, dest):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
145 """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
146
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
147 def copied(self, file):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
148 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
149
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
150 def copies(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
151 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
152
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
153 def normalize(self, path, isknown=False, ignoremissing=False):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
154 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
155 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
156
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
157 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
158 disk, to avoid extra filesystem access.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
159
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
160 If ignoremissing is True, missing path are returned
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
161 unchanged. Otherwise, we try harder to normalize possibly
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
162 existing path components.
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 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
165
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
166 - version of name already stored in the dirstate
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
167 - version of name stored on disk
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
168 - version provided via command arguments
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
169 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
170
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
171 def clear(self):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
172 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
173
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
174 def rebuild(self, parent, allfiles, changedfiles=None):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
175 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
176
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
177 def write(self, tr):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
178 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
179
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
180 def addparentchangecallback(self, category, callback):
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
181 """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
182
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
183 Callback will be called with the following arguments:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
184 dirstate, (oldp1, oldp2), (newp1, newp2)
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 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
187 with a newer callback.
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
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
190 def walk(self, match, subrepos, unknown, ignored, full=True):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
191 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
192 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
193 matched by match.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
194
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
195 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
196
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
197 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
198 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
199
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
200 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
201
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
202 def status(self, match, subrepos, ignored, clean, unknown):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
203 """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
204 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
205 scmutil.status and:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
206
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
207 unsure:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
208 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
209 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
210 but mtime differs)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
211 status.modified:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
212 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
213 was written (different size or mode)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
214 status.clean:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
215 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
216 dirstate was written
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
217 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
218
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
219 def matches(self, match):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43787
diff changeset
220 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
221 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
222 """
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
223
51918
13aa17512583 interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 51917
diff changeset
224 def verify(self, m1, m2, p1, narrow_matcher=None):
49882
8c7895db8955 dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents: 49881
diff changeset
225 """
8c7895db8955 dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents: 49881
diff changeset
226 check the dirstate contents against the parent manifest and yield errors
8c7895db8955 dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents: 49881
diff changeset
227 """