obsolete.py
1126 lines
| 37.5 KiB
| text/x-python
|
PythonLexer
/ mercurial / obsolete.py
|
r17070 | # obsolete.py - obsolete markers handling | ||
# | ||||
# Copyright 2012 Pierre-Yves David <pierre-yves.david@ens-lyon.org> | ||||
# Logilab SA <contact@logilab.fr> | ||||
# | ||||
# This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | ||||
|
r21164 | """Obsolete marker handling | ||
|
r17070 | |||
An obsolete marker maps an old changeset to a list of new | ||||
changesets. If the list of new changesets is empty, the old changeset | ||||
is said to be "killed". Otherwise, the old changeset is being | ||||
"replaced" by the new changesets. | ||||
Obsolete markers can be used to record and distribute changeset graph | ||||
|
r21164 | transformations performed by history rewrite operations, and help | ||
building new tools to reconcile conflicting rewrite actions. To | ||||
facilitate conflict resolution, markers include various annotations | ||||
|
r17070 | besides old and news changeset identifiers, such as creation date or | ||
author name. | ||||
|
r33700 | The old obsoleted changeset is called a "predecessor" and possible | ||
|
r21164 | replacements are called "successors". Markers that used changeset X as | ||
|
r33700 | a predecessor are called "successor markers of X" because they hold | ||
|
r21164 | information about the successors of X. Markers that use changeset Y as | ||
|
r33700 | a successors are call "predecessor markers of Y" because they hold | ||
information about the predecessors of Y. | ||||
|
r17776 | |||
|
r17775 | Examples: | ||
|
r21164 | - When changeset A is replaced by changeset A', one marker is stored: | ||
|
r17775 | |||
|
r21166 | (A, (A',)) | ||
|
r17775 | |||
|
r21164 | - When changesets A and B are folded into a new changeset C, two markers are | ||
|
r17775 | stored: | ||
(A, (C,)) and (B, (C,)) | ||||
|
r21164 | - When changeset A is simply "pruned" from the graph, a marker is created: | ||
|
r17775 | |||
(A, ()) | ||||
|
r29894 | - When changeset A is split into B and C, a single marker is used: | ||
|
r17775 | |||
|
r29894 | (A, (B, C)) | ||
|
r17775 | |||
|
r21164 | We use a single marker to distinguish the "split" case from the "divergence" | ||
case. If two independent operations rewrite the same changeset A in to A' and | ||||
A'', we have an error case: divergent rewriting. We can detect it because | ||||
|
r17775 | two markers will be created independently: | ||
(A, (B,)) and (A, (C,)) | ||||
|
r17070 | |||
Format | ||||
------ | ||||
Markers are stored in an append-only file stored in | ||||
'.hg/store/obsstore'. | ||||
The file starts with a version header: | ||||
- 1 unsigned byte: version number, starting at zero. | ||||
|
r22612 | The header is followed by the markers. Marker format depend of the version. See | ||
comment associated with each format for details. | ||||
|
r21164 | |||
|
r17070 | """ | ||
|
r27332 | from __future__ import absolute_import | ||
import errno | ||||
import struct | ||||
from .i18n import _ | ||||
from . import ( | ||||
error, | ||||
node, | ||||
r33143 | obsutil, | |||
|
r27332 | phases, | ||
|
r32372 | policy, | ||
|
r27332 | util, | ||
) | ||||
|
r17070 | |||
|
r32372 | parsers = policy.importmod(r'parsers') | ||
|
r17070 | _pack = struct.pack | ||
_unpack = struct.unpack | ||||
|
r23498 | _calcsize = struct.calcsize | ||
|
r24046 | propertycache = util.propertycache | ||
|
r17070 | |||
|
r17424 | # the obsolete feature is not mature enough to be enabled by default. | ||
|
r17296 | # you have to rely on third party extension extension to enable this. | ||
_enabled = False | ||||
|
r17070 | |||
|
r22951 | # Options for obsolescence | ||
createmarkersopt = 'createmarkers' | ||||
|
r22952 | allowunstableopt = 'allowunstable' | ||
|
r22953 | exchangeopt = 'exchange' | ||
|
r22951 | |||
|
r34865 | def _getoptionvalue(repo, option): | ||
"""Returns True if the given repository has the given obsolete option | ||||
enabled. | ||||
""" | ||||
configkey = 'evolution.%s' % option | ||||
newconfig = repo.ui.configbool('experimental', configkey) | ||||
# Return the value only if defined | ||||
if newconfig is not None: | ||||
return newconfig | ||||
# Fallback on generic option | ||||
try: | ||||
return repo.ui.configbool('experimental', 'evolution') | ||||
except (error.ConfigError, AttributeError): | ||||
# Fallback on old-fashion config | ||||
# inconsistent config: experimental.evolution | ||||
result = set(repo.ui.configlist('experimental', 'evolution')) | ||||
if 'all' in result: | ||||
return True | ||||
# For migration purposes, temporarily return true if the config hasn't | ||||
# been set but _enabled is true. | ||||
if len(result) == 0 and _enabled: | ||||
return True | ||||
# Temporary hack for next check | ||||
newconfig = repo.ui.config('experimental', 'evolution.createmarkers') | ||||
if newconfig: | ||||
result.add('createmarkers') | ||||
return option in result | ||||
r32333 | def isenabled(repo, option): | |||
"""Returns True if the given repository has the given obsolete option | ||||
enabled. | ||||
""" | ||||
|
r34865 | createmarkersvalue = _getoptionvalue(repo, createmarkersopt) | ||
unstabluevalue = _getoptionvalue(repo, allowunstableopt) | ||||
exchangevalue = _getoptionvalue(repo, exchangeopt) | ||||
r32333 | ||||
# createmarkers must be enabled if other options are enabled | ||||
|
r34865 | if ((unstabluevalue or exchangevalue) and not createmarkersvalue): | ||
r32333 | raise error.Abort(_("'createmarkers' obsolete option must be enabled " | |||
|
r34865 | "if other obsolete options are enabled")) | ||
r32333 | ||||
|
r34865 | return _getoptionvalue(repo, option) | ||
r32333 | ||||
|
r17831 | ### obsolescence marker flag | ||
## bumpedfix flag | ||||
# | ||||
# When a changeset A' succeed to a changeset A which became public, we call A' | ||||
# "bumped" because it's a successors of a public changesets | ||||
# | ||||
# o A' (bumped) | ||||
# |`: | ||||
# | o A | ||||
# |/ | ||||
# o Z | ||||
# | ||||
# The way to solve this situation is to create a new changeset Ad as children | ||||
# of A. This changeset have the same content than A'. So the diff from A to A' | ||||
# is the same than the diff from A to Ad. Ad is marked as a successors of A' | ||||
# | ||||
# o Ad | ||||
# |`: | ||||
# | x A' | ||||
# |'| | ||||
# o | A | ||||
# |/ | ||||
# o Z | ||||
# | ||||
# But by transitivity Ad is also a successors of A. To avoid having Ad marked | ||||
# as bumped too, we add the `bumpedfix` flag to the marker. <A', (Ad,)>. | ||||
|
r18644 | # This flag mean that the successors express the changes between the public and | ||
# bumped version and fix the situation, breaking the transitivity of | ||||
# "bumped" here. | ||||
|
r17831 | bumpedfix = 1 | ||
|
r22850 | usingsha256 = 2 | ||
|
r17831 | |||
|
r22612 | ## Parsing and writing of version "0" | ||
# | ||||
# The header is followed by the markers. Each marker is made of: | ||||
# | ||||
|
r22849 | # - 1 uint8 : number of new changesets "N", can be zero. | ||
|
r22612 | # | ||
|
r22849 | # - 1 uint32: metadata size "M" in bytes. | ||
|
r22612 | # | ||
# - 1 byte: a bit field. It is reserved for flags used in common | ||||
# obsolete marker operations, to avoid repeated decoding of metadata | ||||
# entries. | ||||
# | ||||
# - 20 bytes: obsoleted changeset identifier. | ||||
# | ||||
# - N*20 bytes: new changesets identifiers. | ||||
# | ||||
# - M bytes: metadata as a sequence of nul-terminated strings. Each | ||||
# string contains a key and a value, separated by a colon ':', without | ||||
# additional encoding. Keys cannot contain '\0' or ':' and values | ||||
# cannot contain '\0'. | ||||
_fm0version = 0 | ||||
_fm0fixed = '>BIB20s' | ||||
_fm0node = '20s' | ||||
|
r23498 | _fm0fsize = _calcsize(_fm0fixed) | ||
_fm0fnodesize = _calcsize(_fm0node) | ||||
|
r22334 | |||
|
r33504 | def _fm0readmarkers(data, off, stop): | ||
|
r17070 | # Loop on markers | ||
|
r33504 | while off < stop: | ||
|
r17070 | # read fixed part | ||
|
r22327 | cur = data[off:off + _fm0fsize] | ||
off += _fm0fsize | ||||
|
r22685 | numsuc, mdsize, flags, pre = _unpack(_fm0fixed, cur) | ||
|
r17070 | # read replacement | ||
sucs = () | ||||
|
r22685 | if numsuc: | ||
s = (_fm0fnodesize * numsuc) | ||||
|
r17070 | cur = data[off:off + s] | ||
|
r22685 | sucs = _unpack(_fm0node * numsuc, cur) | ||
|
r17070 | off += s | ||
# read metadata | ||||
# (metadata will be decoded on demand) | ||||
metadata = data[off:off + mdsize] | ||||
if len(metadata) != mdsize: | ||||
|
r26587 | raise error.Abort(_('parsing obsolete marker: metadata is too ' | ||
|
r17070 | 'short, %d bytes expected, got %d') | ||
|
r17253 | % (mdsize, len(metadata))) | ||
|
r17070 | off += mdsize | ||
|
r22847 | metadata = _fm0decodemeta(metadata) | ||
|
r22222 | try: | ||
|
r22845 | when, offset = metadata.pop('date', '0 0').split(' ') | ||
|
r22309 | date = float(when), int(offset) | ||
except ValueError: | ||||
|
r22222 | date = (0., 0) | ||
|
r22258 | parents = None | ||
|
r22845 | if 'p2' in metadata: | ||
parents = (metadata.pop('p1', None), metadata.pop('p2', None)) | ||||
elif 'p1' in metadata: | ||||
parents = (metadata.pop('p1', None),) | ||||
elif 'p0' in metadata: | ||||
|
r22258 | parents = () | ||
if parents is not None: | ||||
try: | ||||
parents = tuple(node.bin(p) for p in parents) | ||||
# if parent content is not a nodeid, drop the data | ||||
for p in parents: | ||||
if len(p) != 20: | ||||
parents = None | ||||
break | ||||
except TypeError: | ||||
# if content cannot be translated to nodeid drop the data. | ||||
parents = None | ||||
|
r22845 | metadata = tuple(sorted(metadata.iteritems())) | ||
|
r22222 | |||
|
r22258 | yield (pre, sucs, flags, metadata, date, parents) | ||
|
r17070 | |||
|
r22330 | def _fm0encodeonemarker(marker): | ||
pre, sucs, flags, metadata, date, parents = marker | ||||
|
r22850 | if flags & usingsha256: | ||
|
r26587 | raise error.Abort(_('cannot handle sha256 with old obsstore format')) | ||
|
r22845 | metadata = dict(metadata) | ||
|
r23002 | time, tz = date | ||
metadata['date'] = '%r %i' % (time, tz) | ||||
|
r22330 | if parents is not None: | ||
if not parents: | ||||
# mark that we explicitly recorded no parents | ||||
metadata['p0'] = '' | ||||
|
r32278 | for i, p in enumerate(parents, 1): | ||
metadata['p%i' % i] = node.hex(p) | ||||
|
r22846 | metadata = _fm0encodemeta(metadata) | ||
|
r22685 | numsuc = len(sucs) | ||
format = _fm0fixed + (_fm0node * numsuc) | ||||
data = [numsuc, len(metadata), flags, pre] | ||||
|
r22330 | data.extend(sucs) | ||
return _pack(format, *data) + metadata | ||||
|
r22848 | def _fm0encodemeta(meta): | ||
"""Return encoded metadata string to string mapping. | ||||
Assume no ':' in key and no '\0' in both key and value.""" | ||||
for key, value in meta.iteritems(): | ||||
if ':' in key or '\0' in key: | ||||
raise ValueError("':' and '\0' are forbidden in metadata key'") | ||||
if '\0' in value: | ||||
raise ValueError("':' is forbidden in metadata value'") | ||||
return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)]) | ||||
def _fm0decodemeta(data): | ||||
"""Return string to string dictionary from encoded version.""" | ||||
d = {} | ||||
for l in data.split('\0'): | ||||
if l: | ||||
key, value = l.split(':') | ||||
d[key] = value | ||||
return d | ||||
|
r22851 | ## Parsing and writing of version "1" | ||
# | ||||
# The header is followed by the markers. Each marker is made of: | ||||
# | ||||
# - uint32: total size of the marker (including this field) | ||||
# | ||||
# - float64: date in seconds since epoch | ||||
# | ||||
# - int16: timezone offset in minutes | ||||
# | ||||
# - uint16: a bit field. It is reserved for flags used in common | ||||
# obsolete marker operations, to avoid repeated decoding of metadata | ||||
# entries. | ||||
# | ||||
# - uint8: number of successors "N", can be zero. | ||||
# | ||||
# - uint8: number of parents "P", can be zero. | ||||
# | ||||
# 0: parents data stored but no parent, | ||||
# 1: one parent stored, | ||||
# 2: two parents stored, | ||||
# 3: no parent data stored | ||||
# | ||||
# - uint8: number of metadata entries M | ||||
# | ||||
|
r33700 | # - 20 or 32 bytes: predecessor changeset identifier. | ||
|
r22851 | # | ||
# - N*(20 or 32) bytes: successors changesets identifiers. | ||||
# | ||||
|
r33700 | # - P*(20 or 32) bytes: parents of the predecessors changesets. | ||
|
r22851 | # | ||
# - M*(uint8, uint8): size of all metadata entries (key and value) | ||||
# | ||||
# - remaining bytes: the metadata, each (key, value) pair after the other. | ||||
_fm1version = 1 | ||||
_fm1fixed = '>IdhHBBB20s' | ||||
_fm1nodesha1 = '20s' | ||||
_fm1nodesha256 = '32s' | ||||
|
r23499 | _fm1nodesha1size = _calcsize(_fm1nodesha1) | ||
_fm1nodesha256size = _calcsize(_fm1nodesha256) | ||||
|
r23498 | _fm1fsize = _calcsize(_fm1fixed) | ||
|
r22851 | _fm1parentnone = 3 | ||
_fm1parentshift = 14 | ||||
_fm1parentmask = (_fm1parentnone << _fm1parentshift) | ||||
_fm1metapair = 'BB' | ||||
|
r33633 | _fm1metapairsize = _calcsize(_fm1metapair) | ||
|
r22851 | |||
|
r33504 | def _fm1purereadmarkers(data, off, stop): | ||
|
r23803 | # make some global constants local for performance | ||
noneflag = _fm1parentnone | ||||
sha2flag = usingsha256 | ||||
sha1size = _fm1nodesha1size | ||||
sha2size = _fm1nodesha256size | ||||
sha1fmt = _fm1nodesha1 | ||||
sha2fmt = _fm1nodesha256 | ||||
metasize = _fm1metapairsize | ||||
metafmt = _fm1metapair | ||||
fsize = _fm1fsize | ||||
unpack = _unpack | ||||
|
r22851 | # Loop on markers | ||
|
r25211 | ufixed = struct.Struct(_fm1fixed).unpack | ||
|
r24018 | |||
|
r33504 | while off < stop: | ||
|
r22851 | # read fixed part | ||
|
r23803 | o1 = off + fsize | ||
|
r23800 | t, secs, tz, flags, numsuc, numpar, nummeta, prec = ufixed(data[off:o1]) | ||
|
r23792 | |||
|
r23803 | if flags & sha2flag: | ||
|
r23805 | # FIXME: prec was read as a SHA1, needs to be amended | ||
|
r23801 | # read 0 or more successors | ||
|
r23804 | if numsuc == 1: | ||
o2 = o1 + sha2size | ||||
sucs = (data[o1:o2],) | ||||
else: | ||||
o2 = o1 + sha2size * numsuc | ||||
sucs = unpack(sha2fmt * numsuc, data[o1:o2]) | ||||
|
r23792 | |||
|
r23801 | # read parents | ||
|
r23803 | if numpar == noneflag: | ||
|
r23801 | o3 = o2 | ||
parents = None | ||||
|
r23804 | elif numpar == 1: | ||
o3 = o2 + sha2size | ||||
parents = (data[o2:o3],) | ||||
|
r23801 | else: | ||
|
r23803 | o3 = o2 + sha2size * numpar | ||
parents = unpack(sha2fmt * numpar, data[o2:o3]) | ||||
|
r23801 | else: | ||
# read 0 or more successors | ||||
|
r23804 | if numsuc == 1: | ||
o2 = o1 + sha1size | ||||
sucs = (data[o1:o2],) | ||||
else: | ||||
o2 = o1 + sha1size * numsuc | ||||
sucs = unpack(sha1fmt * numsuc, data[o1:o2]) | ||||
|
r23792 | |||
|
r23801 | # read parents | ||
|
r23803 | if numpar == noneflag: | ||
|
r23801 | o3 = o2 | ||
parents = None | ||||
|
r23804 | elif numpar == 1: | ||
o3 = o2 + sha1size | ||||
parents = (data[o2:o3],) | ||||
|
r23801 | else: | ||
|
r23803 | o3 = o2 + sha1size * numpar | ||
parents = unpack(sha1fmt * numpar, data[o2:o3]) | ||||
|
r23792 | |||
|
r22851 | # read metadata | ||
|
r23803 | off = o3 + metasize * nummeta | ||
metapairsize = unpack('>' + (metafmt * nummeta), data[o3:off]) | ||||
|
r22851 | metadata = [] | ||
for idx in xrange(0, len(metapairsize), 2): | ||||
|
r23798 | o1 = off + metapairsize[idx] | ||
o2 = o1 + metapairsize[idx + 1] | ||||
metadata.append((data[off:o1], data[o1:o2])) | ||||
off = o2 | ||||
|
r22851 | |||
|
r23800 | yield (prec, sucs, flags, tuple(metadata), (secs, tz * 60), parents) | ||
|
r22851 | |||
def _fm1encodeonemarker(marker): | ||||
pre, sucs, flags, metadata, date, parents = marker | ||||
# determine node size | ||||
_fm1node = _fm1nodesha1 | ||||
if flags & usingsha256: | ||||
_fm1node = _fm1nodesha256 | ||||
numsuc = len(sucs) | ||||
numextranodes = numsuc | ||||
if parents is None: | ||||
numpar = _fm1parentnone | ||||
else: | ||||
numpar = len(parents) | ||||
numextranodes += numpar | ||||
formatnodes = _fm1node * numextranodes | ||||
formatmeta = _fm1metapair * len(metadata) | ||||
format = _fm1fixed + formatnodes + formatmeta | ||||
# tz is stored in minutes so we divide by 60 | ||||
tz = date[1]//60 | ||||
data = [None, date[0], tz, flags, numsuc, numpar, len(metadata), pre] | ||||
data.extend(sucs) | ||||
if parents is not None: | ||||
data.extend(parents) | ||||
|
r23498 | totalsize = _calcsize(format) | ||
|
r22851 | for key, value in metadata: | ||
lk = len(key) | ||||
lv = len(value) | ||||
|
r34408 | if lk > 255: | ||
msg = ('obsstore metadata key cannot be longer than 255 bytes' | ||||
' (key "%s" is %u bytes)') % (key, lk) | ||||
raise error.ProgrammingError(msg) | ||||
if lv > 255: | ||||
msg = ('obsstore metadata value cannot be longer than 255 bytes' | ||||
' (value "%s" for key "%s" is %u bytes)') % (value, key, lv) | ||||
raise error.ProgrammingError(msg) | ||||
|
r22851 | data.append(lk) | ||
data.append(lv) | ||||
totalsize += lk + lv | ||||
data[0] = totalsize | ||||
data = [_pack(format, *data)] | ||||
for key, value in metadata: | ||||
data.append(key) | ||||
data.append(value) | ||||
return ''.join(data) | ||||
|
r22848 | |||
|
r33504 | def _fm1readmarkers(data, off, stop): | ||
|
r24019 | native = getattr(parsers, 'fm1readmarkers', None) | ||
if not native: | ||||
|
r33504 | return _fm1purereadmarkers(data, off, stop) | ||
|
r24019 | return native(data, off, stop) | ||
|
r22331 | # mapping to read/write various marker formats | ||
# <version> -> (decoder, encoder) | ||||
|
r22851 | formats = {_fm0version: (_fm0readmarkers, _fm0encodeonemarker), | ||
_fm1version: (_fm1readmarkers, _fm1encodeonemarker)} | ||||
|
r22331 | |||
|
r32689 | def _readmarkerversion(data): | ||
return _unpack('>B', data[0:1])[0] | ||||
|
r23497 | @util.nogc | ||
|
r33504 | def _readmarkers(data, off=None, stop=None): | ||
|
r22612 | """Read and enumerate markers from raw data""" | ||
|
r32689 | diskversion = _readmarkerversion(data) | ||
|
r33504 | if not off: | ||
off = 1 # skip 1 byte version number | ||||
if stop is None: | ||||
stop = len(data) | ||||
|
r22612 | if diskversion not in formats: | ||
r32591 | msg = _('parsing obsolete marker: unknown version %r') % diskversion | |||
raise error.UnknownVersion(msg, version=diskversion) | ||||
|
r33504 | return diskversion, formats[diskversion][0](data, off, stop) | ||
|
r22612 | |||
|
r32692 | def encodeheader(version=_fm0version): | ||
return _pack('>B', version) | ||||
|
r22612 | def encodemarkers(markers, addheader=False, version=_fm0version): | ||
# Kept separate from flushmarkers(), it will be reused for | ||||
# markers exchange. | ||||
encodeone = formats[version][1] | ||||
if addheader: | ||||
|
r32692 | yield encodeheader(version) | ||
|
r22612 | for marker in markers: | ||
yield encodeone(marker) | ||||
|
r24044 | @util.nogc | ||
def _addsuccessors(successors, markers): | ||||
for mark in markers: | ||||
successors.setdefault(mark[0], set()).add(mark) | ||||
|
r33698 | def _addprecursors(*args, **kwargs): | ||
msg = ("'obsolete._addprecursors' is deprecated, " | ||||
"use 'obsolete._addpredecessors'") | ||||
util.nouideprecwarn(msg, '4.4') | ||||
return _addpredecessors(*args, **kwargs) | ||||
|
r24044 | @util.nogc | ||
|
r33698 | def _addpredecessors(predecessors, markers): | ||
|
r24044 | for mark in markers: | ||
for suc in mark[1]: | ||||
|
r33698 | predecessors.setdefault(suc, set()).add(mark) | ||
|
r24044 | |||
@util.nogc | ||||
def _addchildren(children, markers): | ||||
for mark in markers: | ||||
parents = mark[5] | ||||
if parents is not None: | ||||
for p in parents: | ||||
children.setdefault(p, set()).add(mark) | ||||
|
r24045 | def _checkinvalidmarkers(markers): | ||
|
r23973 | """search for marker with invalid data and raise error if needed | ||
Exist as a separated function to allow the evolve extension for a more | ||||
subtle handling. | ||||
""" | ||||
|
r24045 | for mark in markers: | ||
if node.nullid in mark[1]: | ||||
|
r26587 | raise error.Abort(_('bad obsolescence marker detected: ' | ||
|
r24045 | 'invalid successors nullid')) | ||
|
r23973 | |||
|
r17070 | class obsstore(object): | ||
"""Store obsolete markers | ||||
Markers can be accessed with two mappings: | ||||
|
r33700 | - predecessors[x] -> set(markers on predecessors edges of x) | ||
|
r17776 | - successors[x] -> set(markers on successors edges of x) | ||
|
r33700 | - children[x] -> set(markers on predecessors edges of children(x) | ||
|
r17070 | """ | ||
|
r22254 | fields = ('prec', 'succs', 'flag', 'meta', 'date', 'parents') | ||
|
r33700 | # prec: nodeid, predecessors changesets | ||
|
r22254 | # succs: tuple of nodeid, successor changesets (0-N length) | ||
# flag: integer, flag field carrying modifier for the markers (see doc) | ||||
# meta: binary blob, encoded metadata dictionary | ||||
# date: (float, int) tuple, date of marker creation | ||||
|
r33700 | # parents: (tuple of nodeid) or None, parents of predecessors | ||
|
r22254 | # None is used when no data has been recorded | ||
|
r22221 | |||
|
r25669 | def __init__(self, svfs, defaultformat=_fm1version, readonly=False): | ||
|
r17469 | # caches for various obsolescence related cache | ||
self.caches = {} | ||||
|
r25669 | self.svfs = svfs | ||
|
r32691 | self._defaultformat = defaultformat | ||
|
r22950 | self._readonly = readonly | ||
|
r17070 | |||
|
r17073 | def __iter__(self): | ||
return iter(self._all) | ||||
|
r20585 | def __len__(self): | ||
return len(self._all) | ||||
|
r17075 | def __nonzero__(self): | ||
|
r26310 | if not self._cached('_all'): | ||
try: | ||||
return self.svfs.stat('obsstore').st_size > 1 | ||||
except OSError as inst: | ||||
if inst.errno != errno.ENOENT: | ||||
raise | ||||
# just build an empty _all list if no obsstore exists, which | ||||
# avoids further stat() syscalls | ||||
|
r17075 | return bool(self._all) | ||
|
r31476 | __bool__ = __nonzero__ | ||
|
r26684 | @property | ||
def readonly(self): | ||||
"""True if marker creation is disabled | ||||
Remove me in the future when obsolete marker is always on.""" | ||||
return self._readonly | ||||
|
r22255 | def create(self, transaction, prec, succs=(), flag=0, parents=None, | ||
|
r32411 | date=None, metadata=None, ui=None): | ||
|
r17071 | """obsolete: add a new obsolete marker | ||
* ensuring it is hashable | ||||
* check mandatory metadata | ||||
* encode metadata | ||||
|
r20516 | |||
If you are a human writing code creating marker you want to use the | ||||
`createmarkers` function in this module instead. | ||||
|
r20584 | |||
return True if a new marker have been added, False if the markers | ||||
already existed (no op). | ||||
|
r17071 | """ | ||
if metadata is None: | ||||
metadata = {} | ||||
|
r22222 | if date is None: | ||
if 'date' in metadata: | ||||
# as a courtesy for out-of-tree extensions | ||||
date = util.parsedate(metadata.pop('date')) | ||||
|
r32411 | elif ui is not None: | ||
date = ui.configdate('devel', 'default-date') | ||||
if date is None: | ||||
date = util.makedate() | ||||
|
r22222 | else: | ||
|
r22217 | date = util.makedate() | ||
|
r17071 | if len(prec) != 20: | ||
raise ValueError(prec) | ||||
for succ in succs: | ||||
if len(succ) != 20: | ||||
|
r17117 | raise ValueError(succ) | ||
|
r22177 | if prec in succs: | ||
raise ValueError(_('in-marker cycle with %s') % node.hex(prec)) | ||||
|
r22845 | |||
metadata = tuple(sorted(metadata.iteritems())) | ||||
|
r33685 | marker = (bytes(prec), tuple(succs), int(flag), metadata, date, parents) | ||
|
r20584 | return bool(self.add(transaction, [marker])) | ||
|
r17220 | |||
def add(self, transaction, markers): | ||||
"""Add new markers to the store | ||||
|
r17070 | |||
|
r17220 | Take care of filtering duplicate. | ||
Return the number of new marker.""" | ||||
|
r22950 | if self._readonly: | ||
|
r29389 | raise error.Abort(_('creating obsolete markers is not enabled on ' | ||
'this repo')) | ||||
|
r32774 | known = set() | ||
getsuccessors = self.successors.get | ||||
|
r20030 | new = [] | ||
for m in markers: | ||||
|
r32774 | if m not in getsuccessors(m[0], ()) and m not in known: | ||
|
r20030 | known.add(m) | ||
new.append(m) | ||||
|
r17220 | if new: | ||
|
r25669 | f = self.svfs('obsstore', 'ab') | ||
|
r17124 | try: | ||
|
r17126 | offset = f.tell() | ||
transaction.add('obsstore', offset) | ||||
|
r17219 | # offset == 0: new file - add the version header | ||
|
r33479 | data = b''.join(encodemarkers(new, offset == 0, self._version)) | ||
f.write(data) | ||||
|
r17126 | finally: | ||
# XXX: f.close() == filecache invalidation == obsstore rebuilt. | ||||
# call 'filecacheentry.refresh()' here | ||||
|
r17124 | f.close() | ||
r33248 | addedmarkers = transaction.changes.get('obsmarkers') | |||
if addedmarkers is not None: | ||||
addedmarkers.update(new) | ||||
|
r33479 | self._addmarkers(new, data) | ||
|
r17469 | # new marker *may* have changed several set. invalidate the cache. | ||
self.caches.clear() | ||||
|
r22339 | # records the number of new markers for the transaction hooks | ||
previous = int(transaction.hookargs.get('new_obsmarkers', '0')) | ||||
transaction.hookargs['new_obsmarkers'] = str(previous + len(new)) | ||||
|
r17220 | return len(new) | ||
|
r17126 | |||
|
r17524 | def mergemarkers(self, transaction, data): | ||
|
r22325 | """merge a binary stream of markers inside the obsstore | ||
Returns the number of new markers added.""" | ||||
|
r22332 | version, markers = _readmarkers(data) | ||
|
r22325 | return self.add(transaction, markers) | ||
|
r17070 | |||
|
r24046 | @propertycache | ||
|
r32690 | def _data(self): | ||
return self.svfs.tryread('obsstore') | ||||
@propertycache | ||||
|
r32691 | def _version(self): | ||
if len(self._data) >= 1: | ||||
return _readmarkerversion(self._data) | ||||
else: | ||||
return self._defaultformat | ||||
@propertycache | ||||
|
r26309 | def _all(self): | ||
|
r32690 | data = self._data | ||
|
r26309 | if not data: | ||
return [] | ||||
self._version, markers = _readmarkers(data) | ||||
markers = list(markers) | ||||
_checkinvalidmarkers(markers) | ||||
return markers | ||||
@propertycache | ||||
|
r24046 | def successors(self): | ||
successors = {} | ||||
_addsuccessors(successors, self._all) | ||||
return successors | ||||
|
r33699 | @property | ||
def precursors(self): | ||||
msg = ("'obsstore.precursors' is deprecated, " | ||||
"use 'obsstore.predecessors'") | ||||
util.nouideprecwarn(msg, '4.4') | ||||
return self.predecessors | ||||
|
r24046 | @propertycache | ||
|
r33699 | def predecessors(self): | ||
|
r33698 | predecessors = {} | ||
_addpredecessors(predecessors, self._all) | ||||
return predecessors | ||||
|
r24046 | |||
@propertycache | ||||
def children(self): | ||||
children = {} | ||||
_addchildren(children, self._all) | ||||
return children | ||||
def _cached(self, attr): | ||||
return attr in self.__dict__ | ||||
|
r33479 | def _addmarkers(self, markers, rawdata): | ||
|
r24044 | markers = list(markers) # to allow repeated iteration | ||
|
r33479 | self._data = self._data + rawdata | ||
|
r24044 | self._all.extend(markers) | ||
|
r24046 | if self._cached('successors'): | ||
_addsuccessors(self.successors, markers) | ||||
|
r33699 | if self._cached('predecessors'): | ||
_addpredecessors(self.predecessors, markers) | ||||
|
r24046 | if self._cached('children'): | ||
_addchildren(self.children, markers) | ||||
|
r24045 | _checkinvalidmarkers(markers) | ||
|
r23973 | |||
|
r22271 | def relevantmarkers(self, nodes): | ||
"""return a set of all obsolescence markers relevant to a set of nodes. | ||||
"relevant" to a set of nodes mean: | ||||
- marker that use this changeset as successor | ||||
- prune marker of direct children on this changeset | ||||
|
r33700 | - recursive application of the two rules on predecessors of these | ||
markers | ||||
|
r22271 | |||
It is a set so you cannot rely on order.""" | ||||
pendingnodes = set(nodes) | ||||
seenmarkers = set() | ||||
seennodes = set(pendingnodes) | ||||
|
r33699 | precursorsmarkers = self.predecessors | ||
r32488 | succsmarkers = self.successors | |||
|
r22271 | children = self.children | ||
while pendingnodes: | ||||
direct = set() | ||||
for current in pendingnodes: | ||||
direct.update(precursorsmarkers.get(current, ())) | ||||
pruned = [m for m in children.get(current, ()) if not m[1]] | ||||
direct.update(pruned) | ||||
r32488 | pruned = [m for m in succsmarkers.get(current, ()) if not m[1]] | |||
direct.update(pruned) | ||||
|
r22271 | direct -= seenmarkers | ||
pendingnodes = set([m[0] for m in direct]) | ||||
seenmarkers |= direct | ||||
pendingnodes -= seennodes | ||||
seennodes |= pendingnodes | ||||
return seenmarkers | ||||
|
r17070 | |||
|
r32729 | def makestore(ui, repo): | ||
"""Create an obsstore instance from a repo.""" | ||||
# read default format for new obsstore. | ||||
# developer config: format.obsstore-version | ||||
r33241 | defaultformat = ui.configint('format', 'obsstore-version') | |||
|
r32729 | # rely on obsstore class default when possible. | ||
kwargs = {} | ||||
if defaultformat is not None: | ||||
kwargs['defaultformat'] = defaultformat | ||||
readonly = not isenabled(repo, createmarkersopt) | ||||
store = obsstore(repo.svfs, readonly=readonly, **kwargs) | ||||
if store and readonly: | ||||
ui.warn(_('obsolete feature not enabled but %i markers found!\n') | ||||
% len(list(store))) | ||||
return store | ||||
|
r22345 | def commonversion(versions): | ||
"""Return the newest version listed in both versions and our local formats. | ||||
Returns None if no common version exists. | ||||
""" | ||||
versions.sort(reverse=True) | ||||
# search for highest version known on both side | ||||
for v in versions: | ||||
if v in formats: | ||||
return v | ||||
return None | ||||
|
r17295 | |||
# arbitrary picked to fit into 8K limit from HTTP server | ||||
# you have to take in account: | ||||
# - the version header | ||||
# - the base85 encoding | ||||
_maxpayload = 5300 | ||||
|
r17075 | |||
|
r20599 | def _pushkeyescape(markers): | ||
"""encode markers into a dict suitable for pushkey exchange | ||||
|
r21024 | - binary data is base85 encoded | ||
- split in chunks smaller than 5300 bytes""" | ||||
|
r17295 | keys = {} | ||
parts = [] | ||||
currentlen = _maxpayload * 2 # ensure we create a new part | ||||
|
r20599 | for marker in markers: | ||
|
r22329 | nextdata = _fm0encodeonemarker(marker) | ||
|
r17295 | if (len(nextdata) + currentlen > _maxpayload): | ||
currentpart = [] | ||||
currentlen = 0 | ||||
parts.append(currentpart) | ||||
currentpart.append(nextdata) | ||||
|
r17304 | currentlen += len(nextdata) | ||
|
r17295 | for idx, part in enumerate(reversed(parts)): | ||
|
r22327 | data = ''.join([_pack('>B', _fm0version)] + part) | ||
|
r32200 | keys['dump%i' % idx] = util.b85encode(data) | ||
|
r17295 | return keys | ||
|
r17073 | |||
|
r20599 | def listmarkers(repo): | ||
"""List markers over pushkey""" | ||||
if not repo.obsstore: | ||||
return {} | ||||
|
r25118 | return _pushkeyescape(sorted(repo.obsstore)) | ||
|
r20599 | |||
|
r17075 | def pushmarker(repo, key, old, new): | ||
"""Push markers over pushkey""" | ||||
|
r17295 | if not key.startswith('dump'): | ||
|
r17075 | repo.ui.warn(_('unknown key: %r') % key) | ||
|
r32822 | return False | ||
|
r17075 | if old: | ||
|
r21098 | repo.ui.warn(_('unexpected old value for %r') % key) | ||
|
r32822 | return False | ||
|
r32200 | data = util.b85decode(new) | ||
|
r17075 | lock = repo.lock() | ||
try: | ||||
|
r17126 | tr = repo.transaction('pushkey: obsolete markers') | ||
try: | ||||
repo.obsstore.mergemarkers(tr, data) | ||||
r32314 | repo.invalidatevolatilesets() | |||
|
r17126 | tr.close() | ||
|
r32822 | return True | ||
|
r17126 | finally: | ||
tr.release() | ||||
|
r17075 | finally: | ||
lock.release() | ||||
|
r17073 | |||
r33145 | # keep compatibility for the 4.3 cycle | |||
def allprecursors(obsstore, nodes, ignoreflags=0): | ||||
movemsg = 'obsolete.allprecursors moved to obsutil.allprecursors' | ||||
util.nouideprecwarn(movemsg, '4.3') | ||||
return obsutil.allprecursors(obsstore, nodes, ignoreflags) | ||||
r33146 | def allsuccessors(obsstore, nodes, ignoreflags=0): | |||
movemsg = 'obsolete.allsuccessors moved to obsutil.allsuccessors' | ||||
util.nouideprecwarn(movemsg, '4.3') | ||||
return obsutil.allsuccessors(obsstore, nodes, ignoreflags) | ||||
r33149 | def marker(repo, data): | |||
movemsg = 'obsolete.marker moved to obsutil.marker' | ||||
repo.ui.deprecwarn(movemsg, '4.3') | ||||
return obsutil.marker(repo, data) | ||||
r33150 | def getmarkers(repo, nodes=None, exclusive=False): | |||
movemsg = 'obsolete.getmarkers moved to obsutil.getmarkers' | ||||
repo.ui.deprecwarn(movemsg, '4.3') | ||||
return obsutil.getmarkers(repo, nodes=nodes, exclusive=exclusive) | ||||
r33144 | def exclusivemarkers(repo, nodes): | |||
movemsg = 'obsolete.exclusivemarkers moved to obsutil.exclusivemarkers' | ||||
repo.ui.deprecwarn(movemsg, '4.3') | ||||
return obsutil.exclusivemarkers(repo, nodes) | ||||
r33147 | def foreground(repo, nodes): | |||
movemsg = 'obsolete.foreground moved to obsutil.foreground' | ||||
repo.ui.deprecwarn(movemsg, '4.3') | ||||
return obsutil.foreground(repo, nodes) | ||||
|
r18068 | def successorssets(repo, initialnode, cache=None): | ||
r33143 | movemsg = 'obsolete.successorssets moved to obsutil.successorssets' | |||
repo.ui.deprecwarn(movemsg, '4.3') | ||||
return obsutil.successorssets(repo, initialnode, cache=cache) | ||||
|
r18068 | |||
|
r17828 | # mapping of 'set-name' -> <function to compute this set> | ||
|
r17469 | cachefuncs = {} | ||
def cachefor(name): | ||||
"""Decorator to register a function as computing the cache for a set""" | ||||
def decorator(func): | ||||
|
r32884 | if name in cachefuncs: | ||
msg = "duplicated registration for volatileset '%s' (existing: %r)" | ||||
raise error.ProgrammingError(msg % (name, cachefuncs[name])) | ||||
|
r17469 | cachefuncs[name] = func | ||
return func | ||||
return decorator | ||||
|
r17825 | def getrevs(repo, name): | ||
|
r17469 | """Return the set of revision that belong to the <name> set | ||
Such access may compute the set and cache it for future use""" | ||||
|
r18001 | repo = repo.unfiltered() | ||
|
r17469 | if not repo.obsstore: | ||
|
r22507 | return frozenset() | ||
|
r17469 | if name not in repo.obsstore.caches: | ||
repo.obsstore.caches[name] = cachefuncs[name](repo) | ||||
return repo.obsstore.caches[name] | ||||
# To be simple we need to invalidate obsolescence cache when: | ||||
# | ||||
# - new changeset is added: | ||||
# - public phase is changed | ||||
# - obsolescence marker are added | ||||
# - strip is used a repo | ||||
def clearobscaches(repo): | ||||
"""Remove all obsolescence related cache from a repo | ||||
This remove all cache in obsstore is the obsstore already exist on the | ||||
repo. | ||||
(We could be smarter here given the exact event that trigger the cache | ||||
clearing)""" | ||||
# only clear cache is there is obsstore data in this repo | ||||
if 'obsstore' in repo._filecache: | ||||
repo.obsstore.caches.clear() | ||||
r33124 | def _mutablerevs(repo): | |||
"""the set of mutable revision in the repository""" | ||||
return repo._phasecache.getrevset(repo, (phases.draft, phases.secret)) | ||||
|
r17469 | @cachefor('obsolete') | ||
def _computeobsoleteset(repo): | ||||
"""the set of obsolete revisions""" | ||||
|
r27784 | getnode = repo.changelog.node | ||
r33124 | notpublic = _mutablerevs(repo) | |||
|
r32688 | isobs = repo.obsstore.successors.__contains__ | ||
obs = set(r for r in notpublic if isobs(getnode(r))) | ||||
|
r18271 | return obs | ||
|
r17469 | |||
@cachefor('unstable') | ||||
def _computeunstableset(repo): | ||||
|
r33772 | msg = ("'unstable' volatile set is deprecated, " | ||
"use 'orphan'") | ||||
repo.ui.deprecwarn(msg, '4.4') | ||||
return _computeorphanset(repo) | ||||
@cachefor('orphan') | ||||
def _computeorphanset(repo): | ||||
|
r17469 | """the set of non obsolete revisions with obsolete parents""" | ||
r33125 | pfunc = repo.changelog.parentrevs | |||
mutable = _mutablerevs(repo) | ||||
obsolete = getrevs(repo, 'obsolete') | ||||
others = mutable - obsolete | ||||
|
r24928 | unstable = set() | ||
r33125 | for r in sorted(others): | |||
|
r24928 | # A rev is unstable if one of its parent is obsolete or unstable | ||
# this works since we traverse following growing rev order | ||||
r33125 | for p in pfunc(r): | |||
if p in obsolete or p in unstable: | ||||
unstable.add(r) | ||||
break | ||||
|
r24928 | return unstable | ||
|
r17469 | |||
@cachefor('suspended') | ||||
def _computesuspendedset(repo): | ||||
"""the set of obsolete parents with non obsolete descendants""" | ||||
|
r33772 | suspended = repo.changelog.ancestors(getrevs(repo, 'orphan')) | ||
|
r18276 | return set(r for r in getrevs(repo, 'obsolete') if r in suspended) | ||
|
r17469 | |||
@cachefor('extinct') | ||||
def _computeextinctset(repo): | ||||
"""the set of obsolete parents without non obsolete descendants""" | ||||
|
r18277 | return getrevs(repo, 'obsolete') - getrevs(repo, 'suspended') | ||
|
r17474 | |||
|
r17828 | @cachefor('bumped') | ||
def _computebumpedset(repo): | ||||
|
r33774 | msg = ("'bumped' volatile set is deprecated, " | ||
"use 'phasedivergent'") | ||||
repo.ui.deprecwarn(msg, '4.4') | ||||
return _computephasedivergentset(repo) | ||||
@cachefor('phasedivergent') | ||||
def _computephasedivergentset(repo): | ||||
|
r17828 | """the set of revs trying to obsolete public revisions""" | ||
|
r20207 | bumped = set() | ||
|
r21024 | # util function (avoid attribute lookup in the loop) | ||
|
r20207 | phase = repo._phasecache.phase # would be faster to grab the full list | ||
public = phases.public | ||||
cl = repo.changelog | ||||
torev = cl.nodemap.get | ||||
|
r24927 | for ctx in repo.set('(not public()) and (not obsolete())'): | ||
rev = ctx.rev() | ||||
|
r20207 | # We only evaluate mutable, non-obsolete revision | ||
|
r24927 | node = ctx.node() | ||
|
r33700 | # (future) A cache of predecessors may worth if split is very common | ||
|
r33701 | for pnode in obsutil.allpredecessors(repo.obsstore, [node], | ||
|
r24927 | ignoreflags=bumpedfix): | ||
prev = torev(pnode) # unfiltered! but so is phasecache | ||||
if (prev is not None) and (phase(repo, prev) <= public): | ||||
|
r33700 | # we have a public predecessor | ||
|
r24927 | bumped.add(rev) | ||
break # Next draft! | ||||
|
r20207 | return bumped | ||
|
r17828 | |||
|
r18070 | @cachefor('divergent') | ||
def _computedivergentset(repo): | ||||
|
r33773 | msg = ("'divergent' volatile set is deprecated, " | ||
"use 'contentdivergent'") | ||||
repo.ui.deprecwarn(msg, '4.4') | ||||
return _computecontentdivergentset(repo) | ||||
@cachefor('contentdivergent') | ||||
def _computecontentdivergentset(repo): | ||||
|
r18070 | """the set of rev that compete to be the final successors of some revision. | ||
""" | ||||
divergent = set() | ||||
obsstore = repo.obsstore | ||||
newermap = {} | ||||
for ctx in repo.set('(not public()) - obsolete()'): | ||||
|
r33699 | mark = obsstore.predecessors.get(ctx.node(), ()) | ||
|
r18070 | toprocess = set(mark) | ||
|
r24393 | seen = set() | ||
|
r18070 | while toprocess: | ||
prec = toprocess.pop()[0] | ||||
|
r24393 | if prec in seen: | ||
continue # emergency cycle hanging prevention | ||||
seen.add(prec) | ||||
|
r18070 | if prec not in newermap: | ||
|
r33273 | obsutil.successorssets(repo, prec, cache=newermap) | ||
|
r18070 | newer = [n for n in newermap[prec] if n] | ||
if len(newer) > 1: | ||||
divergent.add(ctx.rev()) | ||||
break | ||||
|
r33699 | toprocess.update(obsstore.predecessors.get(prec, ())) | ||
|
r18070 | return divergent | ||
|
r32327 | def createmarkers(repo, relations, flag=0, date=None, metadata=None, | ||
operation=None): | ||||
|
r17474 | """Add obsolete markers between changesets in a repo | ||
|
r20517 | <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}]) | ||
|
r21024 | tuple. `old` and `news` are changectx. metadata is an optional dictionary | ||
|
r20517 | containing metadata for this marker only. It is merged with the global | ||
metadata specified through the `metadata` argument of this function, | ||||
|
r17474 | |||
Trying to obsolete a public changeset will raise an exception. | ||||
Current user and date are used except if specified otherwise in the | ||||
metadata attribute. | ||||
This function operates within a transaction of its own, but does | ||||
not take any lock on the repo. | ||||
""" | ||||
# prepare metadata | ||||
if metadata is None: | ||||
metadata = {} | ||||
if 'user' not in metadata: | ||||
|
r34576 | develuser = repo.ui.config('devel', 'user.obsmarker') | ||
if develuser: | ||||
metadata['user'] = develuser | ||||
else: | ||||
metadata['user'] = repo.ui.username() | ||||
|
r34389 | |||
# Operation metadata handling | ||||
r32354 | useoperation = repo.ui.configbool('experimental', | |||
|
r34864 | 'evolution.track-operation') | ||
r32354 | if useoperation and operation: | |||
|
r32327 | metadata['operation'] = operation | ||
|
r34389 | |||
|
r34414 | # Effect flag metadata handling | ||
saveeffectflag = repo.ui.configbool('experimental', | ||||
|
r34828 | 'effect-flags') | ||
|
r34414 | |||
|
r17474 | tr = repo.transaction('add-obsolescence-marker') | ||
try: | ||||
|
r27984 | markerargs = [] | ||
|
r20517 | for rel in relations: | ||
prec = rel[0] | ||||
sucs = rel[1] | ||||
localmetadata = metadata.copy() | ||||
if 2 < len(rel): | ||||
localmetadata.update(rel[2]) | ||||
|
r17474 | if not prec.mutable(): | ||
|
r29389 | raise error.Abort(_("cannot obsolete public changeset: %s") | ||
|
r25412 | % prec, | ||
|
r29976 | hint="see 'hg help phases' for details") | ||
|
r17474 | nprec = prec.node() | ||
nsucs = tuple(s.node() for s in sucs) | ||||
|
r22256 | npare = None | ||
if not nsucs: | ||||
npare = tuple(p.node() for p in prec.parents()) | ||||
|
r17474 | if nprec in nsucs: | ||
|
r29389 | raise error.Abort(_("changeset %s cannot obsolete itself") | ||
% prec) | ||||
|
r27984 | |||
|
r34414 | # Effect flag can be different by relation | ||
if saveeffectflag: | ||||
# The effect flag is saved in a versioned field name for future | ||||
# evolution | ||||
effectflag = obsutil.geteffectflag(rel) | ||||
localmetadata[obsutil.EFFECTFLAGFIELD] = "%d" % effectflag | ||||
|
r27984 | # Creating the marker causes the hidden cache to become invalid, | ||
# which causes recomputation when we ask for prec.parents() above. | ||||
# Resulting in n^2 behavior. So let's prepare all of the args | ||||
# first, then create the markers. | ||||
markerargs.append((nprec, nsucs, npare, localmetadata)) | ||||
for args in markerargs: | ||||
nprec, nsucs, npare, localmetadata = args | ||||
|
r22256 | repo.obsstore.create(tr, nprec, nsucs, flag, parents=npare, | ||
|
r32411 | date=date, metadata=localmetadata, | ||
ui=repo.ui) | ||||
|
r18101 | repo.filteredrevcache.clear() | ||
|
r17474 | tr.close() | ||
finally: | ||||
tr.release() | ||||