Mercurial > public > mercurial-scm > hg
annotate mercurial/interfaces/dirstate.py @ 51924:3688a984134b
interfaces: change a couple of dirstate fields to `@property`
As I was adding type hints here and to the concrete classes, PyCharm flagged the
property in the core class as not being compatible with the base class's
version.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 27 Sep 2024 12:10:25 -0400 |
parents | b455dfddfed0 |
children | 93d872a06132 |
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 |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
4 import typing |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 |
51917
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
6 from typing import ( |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
7 Callable, |
51917
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
8 Protocol, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
9 ) |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
10 |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
11 if typing.TYPE_CHECKING: |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
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:
51918
diff
changeset
|
13 # to avoid circular imports |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
14 from .. import ( |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
15 match as matchmod, |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
16 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43008
diff
changeset
|
17 |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 |
51917
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
19 class idirstate(Protocol): |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
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:
51859
diff
changeset
|
21 # def __init__( |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
22 # self, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
23 # opener, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
24 # ui, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
25 # root, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
26 # validate, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
27 # sparsematchfn, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
28 # nodeconstants, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
29 # use_dirstate_v2, |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
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:
51859
diff
changeset
|
31 # ): |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
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:
51859
diff
changeset
|
33 # |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
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:
51859
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:
51859
diff
changeset
|
36 # the dirstate. |
382d9629cede
interfaces: convert the dirstate zope interface to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51859
diff
changeset
|
37 # """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
38 |
42929
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42928
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:
42928
diff
changeset
|
40 # public or removed from the interface. |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
41 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
42 # TODO: decorate with `@rootcache(b'.hgignore')` like dirstate class? |
51924
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
43 @property |
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
44 def _ignore(self) -> matchmod.basematcher: |
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
45 """Matcher for ignored files.""" |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
46 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
47 @property |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
48 def is_changing_any(self) -> bool: |
50023
e1cff85484e2
dirstate: introduce a `is_changing_any` property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50022
diff
changeset
|
49 """True if any changes in progress.""" |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
50 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
51 @property |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
52 def is_changing_parents(self) -> bool: |
50022
e333cc169c45
dirstate: rename `pendingparentchange` to `is_changing_parents`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49961
diff
changeset
|
53 """True if parents changes in progress.""" |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
54 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
55 @property |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
56 def is_changing_files(self) -> bool: |
50026
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
57 """True if file tracking changes in progress.""" |
42929
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42928
diff
changeset
|
58 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
59 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
|
60 """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
|
61 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
62 def _ignorefileandline(self, f): |
43787
be8552f25cab
cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents:
43077
diff
changeset
|
63 """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
|
64 |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
65 # 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:
51918
diff
changeset
|
66 # (can't because circular import) |
51924
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
67 @property |
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
68 def _checklink(self) -> bool: |
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
69 """Callable for checking symlinks.""" # TODO: this comment looks stale |
51919
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
diff
changeset
|
70 |
b455dfddfed0
interfaces: convert the zope `Attribute` attrs to regular fields
Matt Harbison <matt_harbison@yahoo.com>
parents:
51918
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:
51918
diff
changeset
|
72 # (can't because circular import) |
51924
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
73 @property |
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
74 def _checkexec(self) -> bool: |
3688a984134b
interfaces: change a couple of dirstate fields to `@property`
Matt Harbison <matt_harbison@yahoo.com>
parents:
51919
diff
changeset
|
75 """Callable for checking exec bits.""" # TODO: this comment looks stale |
42929
97b79354e9f0
idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents:
42928
diff
changeset
|
76 |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
77 @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
|
78 def changing_parents(self, repo): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
79 """Context manager for handling dirstate parents. |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
80 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
81 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
|
82 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
|
83 released. |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
84 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
85 |
50026
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
86 @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
|
87 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
|
88 """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
|
89 |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
90 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
|
91 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
|
92 released. |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
diff
changeset
|
93 """ |
3550e4a88ccd
dirstate: add a context for tracking files change
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50023
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 hasdir(self, d): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
96 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
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 flagfunc(self, buildfallback): |
49880
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49076
diff
changeset
|
99 """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
|
100 |
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49076
diff
changeset
|
101 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
|
102 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
|
103 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
|
104 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
|
105 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
106 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
107 def getcwd(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
108 """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
|
109 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 """ |
42927
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 pathto(self, f, cwd=None): |
49881
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49880
diff
changeset
|
116 pass |
b3ae17037b54
dirstate: swap pathto() and get_entry() in idirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49880
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 get_entry(self, path): |
49076
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48875
diff
changeset
|
119 """return a DirstateItem for the associated path""" |
9c8d67a3af5e
idirstate: add missing get_entry() method
Matt Harbison <matt_harbison@yahoo.com>
parents:
48875
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 __contains__(self, key): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 """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
|
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 __iter__(self): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 """Iterate the dirstate's contained filenames as bytestrings.""" |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
127 def items(self): |
47539
84391ddf4c78
dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47280
diff
changeset
|
128 """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
|
129 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
130 As usual, filename is a bytestring. |
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 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
133 iteritems = items |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
134 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
135 def parents(self): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
136 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
137 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
138 def p1(self): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
139 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
140 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
141 def p2(self): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 |
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 branch(self): |
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 |
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 setparents(self, p1, p2=None): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
148 """Set dirstate parents to p1 and p2. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
149 |
49880
9ea66d166ec7
dirstate: update docstrings in idirstate from the current dirstate
Anton Shestakov <av6@dwimlabs.net>
parents:
49076
diff
changeset
|
150 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
|
151 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
|
152 returned by the call. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
153 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
154 See localrepo.setparents() |
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 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
157 def setbranch(self, branch, transaction): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
158 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
160 def invalidate(self): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
161 """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
|
162 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
167 def copy(self, source, dest): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
168 """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
|
169 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
170 def copied(self, file): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
171 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
173 def copies(self): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
174 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
176 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
|
177 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
178 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
|
179 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 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
|
181 disk, to avoid extra filesystem access. |
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 If ignoremissing is True, missing path are returned |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
184 unchanged. Otherwise, we try harder to normalize possibly |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 existing path components. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
187 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
|
188 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
189 - version of name already stored in the dirstate |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 - version of name stored on disk |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 - version provided via command arguments |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
192 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
193 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
194 def clear(self): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
195 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
197 def rebuild(self, parent, allfiles, changedfiles=None): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
198 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
200 def write(self, tr): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
201 pass |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
203 def addparentchangecallback(self, category, callback): |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 """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
|
205 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 Callback will be called with the following arguments: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 dirstate, (oldp1, oldp2), (newp1, newp2) |
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 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
|
210 with a newer callback. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 """ |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
213 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
|
214 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 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
|
216 matched by match. |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
217 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 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
|
219 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 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
|
221 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
|
222 |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
223 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
224 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
225 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
|
226 """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
|
227 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
|
228 scmutil.status and: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
229 |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 unsure: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 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
|
232 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
|
233 but mtime differs) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
234 status.modified: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 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
|
236 was written (different size or mode) |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 status.clean: |
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 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
|
239 dirstate was written |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
240 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
241 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
242 def matches(self, match): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
43787
diff
changeset
|
243 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
244 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
|
245 """ |
42927
d459cd8ea42d
interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
246 |
51918
13aa17512583
interfaces: add the missing `self` arg to the dirstate Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents:
51917
diff
changeset
|
247 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
|
248 """ |
8c7895db8955
dirstate: add missing methods and kwargs to idirstate interface
Anton Shestakov <av6@dwimlabs.net>
parents:
49881
diff
changeset
|
249 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
|
250 """ |