##// END OF EJS Templates
narrow: when writing treemanifests, skip inspecting directories outside narrow...
spectral -
r39704:24870f1b default
parent child Browse files
Show More
@@ -2109,9 +2109,16 b' class localrepository(object):'
2109 'changelog, but manifest differs)\n')
2109 'changelog, but manifest differs)\n')
2110 if files or md:
2110 if files or md:
2111 self.ui.note(_("committing manifest\n"))
2111 self.ui.note(_("committing manifest\n"))
2112 # we're using narrowmatch here since it's already applied at
2113 # other stages (such as dirstate.walk), so we're already
2114 # ignoring things outside of narrowspec in most cases. The
2115 # one case where we might have files outside the narrowspec
2116 # at this point is merges, and we already error out in the
2117 # case where the merge has files outside of the narrowspec,
2118 # so this is safe.
2112 mn = mctx.write(trp, linkrev,
2119 mn = mctx.write(trp, linkrev,
2113 p1.manifestnode(), p2.manifestnode(),
2120 p1.manifestnode(), p2.manifestnode(),
2114 added, drop)
2121 added, drop, match=self.narrowmatch())
2115 else:
2122 else:
2116 self.ui.debug('reusing manifest form p1 (listed files '
2123 self.ui.debug('reusing manifest form p1 (listed files '
2117 'actually unchanged)\n')
2124 'actually unchanged)\n')
@@ -1203,7 +1203,7 b' class treemanifest(object):'
1203 s._dirty = False
1203 s._dirty = False
1204 self._loadfunc = _load_for_read
1204 self._loadfunc = _load_for_read
1205
1205
1206 def writesubtrees(self, m1, m2, writesubtree):
1206 def writesubtrees(self, m1, m2, writesubtree, match):
1207 self._load() # for consistency; should never have any effect here
1207 self._load() # for consistency; should never have any effect here
1208 m1._load()
1208 m1._load()
1209 m2._load()
1209 m2._load()
@@ -1214,12 +1214,21 b' class treemanifest(object):'
1214 return ld[1]
1214 return ld[1]
1215 return m._dirs.get(d, emptytree)._node
1215 return m._dirs.get(d, emptytree)._node
1216
1216
1217 # we should have always loaded everything by the time we get here for
1218 # `self`, but possibly not in `m1` or `m2`.
1219 assert not self._lazydirs
1220 # let's skip investigating things that `match` says we do not need.
1221 visit = match.visitchildrenset(self._dir[:-1] or '.')
1222 if visit == 'this' or visit == 'all':
1223 visit = None
1217 for d, subm in self._dirs.iteritems():
1224 for d, subm in self._dirs.iteritems():
1225 if visit and d[:-1] not in visit:
1226 continue
1218 subp1 = getnode(m1, d)
1227 subp1 = getnode(m1, d)
1219 subp2 = getnode(m2, d)
1228 subp2 = getnode(m2, d)
1220 if subp1 == nullid:
1229 if subp1 == nullid:
1221 subp1, subp2 = subp2, subp1
1230 subp1, subp2 = subp2, subp1
1222 writesubtree(subm, subp1, subp2)
1231 writesubtree(subm, subp1, subp2, match)
1223
1232
1224 def walksubtrees(self, matcher=None):
1233 def walksubtrees(self, matcher=None):
1225 """Returns an iterator of the subtrees of this manifest, including this
1234 """Returns an iterator of the subtrees of this manifest, including this
@@ -1445,7 +1454,8 b' class manifestrevlog(object):'
1445 self._dirlogcache[d] = mfrevlog
1454 self._dirlogcache[d] = mfrevlog
1446 return self._dirlogcache[d]
1455 return self._dirlogcache[d]
1447
1456
1448 def add(self, m, transaction, link, p1, p2, added, removed, readtree=None):
1457 def add(self, m, transaction, link, p1, p2, added, removed, readtree=None,
1458 match=None):
1449 if p1 in self.fulltextcache and util.safehasattr(m, 'fastdelta'):
1459 if p1 in self.fulltextcache and util.safehasattr(m, 'fastdelta'):
1450 # If our first parent is in the manifest cache, we can
1460 # If our first parent is in the manifest cache, we can
1451 # compute a delta here using properties we know about the
1461 # compute a delta here using properties we know about the
@@ -1469,9 +1479,11 b' class manifestrevlog(object):'
1469 # process.
1479 # process.
1470 if self._treeondisk:
1480 if self._treeondisk:
1471 assert readtree, "readtree must be set for treemanifest writes"
1481 assert readtree, "readtree must be set for treemanifest writes"
1482 assert match, "match must be specified for treemanifest writes"
1472 m1 = readtree(self.tree, p1)
1483 m1 = readtree(self.tree, p1)
1473 m2 = readtree(self.tree, p2)
1484 m2 = readtree(self.tree, p2)
1474 n = self._addtree(m, transaction, link, m1, m2, readtree)
1485 n = self._addtree(m, transaction, link, m1, m2, readtree,
1486 match=match)
1475 arraytext = None
1487 arraytext = None
1476 else:
1488 else:
1477 text = m.text()
1489 text = m.text()
@@ -1483,17 +1495,17 b' class manifestrevlog(object):'
1483
1495
1484 return n
1496 return n
1485
1497
1486 def _addtree(self, m, transaction, link, m1, m2, readtree):
1498 def _addtree(self, m, transaction, link, m1, m2, readtree, match):
1487 # If the manifest is unchanged compared to one parent,
1499 # If the manifest is unchanged compared to one parent,
1488 # don't write a new revision
1500 # don't write a new revision
1489 if self.tree != '' and (m.unmodifiedsince(m1) or m.unmodifiedsince(
1501 if self.tree != '' and (m.unmodifiedsince(m1) or m.unmodifiedsince(
1490 m2)):
1502 m2)):
1491 return m.node()
1503 return m.node()
1492 def writesubtree(subm, subp1, subp2):
1504 def writesubtree(subm, subp1, subp2, match):
1493 sublog = self.dirlog(subm.dir())
1505 sublog = self.dirlog(subm.dir())
1494 sublog.add(subm, transaction, link, subp1, subp2, None, None,
1506 sublog.add(subm, transaction, link, subp1, subp2, None, None,
1495 readtree=readtree)
1507 readtree=readtree, match=match)
1496 m.writesubtrees(m1, m2, writesubtree)
1508 m.writesubtrees(m1, m2, writesubtree, match)
1497 text = m.dirtext()
1509 text = m.dirtext()
1498 n = None
1510 n = None
1499 if self.tree != '':
1511 if self.tree != '':
@@ -1697,9 +1709,9 b' class memmanifestctx(object):'
1697 def read(self):
1709 def read(self):
1698 return self._manifestdict
1710 return self._manifestdict
1699
1711
1700 def write(self, transaction, link, p1, p2, added, removed):
1712 def write(self, transaction, link, p1, p2, added, removed, match=None):
1701 return self._storage().add(self._manifestdict, transaction, link,
1713 return self._storage().add(self._manifestdict, transaction, link,
1702 p1, p2, added, removed)
1714 p1, p2, added, removed, match=match)
1703
1715
1704 @interfaceutil.implementer(repository.imanifestrevisionstored)
1716 @interfaceutil.implementer(repository.imanifestrevisionstored)
1705 class manifestctx(object):
1717 class manifestctx(object):
@@ -1802,11 +1814,12 b' class memtreemanifestctx(object):'
1802 def read(self):
1814 def read(self):
1803 return self._treemanifest
1815 return self._treemanifest
1804
1816
1805 def write(self, transaction, link, p1, p2, added, removed):
1817 def write(self, transaction, link, p1, p2, added, removed, match=None):
1806 def readtree(dir, node):
1818 def readtree(dir, node):
1807 return self._manifestlog.get(dir, node).read()
1819 return self._manifestlog.get(dir, node).read()
1808 return self._storage().add(self._treemanifest, transaction, link,
1820 return self._storage().add(self._treemanifest, transaction, link,
1809 p1, p2, added, removed, readtree=readtree)
1821 p1, p2, added, removed, readtree=readtree,
1822 match=match)
1810
1823
1811 @interfaceutil.implementer(repository.imanifestrevisionstored)
1824 @interfaceutil.implementer(repository.imanifestrevisionstored)
1812 class treemanifestctx(object):
1825 class treemanifestctx(object):
@@ -978,13 +978,18 b' class imanifestrevisionstored(imanifestr'
978 class imanifestrevisionwritable(imanifestrevisionbase):
978 class imanifestrevisionwritable(imanifestrevisionbase):
979 """Interface representing a manifest revision that can be committed."""
979 """Interface representing a manifest revision that can be committed."""
980
980
981 def write(transaction, linkrev, p1node, p2node, added, removed):
981 def write(transaction, linkrev, p1node, p2node, added, removed, match=None):
982 """Add this revision to storage.
982 """Add this revision to storage.
983
983
984 Takes a transaction object, the changeset revision number it will
984 Takes a transaction object, the changeset revision number it will
985 be associated with, its parent nodes, and lists of added and
985 be associated with, its parent nodes, and lists of added and
986 removed paths.
986 removed paths.
987
987
988 If match is provided, storage can choose not to inspect or write out
989 items that do not match. Storage is still required to be able to provide
990 the full manifest in the future for any directories written (these
991 manifests should not be "narrowed on disk").
992
988 Returns the binary node of the created revision.
993 Returns the binary node of the created revision.
989 """
994 """
990
995
@@ -1141,7 +1146,8 b' class imanifeststorage(interfaceutil.Int'
1141 def dirlog(d):
1146 def dirlog(d):
1142 """Obtain a manifest storage instance for a tree."""
1147 """Obtain a manifest storage instance for a tree."""
1143
1148
1144 def add(m, transaction, link, p1, p2, added, removed, readtree=None):
1149 def add(m, transaction, link, p1, p2, added, removed, readtree=None,
1150 match=None):
1145 """Add a revision to storage.
1151 """Add a revision to storage.
1146
1152
1147 ``m`` is an object conforming to ``imanifestdict``.
1153 ``m`` is an object conforming to ``imanifestdict``.
@@ -1152,6 +1158,15 b' class imanifeststorage(interfaceutil.Int'
1152
1158
1153 ``added`` and ``removed`` are iterables of added and removed paths,
1159 ``added`` and ``removed`` are iterables of added and removed paths,
1154 respectively.
1160 respectively.
1161
1162 ``readtree`` is a function that can be used to read the child tree(s)
1163 when recursively writing the full tree structure when using
1164 treemanifets.
1165
1166 ``match`` is a matcher that can be used to hint to storage that not all
1167 paths must be inspected; this is an optimization and can be safely
1168 ignored. Note that the storage must still be able to reproduce a full
1169 manifest including files that did not match.
1155 """
1170 """
1156
1171
1157 class imanifestlog(interfaceutil.Interface):
1172 class imanifestlog(interfaceutil.Interface):
General Comments 0
You need to be logged in to leave comments. Login now