annotate mercurial/interfaces/dirstate.py @ 45279:f4a2b329717b

merge: move conversion of file-key dict to action-key dict in mergeresult Initially the actions dict which we get has file has keys, but later we want a dict which has actions as keys. This patch moves code computing that to mergeresult class as that's where it should be anyway. Differential Revision: https://phab.mercurial-scm.org/D8817
author Pulkit Goyal <7895pulkit@gmail.com>
date Fri, 24 Jul 2020 14:45:00 +0530
parents be8552f25cab
children 89a2afe31e82
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
1 from __future__ import absolute_import, print_function
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
2
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
3 import contextlib
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
4
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
5 from .. import node as nodemod
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
6
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
7 from . import util as interfaceutil
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43008
diff changeset
8
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
9
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
10 class idirstate(interfaceutil.Interface):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
11 def __init__(opener, ui, root, validate, sparsematchfn):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
12 '''Create a new dirstate object.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
13
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
14 opener is an open()-like callable that can be used to open the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
15 dirstate file; root is the root of the directory tracked by
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
16 the dirstate.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
17 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
18
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
19 # 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
20 # 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
21 _ignore = interfaceutil.Attribute("""Matcher for ignored files.""")
42929
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
22
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
23 def _ignorefiles():
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
24 """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
25
97b79354e9f0 idirstate: group private methods and attrs that are in the interface
Augie Fackler <augie@google.com>
parents: 42928
diff changeset
26 def _ignorefileandline(f):
43787
be8552f25cab cleanup: fix docstring formatting
Matt Harbison <matt_harbison@yahoo.com>
parents: 43077
diff changeset
27 """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
28
43008
5f8b6617e962 interfaces: use triple quotes for Attribute value
Gregory Szorc <gregory.szorc@gmail.com>
parents: 42929
diff changeset
29 _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
30 _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
31
42927
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
32 @contextlib.contextmanager
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
33 def parentchange():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
34 '''Context manager for handling dirstate parents.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
35
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
36 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
37 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
38 released.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
39 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
40
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
41 def pendingparentchange():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
42 '''Returns true if the dirstate is in the middle of a set of changes
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
43 that modify the dirstate parent.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
44 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
45
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
46 def hasdir(d):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
47 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
48
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
49 def flagfunc(buildfallback):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
50 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
51
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
52 def getcwd():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
53 '''Return the path from which a canonical path is calculated.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
54
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
55 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
56 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
57 used to get real file paths. Use vfs functions instead.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
58 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
59
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
60 def pathto(f, cwd=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
61 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
62
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
63 def __getitem__(key):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
64 '''Return the current state of key (a filename) in the dirstate.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
65
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
66 States are:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
67 n normal
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
68 m needs merging
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
69 r marked for removal
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
70 a marked for addition
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
71 ? not tracked
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
72 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
73
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
74 def __contains__(key):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
75 """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
76
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
77 def __iter__():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
78 """Iterate the dirstate's contained filenames as bytestrings."""
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
79
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
80 def items():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
81 """Iterate the dirstate's entries as (filename, dirstatetuple).
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
82
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
83 As usual, filename is a bytestring.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
84 """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
85
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
86 iteritems = items
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
87
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
88 def parents():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
89 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
90
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
91 def p1():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
92 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
93
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
94 def p2():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
95 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
96
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
97 def branch():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
98 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
99
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
100 def setparents(p1, p2=nodemod.nullid):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
101 """Set dirstate parents to p1 and p2.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
102
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
103 When moving from two parents to one, 'm' merged entries a
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
104 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
105 returned by the call.
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 See localrepo.setparents()
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 def setbranch(branch):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
111 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
112
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
113 def invalidate():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
114 '''Causes the next access to reread the dirstate.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
115
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
116 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
117 rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
118 check whether the dirstate has changed before rereading it.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
119
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
120 def copy(source, dest):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
121 """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
122
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
123 def copied(file):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
124 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
125
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
126 def copies():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
127 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
128
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
129 def normal(f, parentfiledata=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
130 '''Mark a file normal and clean.
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 parentfiledata: (mode, size, mtime) of the clean file
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 parentfiledata should be computed from memory (for mode,
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
135 size), as or close as possible from the point where we
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
136 determined the file was clean, to limit the risk of the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
137 file having been changed by an external process between the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
138 moment where the file was determined to be clean and now.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
139 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
140
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
141 def normallookup(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
142 '''Mark a file normal, but possibly dirty.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
143
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
144 def otherparent(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
145 '''Mark as coming from the other parent, always dirty.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
146
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
147 def add(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
148 '''Mark a file added.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
149
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
150 def remove(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
151 '''Mark a file removed.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
152
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
153 def merge(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
154 '''Mark a file merged.'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
155
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
156 def drop(f):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
157 '''Drop a file from the dirstate'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
158
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
159 def normalize(path, isknown=False, ignoremissing=False):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
160 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
161 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
162
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
163 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
164 disk, to avoid extra filesystem access.
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 If ignoremissing is True, missing path are returned
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
167 unchanged. Otherwise, we try harder to normalize possibly
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
168 existing path components.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
169
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
170 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
171
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
172 - version of name already stored in the dirstate
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
173 - version of name stored on disk
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
174 - version provided via command arguments
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
175 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
176
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
177 def clear():
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
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
180 def rebuild(parent, allfiles, changedfiles=None):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
181 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
182
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
183 def identity():
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
184 '''Return identity of dirstate it to detect changing in storage
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
185
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
186 If identity of previous dirstate is equal to this, writing
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
187 changes based on the former dirstate out can keep consistency.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
188 '''
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 def write(tr):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
191 pass
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
192
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
193 def addparentchangecallback(category, callback):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
194 """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
195
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
196 Callback will be called with the following arguments:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
197 dirstate, (oldp1, oldp2), (newp1, newp2)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
198
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
199 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
200 with a newer callback.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
201 """
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
202
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
203 def walk(match, subrepos, unknown, ignored, full=True):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
204 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
205 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
206 matched by match.
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
207
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
208 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
209
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
210 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
211 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
212
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
213 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
214
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
215 def status(match, subrepos, ignored, clean, unknown):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
216 '''Determine the status of the working copy relative to the
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
217 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
218 scmutil.status and:
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 unsure:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
221 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
222 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
223 but mtime differs)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
224 status.modified:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
225 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
226 was written (different size or mode)
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
227 status.clean:
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
228 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
229 dirstate was written
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
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
232 def matches(match):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
233 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
234 return files in the dirstate (in whatever state) filtered by match
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
235 '''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
236
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
237 def savebackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
238 '''Save current dirstate into backup file'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
239
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
240 def restorebackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
241 '''Restore dirstate by backup file'''
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
242
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
243 def clearbackup(tr, backupname):
d459cd8ea42d interfaces: introduce an interface for dirstate implementations
Augie Fackler <augie@google.com>
parents:
diff changeset
244 '''Clear backup file'''