Mercurial > public > mercurial-scm > hg-stable
annotate mercurial/interfaces/dirstate.py @ 51959:b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
At this point, we should have a useful protocol class.
The file syntax requires the type to be supplied for any fields that are
declared, but we'll leave the complex ones partially unspecified for now, for
simplicity. (Also, the things documented as `Callable` are really as future
type annotating worked showed- roll with it for now, but they're marked as TODO
for fixing later.) All of the fields and all of the attrs will need type
annotations, or the type rules say they are considered to be `Any`. That can be
done in a separate pass, possibly applying the `dirstate.pyi` file generated
from the concrete class.
The first cut of this turned the `interfaceutil.Attribute` fields into plain
fields, and thus the types on them. PyCharm flagged a few things as having
incompatible signatures when the concrete dirstate class subclassed this, when
the concrete class has them declared as `@property`. So they've been changed to
`@property` here in those cases. The remaining fields that are decorated in the
concrete class have comments noting the differences. We'll see if they need to
be changed going forward, but leave them for now. We'll be in trouble if the
`@util.propertycache` is needed, because we can't import that module here at
runtime, due to circular imports.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 26 Sep 2024 18:15:36 -0400 |
parents | 13aa17512583 |
children | 3688a984134b |
rev | line source |
---|---|
51901
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51293
diff
changeset
|
1 from __future__ import annotations |
f4733654f144
typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents:
51293
diff
changeset
|
2 |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 import contextlib |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
4 import typing |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
51957
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
6 from typing import ( |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
7 Callable, |
51957
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
8 Protocol, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
9 ) |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
10 |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
11 if typing.TYPE_CHECKING: |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
12 # Almost all mercurial modules are only imported in the type checking phase |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
13 # to avoid circular imports |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
14 from .. import ( |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
15 match as matchmod, |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
16 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43010
diff
changeset
|
17 |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
51957
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
19 class idirstate(Protocol): |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
20 # 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:
51901
diff
changeset
|
21 # def __init__( |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
22 # self, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
23 # opener, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
24 # ui, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
25 # root, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
26 # validate, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
27 # sparsematchfn, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
28 # nodeconstants, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
29 # use_dirstate_v2, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
30 # use_tracked_hint=False, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
31 # ): |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
32 # """Create a new dirstate object. |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
33 # |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
34 # 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:
51901
diff
changeset
|
35 # 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:
51901
diff
changeset
|
36 # the dirstate. |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51901
diff
changeset
|
37 # """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
39 # 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:
42932
diff
changeset
|
40 # public or removed from the interface. |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
41 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
42 # TODO: decorate with `@rootcache(b'.hgignore')` like dirstate class? |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
43 _ignore: matchmod.basematcher |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
44 """Matcher for ignored files.""" |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
45 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
46 @property |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
47 def is_changing_any(self) -> bool: |
50079
e1cff85484e2
dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50078
diff
changeset
|
48 """True if any changes in progress.""" |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
49 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
50 @property |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
51 def is_changing_parents(self) -> bool: |
50078
e333cc169c45
dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
52 """True if parents changes in progress.""" |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
53 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
54 @property |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
55 def is_changing_files(self) -> bool: |
50082
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
56 """True if file tracking changes in progress.""" |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
57 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
58 def _ignorefiles(self): |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
59 """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:
42932
diff
changeset
|
60 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
61 def _ignorefileandline(self, f): |
43807
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43077
diff
changeset
|
62 """Given a file `f`, return the ignore file and line that ignores it.""" |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
63 |
51959
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
64 # TODO: decorate with `@util.propertycache` like dirstate class? |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
65 # (can't because circular import) |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
66 # TODO: The doc looks wrong- the core class has this as a @property, not a |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
67 # callable. |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
68 _checklink: Callable |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
69 """Callable for checking symlinks.""" |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
70 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
71 # TODO: decorate with `@util.propertycache` like dirstate class? |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
72 # (can't because circular import) |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
73 # TODO: The doc looks wrong- the core class has this as a @property, not a |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
74 # callable. |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
75 _checkexec: Callable |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51958
diff
changeset
|
76 """Callable for checking exec bits.""" |
42933
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42932
diff
changeset
|
77 |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
78 @contextlib.contextmanager |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
79 def changing_parents(self, repo): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
80 """Context manager for handling dirstate parents. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
82 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
|
83 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
|
84 released. |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
85 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
50082
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
87 @contextlib.contextmanager |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
88 def changing_files(self, repo): |
50082
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
89 """Context manager for handling dirstate files. |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
90 |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
91 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:
50079
diff
changeset
|
92 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:
50079
diff
changeset
|
93 released. |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
94 """ |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50079
diff
changeset
|
95 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
96 def hasdir(self, d): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
97 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
98 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
99 def flagfunc(self, buildfallback): |
49959
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
100 """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:
49131
diff
changeset
|
101 |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
102 The information is extracted from three possible layers: |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
103 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:
49131
diff
changeset
|
104 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:
49131
diff
changeset
|
105 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:
49131
diff
changeset
|
106 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
107 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
108 def getcwd(self): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
109 """Return the path from which a canonical path is calculated. |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
110 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
111 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
|
112 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
|
113 used to get real file paths. Use vfs functions instead. |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
114 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
115 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
116 def pathto(self, f, cwd=None): |
49960
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49959
diff
changeset
|
117 pass |
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49959
diff
changeset
|
118 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
119 def get_entry(self, path): |
49131
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48966
diff
changeset
|
120 """return a DirstateItem for the associated path""" |
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48966
diff
changeset
|
121 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
122 def __contains__(self, key): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 """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
|
124 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
125 def __iter__(self): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 """Iterate the dirstate's contained filenames as bytestrings.""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
127 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
128 def items(self): |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47291
diff
changeset
|
129 """Iterate the dirstate's entries as (filename, DirstateItem. |
42931
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 As usual, filename is a bytestring. |
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 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
134 iteritems = items |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
135 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
136 def parents(self): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
138 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
139 def p1(self): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
141 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
142 def p2(self): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
145 def branch(self): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
146 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
147 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
148 def setparents(self, p1, p2=None): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 """Set dirstate parents to p1 and p2. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 |
49959
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49131
diff
changeset
|
151 When moving from two parents to one, "merged" entries a |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 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
|
153 returned by the call. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
155 See localrepo.setparents() |
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 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
158 def setbranch(self, branch, transaction): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
160 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
161 def invalidate(self): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
162 """Causes the next access to reread the dirstate. |
42931
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 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
|
165 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
166 check whether the dirstate has changed before rereading it.""" |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
168 def copy(self, source, dest): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
169 """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
|
170 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
171 def copied(self, file): |
42931
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 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
174 def copies(self): |
42931
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 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
177 def normalize(self, path, isknown=False, ignoremissing=False): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
178 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 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
|
180 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 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
|
182 disk, to avoid extra filesystem access. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
183 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
184 If ignoremissing is True, missing path are returned |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 unchanged. Otherwise, we try harder to normalize possibly |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 existing path components. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
188 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
|
189 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 - version of name already stored in the dirstate |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 - version of name stored on disk |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
192 - version provided via command arguments |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
193 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
194 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
195 def clear(self): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
197 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
198 def rebuild(self, parent, allfiles, changedfiles=None): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
201 def write(self, tr): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
203 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
204 def addparentchangecallback(self, category, callback): |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
205 """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
|
206 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 Callback will be called with the following arguments: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 dirstate, (oldp1, oldp2), (newp1, newp2) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
209 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 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
|
211 with a newer callback. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 """ |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
213 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
214 def walk(self, match, subrepos, unknown, ignored, full=True): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
215 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 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
|
217 matched by match. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
219 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
|
220 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 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
|
222 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
|
223 |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
224 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
225 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
226 def status(self, match, subrepos, ignored, clean, unknown): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
227 """Determine the status of the working copy relative to the |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
228 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
|
229 scmutil.status and: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 unsure: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
232 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
|
233 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
|
234 but mtime differs) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 status.modified: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
236 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
|
237 was written (different size or mode) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 status.clean: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 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
|
240 dirstate was written |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
241 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
243 def matches(self, match): |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
244 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
245 return files in the dirstate (in whatever state) filtered by match |
45957
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43807
diff
changeset
|
246 """ |
42931
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
247 |
51958
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51957
diff
changeset
|
248 def verify(self, m1, m2, p1, narrow_matcher=None): |
49961
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
249 """ |
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49960
diff
changeset
|
250 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:
49960
diff
changeset
|
251 """ |