2005-08-28 01:21:25 +04:00
|
|
|
# manifest.py - manifest revision class for mercurial
|
|
|
|
#
|
2007-06-19 10:51:34 +04:00
|
|
|
# Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
|
2005-08-28 01:21:25 +04:00
|
|
|
#
|
2009-04-26 03:08:54 +04:00
|
|
|
# This software may be used and distributed according to the terms of the
|
2010-01-20 07:20:08 +03:00
|
|
|
# GNU General Public License version 2 or any later version.
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2006-12-15 05:25:19 +03:00
|
|
|
from i18n import _
|
2015-04-07 00:36:08 +03:00
|
|
|
import mdiff, parsers, error, revlog, util
|
2009-04-28 19:40:46 +04:00
|
|
|
import array, struct
|
2015-04-01 00:01:33 +03:00
|
|
|
import os
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2015-03-14 01:19:54 +03:00
|
|
|
propertycache = util.propertycache
|
2015-03-07 19:42:05 +03:00
|
|
|
|
2015-03-28 08:26:41 +03:00
|
|
|
def _parsev1(data):
|
2015-03-28 01:02:43 +03:00
|
|
|
# This method does a little bit of excessive-looking
|
|
|
|
# precondition checking. This is so that the behavior of this
|
|
|
|
# class exactly matches its C counterpart to try and help
|
|
|
|
# prevent surprise breakage for anyone that develops against
|
|
|
|
# the pure version.
|
|
|
|
if data and data[-1] != '\n':
|
|
|
|
raise ValueError('Manifest did not end in a newline.')
|
|
|
|
prev = None
|
|
|
|
for l in data.splitlines():
|
|
|
|
if prev is not None and prev > l:
|
|
|
|
raise ValueError('Manifest lines not in sorted order.')
|
|
|
|
prev = l
|
|
|
|
f, n = l.split('\0')
|
|
|
|
if len(n) > 40:
|
|
|
|
yield f, revlog.bin(n[:40]), n[40:]
|
|
|
|
else:
|
|
|
|
yield f, revlog.bin(n), ''
|
|
|
|
|
2015-03-28 08:26:41 +03:00
|
|
|
def _parsev2(data):
|
|
|
|
metadataend = data.find('\n')
|
|
|
|
# Just ignore metadata for now
|
|
|
|
pos = metadataend + 1
|
|
|
|
prevf = ''
|
|
|
|
while pos < len(data):
|
|
|
|
end = data.find('\n', pos + 1) # +1 to skip stem length byte
|
|
|
|
if end == -1:
|
|
|
|
raise ValueError('Manifest ended with incomplete file entry.')
|
|
|
|
stemlen = ord(data[pos])
|
|
|
|
items = data[pos + 1:end].split('\0')
|
|
|
|
f = prevf[:stemlen] + items[0]
|
|
|
|
if prevf > f:
|
|
|
|
raise ValueError('Manifest entries not in sorted order.')
|
|
|
|
fl = items[1]
|
|
|
|
# Just ignore metadata (items[2:] for now)
|
|
|
|
n = data[end + 1:end + 21]
|
|
|
|
yield f, n, fl
|
|
|
|
pos = end + 22
|
|
|
|
prevf = f
|
|
|
|
|
|
|
|
def _parse(data):
|
|
|
|
"""Generates (path, node, flags) tuples from a manifest text"""
|
|
|
|
if data.startswith('\0'):
|
|
|
|
return iter(_parsev2(data))
|
|
|
|
else:
|
|
|
|
return iter(_parsev1(data))
|
|
|
|
|
2015-04-01 00:01:33 +03:00
|
|
|
def _text(it, usemanifestv2):
|
2015-03-28 01:37:46 +03:00
|
|
|
"""Given an iterator over (path, node, flags) tuples, returns a manifest
|
|
|
|
text"""
|
2015-04-01 00:01:33 +03:00
|
|
|
if usemanifestv2:
|
|
|
|
return _textv2(it)
|
|
|
|
else:
|
|
|
|
return _textv1(it)
|
|
|
|
|
|
|
|
def _textv1(it):
|
2015-03-28 01:37:46 +03:00
|
|
|
files = []
|
|
|
|
lines = []
|
|
|
|
_hex = revlog.hex
|
|
|
|
for f, n, fl in it:
|
|
|
|
files.append(f)
|
|
|
|
# if this is changed to support newlines in filenames,
|
|
|
|
# be sure to check the templates/ dir again (especially *-raw.tmpl)
|
|
|
|
lines.append("%s\0%s%s\n" % (f, _hex(n), fl))
|
|
|
|
|
|
|
|
_checkforbidden(files)
|
|
|
|
return ''.join(lines)
|
|
|
|
|
2015-04-01 00:01:33 +03:00
|
|
|
def _textv2(it):
|
|
|
|
files = []
|
|
|
|
lines = ['\0\n']
|
|
|
|
prevf = ''
|
|
|
|
for f, n, fl in it:
|
|
|
|
files.append(f)
|
|
|
|
stem = os.path.commonprefix([prevf, f])
|
|
|
|
stemlen = min(len(stem), 255)
|
|
|
|
lines.append("%c%s\0%s\n%s\n" % (stemlen, f[stemlen:], fl, n))
|
|
|
|
prevf = f
|
|
|
|
_checkforbidden(files)
|
|
|
|
return ''.join(lines)
|
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
class _lazymanifest(dict):
|
|
|
|
"""This is the pure implementation of lazymanifest.
|
|
|
|
|
|
|
|
It has not been optimized *at all* and is not lazy.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, data):
|
|
|
|
dict.__init__(self)
|
2015-03-28 01:02:43 +03:00
|
|
|
for f, n, fl in _parse(data):
|
|
|
|
self[f] = n, fl
|
2015-03-07 19:43:12 +03:00
|
|
|
|
2014-12-12 21:40:44 +03:00
|
|
|
def __setitem__(self, k, v):
|
2015-03-07 20:04:39 +03:00
|
|
|
node, flag = v
|
|
|
|
assert node is not None
|
|
|
|
if len(node) > 21:
|
|
|
|
node = node[:21] # match c implementation behavior
|
|
|
|
dict.__setitem__(self, k, (node, flag))
|
|
|
|
|
|
|
|
def __iter__(self):
|
2015-03-13 04:18:29 +03:00
|
|
|
return iter(sorted(dict.keys(self)))
|
2015-03-07 20:04:39 +03:00
|
|
|
|
2015-03-13 04:53:44 +03:00
|
|
|
def iterkeys(self):
|
|
|
|
return iter(sorted(dict.keys(self)))
|
|
|
|
|
2015-03-13 04:18:29 +03:00
|
|
|
def iterentries(self):
|
|
|
|
return ((f, e[0], e[1]) for f, e in sorted(self.iteritems()))
|
|
|
|
|
2006-07-16 11:59:20 +04:00
|
|
|
def copy(self):
|
2015-03-07 20:04:39 +03:00
|
|
|
c = _lazymanifest('')
|
|
|
|
c.update(self)
|
|
|
|
return c
|
|
|
|
|
|
|
|
def diff(self, m2, clean=False):
|
|
|
|
'''Finds changes between the current manifest and m2.'''
|
|
|
|
diff = {}
|
|
|
|
|
|
|
|
for fn, e1 in self.iteritems():
|
|
|
|
if fn not in m2:
|
|
|
|
diff[fn] = e1, (None, '')
|
|
|
|
else:
|
|
|
|
e2 = m2[fn]
|
|
|
|
if e1 != e2:
|
|
|
|
diff[fn] = e1, e2
|
|
|
|
elif clean:
|
|
|
|
diff[fn] = None
|
|
|
|
|
|
|
|
for fn, e2 in m2.iteritems():
|
|
|
|
if fn not in self:
|
|
|
|
diff[fn] = (None, ''), e2
|
|
|
|
|
|
|
|
return diff
|
|
|
|
|
|
|
|
def filtercopy(self, filterfn):
|
|
|
|
c = _lazymanifest('')
|
2015-03-13 04:18:29 +03:00
|
|
|
for f, n, fl in self.iterentries():
|
2015-03-07 20:04:39 +03:00
|
|
|
if filterfn(f):
|
|
|
|
c[f] = n, fl
|
|
|
|
return c
|
|
|
|
|
|
|
|
def text(self):
|
|
|
|
"""Get the full data of this manifest as a bytestring."""
|
2015-04-01 00:01:33 +03:00
|
|
|
return _textv1(self.iterentries())
|
2015-03-07 20:04:39 +03:00
|
|
|
|
2015-03-07 05:29:47 +03:00
|
|
|
try:
|
|
|
|
_lazymanifest = parsers.lazymanifest
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
class manifestdict(object):
|
|
|
|
def __init__(self, data=''):
|
2015-03-28 08:26:41 +03:00
|
|
|
if data.startswith('\0'):
|
|
|
|
#_lazymanifest can not parse v2
|
|
|
|
self._lm = _lazymanifest('')
|
|
|
|
for f, n, fl in _parsev2(data):
|
|
|
|
self._lm[f] = n, fl
|
|
|
|
else:
|
|
|
|
self._lm = _lazymanifest(data)
|
2015-03-07 20:04:39 +03:00
|
|
|
|
|
|
|
def __getitem__(self, key):
|
|
|
|
return self._lm[key][0]
|
|
|
|
|
2015-03-11 02:26:13 +03:00
|
|
|
def find(self, key):
|
|
|
|
return self._lm[key]
|
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
def __len__(self):
|
|
|
|
return len(self._lm)
|
|
|
|
|
|
|
|
def __setitem__(self, key, node):
|
|
|
|
self._lm[key] = node, self.flags(key, '')
|
|
|
|
|
|
|
|
def __contains__(self, key):
|
|
|
|
return key in self._lm
|
|
|
|
|
|
|
|
def __delitem__(self, key):
|
|
|
|
del self._lm[key]
|
|
|
|
|
2015-03-11 23:46:15 +03:00
|
|
|
def __iter__(self):
|
2015-03-13 04:18:29 +03:00
|
|
|
return self._lm.__iter__()
|
2015-03-07 20:04:39 +03:00
|
|
|
|
|
|
|
def iterkeys(self):
|
2015-03-11 23:46:15 +03:00
|
|
|
return self._lm.iterkeys()
|
|
|
|
|
|
|
|
def keys(self):
|
|
|
|
return list(self.iterkeys())
|
2015-03-07 20:04:39 +03:00
|
|
|
|
2015-02-28 00:57:37 +03:00
|
|
|
def filesnotin(self, m2):
|
|
|
|
'''Set of files in this manifest that are not in the other'''
|
2015-03-13 04:18:29 +03:00
|
|
|
files = set(self)
|
|
|
|
files.difference_update(m2)
|
2015-02-28 00:57:37 +03:00
|
|
|
return files
|
|
|
|
|
2015-03-14 01:19:54 +03:00
|
|
|
@propertycache
|
|
|
|
def _dirs(self):
|
2015-04-07 00:36:08 +03:00
|
|
|
return util.dirs(self)
|
2015-03-14 01:19:54 +03:00
|
|
|
|
|
|
|
def dirs(self):
|
|
|
|
return self._dirs
|
|
|
|
|
2015-03-14 01:25:01 +03:00
|
|
|
def hasdir(self, dir):
|
|
|
|
return dir in self._dirs
|
|
|
|
|
2015-04-08 19:38:09 +03:00
|
|
|
def _filesfastpath(self, match):
|
|
|
|
'''Checks whether we can correctly and quickly iterate over matcher
|
|
|
|
files instead of over manifest files.'''
|
|
|
|
files = match.files()
|
|
|
|
return (len(files) < 100 and (match.isexact() or
|
|
|
|
(not match.anypats() and util.all(fn in self for fn in files))))
|
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
def walk(self, match):
|
|
|
|
'''Generates matching file names.
|
|
|
|
|
|
|
|
Equivalent to manifest.matches(match).iterkeys(), but without creating
|
|
|
|
an entirely new manifest.
|
|
|
|
|
|
|
|
It also reports nonexistent files by marking them bad with match.bad().
|
|
|
|
'''
|
2015-04-08 07:08:23 +03:00
|
|
|
if match.always():
|
|
|
|
for f in iter(self):
|
|
|
|
yield f
|
|
|
|
return
|
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
fset = set(match.files())
|
|
|
|
|
|
|
|
# avoid the entire walk if we're only looking for specific files
|
2015-04-08 19:38:09 +03:00
|
|
|
if self._filesfastpath(match):
|
2015-04-08 08:35:44 +03:00
|
|
|
for fn in sorted(fset):
|
|
|
|
yield fn
|
2015-04-08 08:36:17 +03:00
|
|
|
return
|
2015-04-08 01:18:52 +03:00
|
|
|
|
|
|
|
for fn in self:
|
|
|
|
if fn in fset:
|
|
|
|
# specified pattern is the exact name
|
|
|
|
fset.remove(fn)
|
|
|
|
if match(fn):
|
|
|
|
yield fn
|
|
|
|
|
|
|
|
# for dirstate.walk, files=['.'] means "walk the whole tree".
|
|
|
|
# follow that here, too
|
|
|
|
fset.discard('.')
|
|
|
|
|
|
|
|
for fn in sorted(fset):
|
|
|
|
if not self.hasdir(fn):
|
|
|
|
match.bad(fn, None)
|
|
|
|
|
2014-10-23 08:38:30 +04:00
|
|
|
def matches(self, match):
|
|
|
|
'''generate a new manifest filtered by the match argument'''
|
|
|
|
if match.always():
|
|
|
|
return self.copy()
|
|
|
|
|
2015-04-08 19:38:09 +03:00
|
|
|
if self._filesfastpath(match):
|
2015-04-08 20:01:31 +03:00
|
|
|
m = manifestdict()
|
|
|
|
lm = self._lm
|
|
|
|
for fn in match.files():
|
|
|
|
if fn in lm:
|
|
|
|
m._lm[fn] = lm[fn]
|
|
|
|
return m
|
2014-10-23 08:38:30 +04:00
|
|
|
|
2015-04-11 04:13:01 +03:00
|
|
|
m = manifestdict()
|
2015-04-08 20:06:05 +03:00
|
|
|
m._lm = self._lm.filtercopy(match)
|
|
|
|
return m
|
2014-10-23 08:38:30 +04:00
|
|
|
|
2014-12-16 00:04:28 +03:00
|
|
|
def diff(self, m2, clean=False):
|
|
|
|
'''Finds changes between the current manifest and m2.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
m2: the manifest to which this manifest should be compared.
|
|
|
|
clean: if true, include files unchanged between these manifests
|
|
|
|
with a None value in the returned dictionary.
|
|
|
|
|
|
|
|
The result is returned as a dict with filename as key and
|
|
|
|
values of the form ((n1,fl1),(n2,fl2)), where n1/n2 is the
|
|
|
|
nodeid in the current/other manifest and fl1/fl2 is the flag
|
|
|
|
in the current/other manifest. Where the file does not exist,
|
|
|
|
the nodeid will be None and the flags will be the empty
|
|
|
|
string.
|
|
|
|
'''
|
2015-03-07 20:04:39 +03:00
|
|
|
return self._lm.diff(m2._lm, clean)
|
manifest: for diff(), only iterate over files, not flags
From manifest.diff(), we return a dict from filename to pairs of pairs
of file nodeids and flags (values of the form ((n1,n2),(fl1,fl2))). To
create this dict, we currently generate one dict for files (with
(n1,n2) values) and one for flags (with (fl1,fl2) values) and then
join these dicts. Missing files are represented by None and missing
flags by '', but due to the dict joining, the inner pairs themselves
can also be None. The only caller, merge.manifestmerge(), then unpacks
these values while checking for None values.
By inlining the calls to dicthelpers and simplifying it to only
iterate over files (ignoring flags-only differences), we can simplify
life for our caller.
2014-10-15 09:48:44 +04:00
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
def setflag(self, key, flag):
|
|
|
|
self._lm[key] = self[key], flag
|
manifest: for diff(), only iterate over files, not flags
From manifest.diff(), we return a dict from filename to pairs of pairs
of file nodeids and flags (values of the form ((n1,n2),(fl1,fl2))). To
create this dict, we currently generate one dict for files (with
(n1,n2) values) and one for flags (with (fl1,fl2) values) and then
join these dicts. Missing files are represented by None and missing
flags by '', but due to the dict joining, the inner pairs themselves
can also be None. The only caller, merge.manifestmerge(), then unpacks
these values while checking for None values.
By inlining the calls to dicthelpers and simplifying it to only
iterate over files (ignoring flags-only differences), we can simplify
life for our caller.
2014-10-15 09:48:44 +04:00
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
def get(self, key, default=None):
|
|
|
|
try:
|
|
|
|
return self._lm[key][0]
|
|
|
|
except KeyError:
|
|
|
|
return default
|
2006-07-16 11:59:20 +04:00
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
def flags(self, key, default=''):
|
|
|
|
try:
|
|
|
|
return self._lm[key][1]
|
|
|
|
except KeyError:
|
|
|
|
return default
|
2014-10-08 22:47:30 +04:00
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
def copy(self):
|
2015-04-11 04:13:01 +03:00
|
|
|
c = manifestdict()
|
2015-03-07 20:04:39 +03:00
|
|
|
c._lm = self._lm.copy()
|
|
|
|
return c
|
|
|
|
|
|
|
|
def iteritems(self):
|
2015-03-13 04:18:29 +03:00
|
|
|
return (x[:2] for x in self._lm.iterentries())
|
2015-03-07 20:04:39 +03:00
|
|
|
|
2015-04-01 00:01:33 +03:00
|
|
|
def text(self, usemanifestv2=False):
|
|
|
|
if usemanifestv2:
|
|
|
|
return _textv2(self._lm.iterentries())
|
|
|
|
else:
|
|
|
|
# use (probably) native version for v1
|
|
|
|
return self._lm.text()
|
2014-08-07 17:46:05 +04:00
|
|
|
|
2014-10-08 23:20:14 +04:00
|
|
|
def fastdelta(self, base, changes):
|
|
|
|
"""Given a base manifest text as an array.array and a list of changes
|
|
|
|
relative to that text, compute a delta that can be used by revlog.
|
|
|
|
"""
|
|
|
|
delta = []
|
|
|
|
dstart = None
|
|
|
|
dend = None
|
|
|
|
dline = [""]
|
|
|
|
start = 0
|
|
|
|
# zero copy representation of base as a buffer
|
|
|
|
addbuf = util.buffer(base)
|
|
|
|
|
|
|
|
# start with a readonly loop that finds the offset of
|
|
|
|
# each line and creates the deltas
|
|
|
|
for f, todelete in changes:
|
|
|
|
# bs will either be the index of the item or the insert point
|
|
|
|
start, end = _msearch(addbuf, f, start)
|
|
|
|
if not todelete:
|
2015-03-07 20:04:39 +03:00
|
|
|
h, fl = self._lm[f]
|
|
|
|
l = "%s\0%s%s\n" % (f, revlog.hex(h), fl)
|
2014-10-08 23:20:14 +04:00
|
|
|
else:
|
|
|
|
if start == end:
|
|
|
|
# item we want to delete was not found, error out
|
|
|
|
raise AssertionError(
|
|
|
|
_("failed to remove %s from manifest") % f)
|
|
|
|
l = ""
|
|
|
|
if dstart is not None and dstart <= start and dend >= start:
|
|
|
|
if dend < end:
|
|
|
|
dend = end
|
|
|
|
if l:
|
|
|
|
dline.append(l)
|
|
|
|
else:
|
|
|
|
if dstart is not None:
|
|
|
|
delta.append([dstart, dend, "".join(dline)])
|
|
|
|
dstart = start
|
|
|
|
dend = end
|
|
|
|
dline = [l]
|
|
|
|
|
|
|
|
if dstart is not None:
|
|
|
|
delta.append([dstart, dend, "".join(dline)])
|
|
|
|
# apply the delta to the base, and get a delta for addrevision
|
|
|
|
deltatext, arraytext = _addlistdelta(base, delta)
|
|
|
|
return arraytext, deltatext
|
|
|
|
|
2014-10-08 23:21:59 +04:00
|
|
|
def _msearch(m, s, lo=0, hi=None):
|
|
|
|
'''return a tuple (start, end) that says where to find s within m.
|
|
|
|
|
|
|
|
If the string is found m[start:end] are the line containing
|
|
|
|
that string. If start == end the string was not found and
|
|
|
|
they indicate the proper sorted insertion point.
|
|
|
|
|
|
|
|
m should be a buffer or a string
|
|
|
|
s is a string'''
|
|
|
|
def advance(i, c):
|
|
|
|
while i < lenm and m[i] != c:
|
|
|
|
i += 1
|
|
|
|
return i
|
|
|
|
if not s:
|
|
|
|
return (lo, lo)
|
|
|
|
lenm = len(m)
|
|
|
|
if not hi:
|
|
|
|
hi = lenm
|
|
|
|
while lo < hi:
|
|
|
|
mid = (lo + hi) // 2
|
|
|
|
start = mid
|
|
|
|
while start > 0 and m[start - 1] != '\n':
|
|
|
|
start -= 1
|
|
|
|
end = advance(start, '\0')
|
|
|
|
if m[start:end] < s:
|
|
|
|
# we know that after the null there are 40 bytes of sha1
|
|
|
|
# this translates to the bisect lo = mid + 1
|
|
|
|
lo = advance(end + 40, '\n') + 1
|
|
|
|
else:
|
|
|
|
# this translates to the bisect hi = mid
|
|
|
|
hi = start
|
|
|
|
end = advance(lo, '\0')
|
|
|
|
found = m[lo:end]
|
|
|
|
if s == found:
|
|
|
|
# we know that after the null there are 40 bytes of sha1
|
|
|
|
end = advance(end + 40, '\n')
|
|
|
|
return (lo, end + 1)
|
|
|
|
else:
|
|
|
|
return (lo, lo)
|
|
|
|
|
2014-09-11 18:14:34 +04:00
|
|
|
def _checkforbidden(l):
|
2014-08-07 17:46:05 +04:00
|
|
|
"""Check filenames for illegal characters."""
|
|
|
|
for f in l:
|
|
|
|
if '\n' in f or '\r' in f:
|
|
|
|
raise error.RevlogError(
|
|
|
|
_("'\\n' and '\\r' disallowed in filenames: %r") % f)
|
|
|
|
|
|
|
|
|
2014-08-07 20:47:20 +04:00
|
|
|
# apply the changes collected during the bisect loop to our addlist
|
|
|
|
# return a delta suitable for addrevision
|
2014-09-11 18:14:34 +04:00
|
|
|
def _addlistdelta(addlist, x):
|
2014-08-07 20:47:20 +04:00
|
|
|
# for large addlist arrays, building a new array is cheaper
|
|
|
|
# than repeatedly modifying the existing one
|
|
|
|
currentposition = 0
|
|
|
|
newaddlist = array.array('c')
|
|
|
|
|
|
|
|
for start, end, content in x:
|
|
|
|
newaddlist += addlist[currentposition:start]
|
|
|
|
if content:
|
|
|
|
newaddlist += array.array('c', content)
|
|
|
|
|
|
|
|
currentposition = end
|
|
|
|
|
|
|
|
newaddlist += addlist[currentposition:]
|
|
|
|
|
|
|
|
deltatext = "".join(struct.pack(">lll", start, end, len(content))
|
|
|
|
+ content for start, end, content in x)
|
|
|
|
return deltatext, newaddlist
|
|
|
|
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
def _splittopdir(f):
|
|
|
|
if '/' in f:
|
|
|
|
dir, subpath = f.split('/', 1)
|
|
|
|
return dir + '/', subpath
|
|
|
|
else:
|
|
|
|
return '', f
|
|
|
|
|
|
|
|
class treemanifest(object):
|
2015-02-23 21:57:57 +03:00
|
|
|
def __init__(self, dir='', text=''):
|
|
|
|
self._dir = dir
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
self._dirs = {}
|
|
|
|
# Using _lazymanifest here is a little slower than plain old dicts
|
|
|
|
self._files = {}
|
|
|
|
self._flags = {}
|
2015-03-28 01:02:43 +03:00
|
|
|
for f, n, fl in _parse(text):
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
self[f] = n
|
|
|
|
if fl:
|
|
|
|
self.setflag(f, fl)
|
|
|
|
|
2015-02-23 21:57:57 +03:00
|
|
|
def _subpath(self, path):
|
|
|
|
return self._dir + path
|
|
|
|
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
def __len__(self):
|
|
|
|
size = len(self._files)
|
|
|
|
for m in self._dirs.values():
|
|
|
|
size += m.__len__()
|
|
|
|
return size
|
|
|
|
|
2015-03-31 03:21:49 +03:00
|
|
|
def _isempty(self):
|
|
|
|
return (not self._files and (not self._dirs or
|
|
|
|
util.all(m._isempty() for m in self._dirs.values())))
|
|
|
|
|
2015-02-23 21:57:57 +03:00
|
|
|
def __str__(self):
|
|
|
|
return '<treemanifest dir=%s>' % self._dir
|
|
|
|
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
def iteritems(self):
|
|
|
|
for p, n in sorted(self._dirs.items() + self._files.items()):
|
|
|
|
if p in self._files:
|
2015-02-23 21:57:57 +03:00
|
|
|
yield self._subpath(p), n
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
else:
|
2015-02-23 21:57:57 +03:00
|
|
|
for f, sn in n.iteritems():
|
|
|
|
yield f, sn
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
|
|
|
def iterkeys(self):
|
|
|
|
for p in sorted(self._dirs.keys() + self._files.keys()):
|
|
|
|
if p in self._files:
|
2015-02-23 21:57:57 +03:00
|
|
|
yield self._subpath(p)
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
else:
|
|
|
|
for f in self._dirs[p].iterkeys():
|
2015-02-23 21:57:57 +03:00
|
|
|
yield f
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
|
|
|
def keys(self):
|
|
|
|
return list(self.iterkeys())
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self.iterkeys()
|
|
|
|
|
|
|
|
def __contains__(self, f):
|
|
|
|
if f is None:
|
|
|
|
return False
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
if dir not in self._dirs:
|
|
|
|
return False
|
|
|
|
return self._dirs[dir].__contains__(subpath)
|
|
|
|
else:
|
|
|
|
return f in self._files
|
|
|
|
|
|
|
|
def get(self, f, default=None):
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
if dir not in self._dirs:
|
|
|
|
return default
|
|
|
|
return self._dirs[dir].get(subpath, default)
|
|
|
|
else:
|
|
|
|
return self._files.get(f, default)
|
|
|
|
|
|
|
|
def __getitem__(self, f):
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
return self._dirs[dir].__getitem__(subpath)
|
|
|
|
else:
|
|
|
|
return self._files[f]
|
|
|
|
|
|
|
|
def flags(self, f):
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
if dir not in self._dirs:
|
|
|
|
return ''
|
|
|
|
return self._dirs[dir].flags(subpath)
|
|
|
|
else:
|
|
|
|
if f in self._dirs:
|
|
|
|
return ''
|
|
|
|
return self._flags.get(f, '')
|
|
|
|
|
|
|
|
def find(self, f):
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
return self._dirs[dir].find(subpath)
|
|
|
|
else:
|
|
|
|
return self._files[f], self._flags.get(f, '')
|
|
|
|
|
|
|
|
def __delitem__(self, f):
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
self._dirs[dir].__delitem__(subpath)
|
|
|
|
# If the directory is now empty, remove it
|
2015-03-31 03:21:49 +03:00
|
|
|
if self._dirs[dir]._isempty():
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
del self._dirs[dir]
|
|
|
|
else:
|
|
|
|
del self._files[f]
|
|
|
|
if f in self._flags:
|
|
|
|
del self._flags[f]
|
|
|
|
|
|
|
|
def __setitem__(self, f, n):
|
|
|
|
assert n is not None
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
if dir not in self._dirs:
|
2015-02-23 21:57:57 +03:00
|
|
|
self._dirs[dir] = treemanifest(self._subpath(dir))
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
self._dirs[dir].__setitem__(subpath, n)
|
|
|
|
else:
|
2015-03-26 19:42:21 +03:00
|
|
|
self._files[f] = n[:21] # to match manifestdict's behavior
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
|
|
|
def setflag(self, f, flags):
|
|
|
|
"""Set the flags (symlink, executable) for path f."""
|
|
|
|
dir, subpath = _splittopdir(f)
|
|
|
|
if dir:
|
|
|
|
if dir not in self._dirs:
|
2015-02-23 21:57:57 +03:00
|
|
|
self._dirs[dir] = treemanifest(self._subpath(dir))
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
self._dirs[dir].setflag(subpath, flags)
|
|
|
|
else:
|
|
|
|
self._flags[f] = flags
|
|
|
|
|
|
|
|
def copy(self):
|
2015-02-23 21:57:57 +03:00
|
|
|
copy = treemanifest(self._dir)
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
for d in self._dirs:
|
|
|
|
copy._dirs[d] = self._dirs[d].copy()
|
|
|
|
copy._files = dict.copy(self._files)
|
|
|
|
copy._flags = dict.copy(self._flags)
|
|
|
|
return copy
|
|
|
|
|
|
|
|
def filesnotin(self, m2):
|
|
|
|
'''Set of files in this manifest that are not in the other'''
|
2015-03-04 00:50:06 +03:00
|
|
|
files = set()
|
|
|
|
def _filesnotin(t1, t2):
|
|
|
|
for d, m1 in t1._dirs.iteritems():
|
|
|
|
if d in t2._dirs:
|
|
|
|
m2 = t2._dirs[d]
|
|
|
|
_filesnotin(m1, m2)
|
|
|
|
else:
|
|
|
|
files.update(m1.iterkeys())
|
|
|
|
|
|
|
|
for fn in t1._files.iterkeys():
|
|
|
|
if fn not in t2._files:
|
|
|
|
files.add(t1._subpath(fn))
|
|
|
|
|
|
|
|
_filesnotin(self, m2)
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
return files
|
|
|
|
|
|
|
|
@propertycache
|
|
|
|
def _alldirs(self):
|
2015-04-07 00:36:08 +03:00
|
|
|
return util.dirs(self)
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
|
|
|
def dirs(self):
|
|
|
|
return self._alldirs
|
|
|
|
|
|
|
|
def hasdir(self, dir):
|
2015-03-17 02:01:16 +03:00
|
|
|
topdir, subdir = _splittopdir(dir)
|
|
|
|
if topdir:
|
|
|
|
if topdir in self._dirs:
|
|
|
|
return self._dirs[topdir].hasdir(subdir)
|
|
|
|
return False
|
|
|
|
return (dir + '/') in self._dirs
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
def walk(self, match):
|
|
|
|
'''Generates matching file names.
|
|
|
|
|
|
|
|
Equivalent to manifest.matches(match).iterkeys(), but without creating
|
|
|
|
an entirely new manifest.
|
|
|
|
|
|
|
|
It also reports nonexistent files by marking them bad with match.bad().
|
|
|
|
'''
|
2015-04-08 07:08:23 +03:00
|
|
|
if match.always():
|
|
|
|
for f in iter(self):
|
|
|
|
yield f
|
|
|
|
return
|
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
fset = set(match.files())
|
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
for fn in self._walk(match):
|
2015-04-08 01:18:52 +03:00
|
|
|
if fn in fset:
|
|
|
|
# specified pattern is the exact name
|
|
|
|
fset.remove(fn)
|
2015-04-08 01:18:52 +03:00
|
|
|
yield fn
|
2015-04-08 01:18:52 +03:00
|
|
|
|
|
|
|
# for dirstate.walk, files=['.'] means "walk the whole tree".
|
|
|
|
# follow that here, too
|
|
|
|
fset.discard('.')
|
|
|
|
|
|
|
|
for fn in sorted(fset):
|
|
|
|
if not self.hasdir(fn):
|
|
|
|
match.bad(fn, None)
|
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
def _walk(self, match, alldirs=False):
|
|
|
|
'''Recursively generates matching file names for walk().
|
|
|
|
|
|
|
|
Will visit all subdirectories if alldirs is True, otherwise it will
|
|
|
|
only visit subdirectories for which match.visitdir is True.'''
|
|
|
|
|
|
|
|
if not alldirs:
|
|
|
|
# substring to strip trailing slash
|
|
|
|
visit = match.visitdir(self._dir[:-1] or '.')
|
|
|
|
if not visit:
|
|
|
|
return
|
|
|
|
alldirs = (visit == 'all')
|
2015-04-08 01:18:52 +03:00
|
|
|
|
|
|
|
# yield this dir's files and walk its submanifests
|
|
|
|
for p in sorted(self._dirs.keys() + self._files.keys()):
|
|
|
|
if p in self._files:
|
|
|
|
fullp = self._subpath(p)
|
|
|
|
if match(fullp):
|
|
|
|
yield fullp
|
|
|
|
else:
|
2015-04-08 01:18:52 +03:00
|
|
|
for f in self._dirs[p]._walk(match, alldirs):
|
2015-04-08 01:18:52 +03:00
|
|
|
yield f
|
|
|
|
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
def matches(self, match):
|
|
|
|
'''generate a new manifest filtered by the match argument'''
|
|
|
|
if match.always():
|
|
|
|
return self.copy()
|
|
|
|
|
2015-03-31 04:10:59 +03:00
|
|
|
return self._matches(match)
|
|
|
|
|
2015-04-06 20:51:53 +03:00
|
|
|
def _matches(self, match, alldirs=False):
|
2015-03-31 04:10:59 +03:00
|
|
|
'''recursively generate a new manifest filtered by the match argument.
|
2015-04-06 20:51:53 +03:00
|
|
|
|
|
|
|
Will visit all subdirectories if alldirs is True, otherwise it will
|
|
|
|
only visit subdirectories for which match.visitdir is True.'''
|
2015-03-31 04:10:59 +03:00
|
|
|
|
|
|
|
ret = treemanifest(self._dir)
|
2015-04-06 20:51:53 +03:00
|
|
|
if not alldirs:
|
|
|
|
# substring to strip trailing slash
|
|
|
|
visit = match.visitdir(self._dir[:-1] or '.')
|
|
|
|
if not visit:
|
|
|
|
return ret
|
|
|
|
alldirs = (visit == 'all')
|
2015-03-31 04:10:59 +03:00
|
|
|
|
|
|
|
for fn in self._files:
|
|
|
|
fullp = self._subpath(fn)
|
|
|
|
if not match(fullp):
|
|
|
|
continue
|
|
|
|
ret._files[fn] = self._files[fn]
|
|
|
|
if fn in self._flags:
|
|
|
|
ret._flags[fn] = self._flags[fn]
|
|
|
|
|
|
|
|
for dir, subm in self._dirs.iteritems():
|
2015-04-06 20:51:53 +03:00
|
|
|
m = subm._matches(match, alldirs)
|
2015-03-31 04:10:59 +03:00
|
|
|
if not m._isempty():
|
|
|
|
ret._dirs[dir] = m
|
|
|
|
|
|
|
|
return ret
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
|
|
|
def diff(self, m2, clean=False):
|
|
|
|
'''Finds changes between the current manifest and m2.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
m2: the manifest to which this manifest should be compared.
|
|
|
|
clean: if true, include files unchanged between these manifests
|
|
|
|
with a None value in the returned dictionary.
|
|
|
|
|
|
|
|
The result is returned as a dict with filename as key and
|
|
|
|
values of the form ((n1,fl1),(n2,fl2)), where n1/n2 is the
|
|
|
|
nodeid in the current/other manifest and fl1/fl2 is the flag
|
|
|
|
in the current/other manifest. Where the file does not exist,
|
|
|
|
the nodeid will be None and the flags will be the empty
|
|
|
|
string.
|
|
|
|
'''
|
2015-02-20 04:13:35 +03:00
|
|
|
result = {}
|
|
|
|
emptytree = treemanifest()
|
|
|
|
def _diff(t1, t2):
|
|
|
|
for d, m1 in t1._dirs.iteritems():
|
|
|
|
m2 = t2._dirs.get(d, emptytree)
|
|
|
|
_diff(m1, m2)
|
|
|
|
|
|
|
|
for d, m2 in t2._dirs.iteritems():
|
|
|
|
if d not in t1._dirs:
|
|
|
|
_diff(emptytree, m2)
|
|
|
|
|
|
|
|
for fn, n1 in t1._files.iteritems():
|
|
|
|
fl1 = t1._flags.get(fn, '')
|
|
|
|
n2 = t2._files.get(fn, None)
|
|
|
|
fl2 = t2._flags.get(fn, '')
|
|
|
|
if n1 != n2 or fl1 != fl2:
|
|
|
|
result[t1._subpath(fn)] = ((n1, fl1), (n2, fl2))
|
|
|
|
elif clean:
|
|
|
|
result[t1._subpath(fn)] = None
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
2015-02-20 04:13:35 +03:00
|
|
|
for fn, n2 in t2._files.iteritems():
|
|
|
|
if fn not in t1._files:
|
|
|
|
fl2 = t2._flags.get(fn, '')
|
|
|
|
result[t2._subpath(fn)] = ((None, ''), (n2, fl2))
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
2015-02-20 04:13:35 +03:00
|
|
|
_diff(self, m2)
|
|
|
|
return result
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
2015-04-01 00:01:33 +03:00
|
|
|
def text(self, usemanifestv2=False):
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
"""Get the full data of this manifest as a bytestring."""
|
2015-03-28 01:37:46 +03:00
|
|
|
flags = self.flags
|
2015-04-01 00:01:33 +03:00
|
|
|
return _text(((f, self[f], flags(f)) for f in self.keys()),
|
|
|
|
usemanifestv2)
|
treemanifest: create treemanifest class
There are a number of problems with large and flat manifests. Copying
from http://mercurial.selenic.com/wiki/ManifestShardingPlan:
* manifest too large for RAM
* manifest resolution too much CPU (long delta chains)
* committing is slow because entire manifest has to be hashed
* impossible for narrow clone to leave out part of manifest as all is
needed to calculate new hash
* diffing two revisions involves traversing entire subdirectories
even if identical
This is a first step in a series introducing a manifest revlog per
directory.
This change adds a new manifest class: treemanifest, which is a tree
where each node has a dict of files (nodeids), a dict of flags, and a
dict of subdirectories (treemanifests). So far, it behaves just like
manifestdict, but it will later help us write one manifest revlog per
directory. The new class is still unused; it will be used after the
next change.
The code is not yet optimized. Running with it (see below) makes most
or all operations slower. Once we start storing manifest revlogs for
every directory, it should be possible to make many of these
operations much faster. The fastdelta() optimization has been
intentionally not implemented for the treemanifests. We can implement
it later if necessary.
All tests pass when run with the following patch (and without, of
couse):
--- a/mercurial/manifest.py Thu Mar 19 11:08:42 2015 -0700
+++ b/mercurial/manifest.py Thu Mar 19 11:15:50 2015 -0700
@@ -596,7 +596,7 @@ class manifest(revlog.revlog):
return None, None
def add(self, m, transaction, link, p1, p2, added, removed):
- if p1 in self._mancache:
+ if False and p1 in self._mancache:
# If our first parent is in the manifest cache, we can
# compute a delta here using properties we know about the
# manifest up-front, which may save time later for the
@@ -626,3 +626,5 @@ class manifest(revlog.revlog):
self._mancache[n] = (m, arraytext)
return n
+
+manifestdict = treemanifest
2015-03-19 21:08:42 +03:00
|
|
|
|
2009-01-12 07:55:36 +03:00
|
|
|
class manifest(revlog.revlog):
|
2007-03-23 03:52:38 +03:00
|
|
|
def __init__(self, opener):
|
2015-01-24 04:06:03 +03:00
|
|
|
# During normal operations, we expect to deal with not more than four
|
|
|
|
# revs at a time (such as during commit --amend). When rebasing large
|
|
|
|
# stacks of commits, the number can go up, hence the config knob below.
|
|
|
|
cachesize = 4
|
2015-03-19 21:07:57 +03:00
|
|
|
usetreemanifest = False
|
2015-03-28 02:19:44 +03:00
|
|
|
usemanifestv2 = False
|
2015-01-24 04:06:03 +03:00
|
|
|
opts = getattr(opener, 'options', None)
|
|
|
|
if opts is not None:
|
|
|
|
cachesize = opts.get('manifestcachesize', cachesize)
|
2015-03-19 21:07:57 +03:00
|
|
|
usetreemanifest = opts.get('usetreemanifest', usetreemanifest)
|
2015-04-01 08:45:45 +03:00
|
|
|
usemanifestv2 = opts.get('manifestv2', usemanifestv2)
|
2015-01-24 04:06:03 +03:00
|
|
|
self._mancache = util.lrucachedict(cachesize)
|
2009-01-12 07:55:36 +03:00
|
|
|
revlog.revlog.__init__(self, opener, "00manifest.i")
|
2015-04-11 04:54:33 +03:00
|
|
|
self._treeinmem = usetreemanifest
|
|
|
|
self._treeondisk = usetreemanifest
|
2015-03-28 02:19:44 +03:00
|
|
|
self._usemanifestv2 = usemanifestv2
|
2015-03-19 21:07:57 +03:00
|
|
|
|
|
|
|
def _newmanifest(self, data=''):
|
2015-04-11 04:54:33 +03:00
|
|
|
if self._treeinmem:
|
2015-02-23 21:57:57 +03:00
|
|
|
return treemanifest('', data)
|
2015-03-19 21:07:57 +03:00
|
|
|
return manifestdict(data)
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2015-03-28 06:41:30 +03:00
|
|
|
def _slowreaddelta(self, node):
|
|
|
|
r0 = self.deltaparent(self.rev(node))
|
|
|
|
m0 = self.read(self.node(r0))
|
|
|
|
m1 = self.read(node)
|
|
|
|
md = self._newmanifest()
|
|
|
|
for f, ((n0, fl0), (n1, fl1)) in m0.diff(m1).iteritems():
|
|
|
|
if n1:
|
|
|
|
md[f] = n1
|
|
|
|
if fl1:
|
|
|
|
md.setflag(f, fl1)
|
|
|
|
return md
|
|
|
|
|
2006-09-30 00:00:54 +04:00
|
|
|
def readdelta(self, node):
|
2015-04-11 04:54:33 +03:00
|
|
|
if self._usemanifestv2 or self._treeondisk:
|
2015-03-28 06:41:30 +03:00
|
|
|
return self._slowreaddelta(node)
|
2008-11-13 00:32:16 +03:00
|
|
|
r = self.rev(node)
|
2015-03-07 19:43:12 +03:00
|
|
|
d = mdiff.patchtext(self.revdiff(self.deltaparent(r), r))
|
2015-03-19 21:07:57 +03:00
|
|
|
return self._newmanifest(d)
|
2006-10-01 21:26:33 +04:00
|
|
|
|
2011-03-21 03:43:28 +03:00
|
|
|
def readfast(self, node):
|
|
|
|
'''use the faster of readdelta or read'''
|
|
|
|
r = self.rev(node)
|
2011-05-05 20:05:24 +04:00
|
|
|
deltaparent = self.deltaparent(r)
|
|
|
|
if deltaparent != revlog.nullrev and deltaparent in self.parentrevs(r):
|
2011-03-21 03:43:28 +03:00
|
|
|
return self.readdelta(node)
|
|
|
|
return self.read(node)
|
|
|
|
|
2005-08-28 01:21:25 +04:00
|
|
|
def read(self, node):
|
2009-01-12 07:55:36 +03:00
|
|
|
if node == revlog.nullid:
|
2015-03-19 21:07:57 +03:00
|
|
|
return self._newmanifest() # don't upset local cache
|
2013-02-09 19:43:02 +04:00
|
|
|
if node in self._mancache:
|
|
|
|
return self._mancache[node][0]
|
2005-08-28 01:21:25 +04:00
|
|
|
text = self.revision(node)
|
2009-09-02 23:05:01 +04:00
|
|
|
arraytext = array.array('c', text)
|
2015-03-19 21:07:57 +03:00
|
|
|
m = self._newmanifest(text)
|
2015-02-24 20:08:54 +03:00
|
|
|
self._mancache[node] = (m, arraytext)
|
|
|
|
return m
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2006-05-19 10:31:12 +04:00
|
|
|
def find(self, node, f):
|
|
|
|
'''look up entry for a single file efficiently.
|
2007-03-07 21:25:58 +03:00
|
|
|
return (node, flags) pair if found, (None, None) if not.'''
|
2015-03-11 18:28:56 +03:00
|
|
|
m = self.read(node)
|
2015-03-07 20:04:39 +03:00
|
|
|
try:
|
2015-03-11 18:28:56 +03:00
|
|
|
return m.find(f)
|
2015-03-07 20:04:39 +03:00
|
|
|
except KeyError:
|
2006-05-19 10:31:12 +04:00
|
|
|
return None, None
|
|
|
|
|
2015-02-24 20:08:54 +03:00
|
|
|
def add(self, m, transaction, link, p1, p2, added, removed):
|
2015-04-11 04:54:33 +03:00
|
|
|
if (p1 in self._mancache and not self._treeinmem
|
2015-03-28 03:07:24 +03:00
|
|
|
and not self._usemanifestv2):
|
2014-10-08 20:59:11 +04:00
|
|
|
# If our first parent is in the manifest cache, we can
|
|
|
|
# compute a delta here using properties we know about the
|
|
|
|
# manifest up-front, which may save time later for the
|
|
|
|
# revlog layer.
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2014-09-11 18:14:34 +04:00
|
|
|
_checkforbidden(added)
|
2005-08-28 01:21:25 +04:00
|
|
|
# combine the changed lists into one list for sorting
|
2009-09-02 23:05:43 +04:00
|
|
|
work = [(x, False) for x in added]
|
|
|
|
work.extend((x, True) for x in removed)
|
2012-08-28 01:14:27 +04:00
|
|
|
# this could use heapq.merge() (from Python 2.6+) or equivalent
|
2009-09-02 23:05:43 +04:00
|
|
|
# since the lists are already sorted
|
2005-08-28 01:21:25 +04:00
|
|
|
work.sort()
|
|
|
|
|
2015-02-24 20:08:54 +03:00
|
|
|
arraytext, deltatext = m.fastdelta(self._mancache[p1][1], work)
|
2014-10-08 23:20:14 +04:00
|
|
|
cachedelta = self.rev(p1), deltatext
|
2011-12-16 01:27:11 +04:00
|
|
|
text = util.buffer(arraytext)
|
2014-10-08 20:59:11 +04:00
|
|
|
else:
|
|
|
|
# The first parent manifest isn't already loaded, so we'll
|
|
|
|
# just encode a fulltext of the manifest and pass that
|
|
|
|
# through to the revlog layer, and let it handle the delta
|
|
|
|
# process.
|
2015-04-01 00:01:33 +03:00
|
|
|
text = m.text(self._usemanifestv2)
|
2014-10-08 20:59:11 +04:00
|
|
|
arraytext = array.array('c', text)
|
|
|
|
cachedelta = None
|
2005-08-28 01:21:25 +04:00
|
|
|
|
2009-09-04 12:47:55 +04:00
|
|
|
n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
|
2015-02-24 20:08:54 +03:00
|
|
|
self._mancache[n] = (m, arraytext)
|
2005-08-28 01:21:25 +04:00
|
|
|
|
|
|
|
return n
|