Mercurial > hg
comparison mercurial/dirstate.py @ 35078:a052022639cc
dirstate: document dirstatemap interface
Differential Revision: https://phab.mercurial-scm.org/D1380
author | Mark Thomas <mbthomas@fb.com> |
---|---|
date | Wed, 15 Nov 2017 01:07:42 -0800 |
parents | 1664dc7ccd8a |
children | 853b7c41d19c |
comparison
equal
deleted
inserted
replaced
35077:cd4cd7b94ff1 | 35078:a052022639cc |
---|---|
125 ''' | 125 ''' |
126 return self._parentwriters > 0 | 126 return self._parentwriters > 0 |
127 | 127 |
128 @propertycache | 128 @propertycache |
129 def _map(self): | 129 def _map(self): |
130 '''Return the dirstate contents as a map from filename to | 130 """Return the dirstate contents (see documentation for dirstatemap).""" |
131 (state, mode, size, time).''' | |
132 self._map = dirstatemap(self._ui, self._opener, self._root) | 131 self._map = dirstatemap(self._ui, self._opener, self._root) |
133 return self._map | 132 return self._map |
134 | 133 |
135 @property | 134 @property |
136 def _sparsematcher(self): | 135 def _sparsematcher(self): |
1194 def clearbackup(self, tr, backupname): | 1193 def clearbackup(self, tr, backupname): |
1195 '''Clear backup file''' | 1194 '''Clear backup file''' |
1196 self._opener.unlink(backupname) | 1195 self._opener.unlink(backupname) |
1197 | 1196 |
1198 class dirstatemap(object): | 1197 class dirstatemap(object): |
1198 """Map encapsulating the dirstate's contents. | |
1199 | |
1200 The dirstate contains the following state: | |
1201 | |
1202 - `identity` is the identity of the dirstate file, which can be used to | |
1203 detect when changes have occurred to the dirstate file. | |
1204 | |
1205 - `parents` is a pair containing the parents of the working copy. The | |
1206 parents are updated by calling `setparents`. | |
1207 | |
1208 - the state map maps filenames to tuples of (state, mode, size, mtime), | |
1209 where state is a single character representing 'normal', 'added', | |
1210 'removed', or 'merged'. It is accessed by treating the dirstate as a | |
1211 dict. | |
1212 | |
1213 - `copymap` maps destination filenames to their source filename. | |
1214 | |
1215 The dirstate also provides the following views onto the state: | |
1216 | |
1217 - `nonnormalset` is a set of the filenames that have state other | |
1218 than 'normal', or are normal but have an mtime of -1 ('normallookup'). | |
1219 | |
1220 - `otherparentset` is a set of the filenames that are marked as coming | |
1221 from the second parent when the dirstate is currently being merged. | |
1222 | |
1223 - `dirs` is a set-like object containing all the directories that contain | |
1224 files in the dirstate, excluding any files that are marked as removed. | |
1225 | |
1226 - `filefoldmap` is a dict mapping normalized filenames to the denormalized | |
1227 form that they appear as in the dirstate. | |
1228 | |
1229 - `dirfoldmap` is a dict mapping normalized directory names to the | |
1230 denormalized form that they appear as in the dirstate. | |
1231 | |
1232 Once instantiated, the nonnormalset, otherparentset, dirs, filefoldmap and | |
1233 dirfoldmap views must be maintained by the caller. | |
1234 """ | |
1235 | |
1199 def __init__(self, ui, opener, root): | 1236 def __init__(self, ui, opener, root): |
1200 self._ui = ui | 1237 self._ui = ui |
1201 self._opener = opener | 1238 self._opener = opener |
1202 self._root = root | 1239 self._root = root |
1203 self._filename = 'dirstate' | 1240 self._filename = 'dirstate' |