equal
deleted
inserted
replaced
14 |
14 |
15 from .i18n import _ |
15 from .i18n import _ |
16 from .node import ( |
16 from .node import ( |
17 bin, |
17 bin, |
18 hex, |
18 hex, |
19 nullid, |
|
20 nullrev, |
19 nullrev, |
21 ) |
20 ) |
22 from .pycompat import getattr |
21 from .pycompat import getattr |
23 from . import ( |
22 from . import ( |
24 encoding, |
23 encoding, |
793 @interfaceutil.implementer(repository.imanifestdict) |
792 @interfaceutil.implementer(repository.imanifestdict) |
794 class treemanifest(object): |
793 class treemanifest(object): |
795 def __init__(self, nodeconstants, dir=b'', text=b''): |
794 def __init__(self, nodeconstants, dir=b'', text=b''): |
796 self._dir = dir |
795 self._dir = dir |
797 self.nodeconstants = nodeconstants |
796 self.nodeconstants = nodeconstants |
798 self._node = nullid |
797 self._node = self.nodeconstants.nullid |
799 self._loadfunc = _noop |
798 self._loadfunc = _noop |
800 self._copyfunc = _noop |
799 self._copyfunc = _noop |
801 self._dirty = False |
800 self._dirty = False |
802 self._dirs = {} |
801 self._dirs = {} |
803 self._lazydirs = {} |
802 self._lazydirs = {} |
1389 for d, subm in pycompat.iteritems(self._dirs): |
1388 for d, subm in pycompat.iteritems(self._dirs): |
1390 if visit and d[:-1] not in visit: |
1389 if visit and d[:-1] not in visit: |
1391 continue |
1390 continue |
1392 subp1 = getnode(m1, d) |
1391 subp1 = getnode(m1, d) |
1393 subp2 = getnode(m2, d) |
1392 subp2 = getnode(m2, d) |
1394 if subp1 == nullid: |
1393 if subp1 == self.nodeconstants.nullid: |
1395 subp1, subp2 = subp2, subp1 |
1394 subp1, subp2 = subp2, subp1 |
1396 writesubtree(subm, subp1, subp2, match) |
1395 writesubtree(subm, subp1, subp2, match) |
1397 |
1396 |
1398 def walksubtrees(self, matcher=None): |
1397 def walksubtrees(self, matcher=None): |
1399 """Returns an iterator of the subtrees of this manifest, including this |
1398 """Returns an iterator of the subtrees of this manifest, including this |
1992 if self._treemanifests: |
1991 if self._treemanifests: |
1993 m = treemanifestctx(self, b'', node) |
1992 m = treemanifestctx(self, b'', node) |
1994 else: |
1993 else: |
1995 m = manifestctx(self, node) |
1994 m = manifestctx(self, node) |
1996 |
1995 |
1997 if node != nullid: |
1996 if node != self.nodeconstants.nullid: |
1998 mancache = self._dirmancache.get(tree) |
1997 mancache = self._dirmancache.get(tree) |
1999 if not mancache: |
1998 if not mancache: |
2000 mancache = util.lrucachedict(self._cachesize) |
1999 mancache = util.lrucachedict(self._cachesize) |
2001 self._dirmancache[tree] = mancache |
2000 self._dirmancache[tree] = mancache |
2002 mancache[node] = m |
2001 mancache[node] = m |
2080 def parents(self): |
2079 def parents(self): |
2081 return self._storage().parents(self._node) |
2080 return self._storage().parents(self._node) |
2082 |
2081 |
2083 def read(self): |
2082 def read(self): |
2084 if self._data is None: |
2083 if self._data is None: |
2085 if self._node == nullid: |
2084 if self._node == self._manifestlog.nodeconstants.nullid: |
2086 self._data = manifestdict() |
2085 self._data = manifestdict() |
2087 else: |
2086 else: |
2088 store = self._storage() |
2087 store = self._storage() |
2089 if self._node in store.fulltextcache: |
2088 if self._node in store.fulltextcache: |
2090 text = pycompat.bytestr(store.fulltextcache[self._node]) |
2089 text = pycompat.bytestr(store.fulltextcache[self._node]) |
2186 return self._manifestlog.getstorage(self._dir) |
2185 return self._manifestlog.getstorage(self._dir) |
2187 |
2186 |
2188 def read(self): |
2187 def read(self): |
2189 if self._data is None: |
2188 if self._data is None: |
2190 store = self._storage() |
2189 store = self._storage() |
2191 if self._node == nullid: |
2190 if self._node == self._manifestlog.nodeconstants.nullid: |
2192 self._data = treemanifest(self._manifestlog.nodeconstants) |
2191 self._data = treemanifest(self._manifestlog.nodeconstants) |
2193 # TODO accessing non-public API |
2192 # TODO accessing non-public API |
2194 elif store._treeondisk: |
2193 elif store._treeondisk: |
2195 m = treemanifest(self._manifestlog.nodeconstants, dir=self._dir) |
2194 m = treemanifest(self._manifestlog.nodeconstants, dir=self._dir) |
2196 |
2195 |