2019-11-01 22:33:28 +03:00
|
|
|
# Portions Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
#
|
|
|
|
# This software may be used and distributed according to the terms of the
|
|
|
|
# GNU General Public License version 2.
|
|
|
|
|
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
|
|
|
|
2015-12-22 08:35:46 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2015-09-04 12:57:58 +03:00
|
|
|
import heapq
|
2017-05-29 04:29:58 +03:00
|
|
|
import itertools
|
2015-12-22 08:35:46 +03:00
|
|
|
import os
|
|
|
|
import struct
|
|
|
|
|
2020-02-22 00:48:20 +03:00
|
|
|
from edenscmnative import parsers
|
|
|
|
|
|
|
|
from . import error, mdiff, pycompat, revlog, util
|
2015-12-22 08:35:46 +03:00
|
|
|
from .i18n import _
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
from .node import bin, hex
|
2020-01-29 18:38:41 +03:00
|
|
|
from .pycompat import encodeutf8, unicode
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
|
|
|
|
2015-03-14 01:19:54 +03:00
|
|
|
propertycache = util.propertycache
|
2015-03-07 19:42:05 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2019-03-26 23:28:13 +03:00
|
|
|
def _parse(data):
|
|
|
|
"""Generates (path, node, flags) tuples from a manifest text"""
|
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.
|
2020-02-18 01:47:28 +03:00
|
|
|
if data and data[-1:] != b"\n":
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise ValueError("Manifest did not end in a newline.")
|
2015-03-28 01:02:43 +03:00
|
|
|
prev = None
|
|
|
|
for l in data.splitlines():
|
|
|
|
if prev is not None and prev > l:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise ValueError("Manifest lines not in sorted order.")
|
2015-03-28 01:02:43 +03:00
|
|
|
prev = l
|
2020-02-18 01:47:28 +03:00
|
|
|
f, n = pycompat.decodeutf8(l).split("\0")
|
2015-03-28 01:02:43 +03:00
|
|
|
if len(n) > 40:
|
2017-03-12 10:30:15 +03:00
|
|
|
yield f, bin(n[:40]), n[40:]
|
2015-03-28 01:02:43 +03:00
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
yield f, bin(n), ""
|
|
|
|
|
2015-03-28 01:02:43 +03:00
|
|
|
|
2019-03-26 23:28:13 +03:00
|
|
|
def _text(it):
|
2015-03-28 01:37:46 +03:00
|
|
|
"""Given an iterator over (path, node, flags) tuples, returns a manifest
|
|
|
|
text"""
|
|
|
|
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)
|
2020-02-18 01:47:28 +03:00
|
|
|
return pycompat.encodeutf8("".join(lines))
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-28 01:37:46 +03:00
|
|
|
|
2016-09-12 14:37:14 +03:00
|
|
|
def unhexlify(data, extra, pos, length):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
s = bin(data[pos : pos + length])
|
2016-09-12 14:37:14 +03:00
|
|
|
if extra:
|
2018-10-01 17:15:19 +03:00
|
|
|
s += chr(extra & 0xFF)
|
2016-09-12 14:37:14 +03:00
|
|
|
return s
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-09-12 14:37:14 +03:00
|
|
|
def _cmp(a, b):
|
|
|
|
return (a > b) - (a < b)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2020-01-29 18:38:41 +03:00
|
|
|
_lazymanifest = parsers.lazymanifest
|
2015-03-07 05:29:47 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
class manifestdict(object):
|
2020-01-29 18:38:41 +03:00
|
|
|
def __init__(self, data=b""):
|
2019-03-26 23:28:13 +03:00
|
|
|
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)
|
|
|
|
|
2016-11-04 03:31:14 +03:00
|
|
|
def __nonzero__(self):
|
|
|
|
# nonzero is covered by the __len__ function, but implementing it here
|
|
|
|
# makes it easier for extensions to override.
|
|
|
|
return len(self._lm) != 0
|
|
|
|
|
2017-03-13 22:40:14 +03:00
|
|
|
__bool__ = __nonzero__
|
|
|
|
|
2015-03-07 20:04:39 +03:00
|
|
|
def __setitem__(self, key, node):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self._lm[key] = node, self.flags(key, "")
|
2015-03-07 20:04:39 +03:00
|
|
|
|
|
|
|
def __contains__(self, key):
|
2017-09-30 02:52:22 +03:00
|
|
|
if key is None:
|
|
|
|
return False
|
2015-03-07 20:04:39 +03:00
|
|
|
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):
|
2020-01-29 03:25:29 +03:00
|
|
|
return pycompat.iterkeys(self._lm)
|
2015-03-11 23:46:15 +03:00
|
|
|
|
|
|
|
def keys(self):
|
2020-01-29 03:25:29 +03:00
|
|
|
return list(self._lm.keys())
|
2015-03-07 20:04:39 +03:00
|
|
|
|
2019-08-01 20:30:45 +03:00
|
|
|
def filesnotin(self, m2, matcher=None):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Set of files in this manifest that are not in the other"""
|
2019-08-01 20:30:45 +03:00
|
|
|
if matcher:
|
|
|
|
m1 = self.matches(matcher)
|
|
|
|
m2 = m2.matches(matcher)
|
2017-03-07 20:56:11 +03:00
|
|
|
return m1.filesnotin(m2)
|
2016-05-03 01:22:16 +03:00
|
|
|
diff = self.diff(m2)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
files = set(
|
|
|
|
filepath
|
2020-01-29 03:25:29 +03:00
|
|
|
for filepath, hashflags in pycompat.iteritems(diff)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if hashflags[1][0] is None
|
|
|
|
)
|
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):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Checks whether we can correctly and quickly iterate over matcher
|
|
|
|
files instead of over manifest files."""
|
2015-04-08 19:38:09 +03:00
|
|
|
files = match.files()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return len(files) < 100 and (
|
|
|
|
match.isexact() or (match.prefix() and all(fn in self for fn in files))
|
|
|
|
)
|
2015-04-08 19:38:09 +03:00
|
|
|
|
2015-04-08 01:18:52 +03:00
|
|
|
def walk(self, match):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Generates matching file names.
|
2015-04-08 01:18:52 +03:00
|
|
|
|
|
|
|
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().
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
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
|
|
|
|
|
2019-08-13 00:29:03 +03:00
|
|
|
# for dirstate.walk, files=[''] means "walk the whole tree".
|
2015-04-08 01:18:52 +03:00
|
|
|
# follow that here, too
|
2019-08-13 00:29:03 +03:00
|
|
|
fset.discard("")
|
2015-04-08 01:18:52 +03:00
|
|
|
|
|
|
|
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):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""generate a new manifest filtered by the match argument"""
|
2014-10-23 08:38:30 +04:00
|
|
|
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
|
|
|
|
2019-07-31 20:01:29 +03:00
|
|
|
def diff(self, m2, matcher=None):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""Finds changes between the current manifest and m2.
|
2014-12-16 00:04:28 +03:00
|
|
|
|
|
|
|
Args:
|
|
|
|
m2: the manifest to which this manifest should be compared.
|
|
|
|
|
|
|
|
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.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
2019-07-31 20:01:29 +03:00
|
|
|
if matcher:
|
|
|
|
m1 = self.matches(matcher)
|
|
|
|
m2 = m2.matches(matcher)
|
2019-07-31 20:01:29 +03:00
|
|
|
return m1.diff(m2)
|
|
|
|
return self._lm.diff(m2._lm)
|
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
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
def flags(self, key, default=""):
|
2015-03-07 20:04:39 +03:00
|
|
|
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
|
|
|
|
|
2017-05-29 07:00:02 +03:00
|
|
|
def items(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
|
|
|
|
2017-05-29 07:00:02 +03:00
|
|
|
iteritems = items
|
|
|
|
|
2016-02-08 08:13:24 +03:00
|
|
|
def iterentries(self):
|
|
|
|
return self._lm.iterentries()
|
|
|
|
|
2019-03-26 23:28:13 +03:00
|
|
|
def text(self):
|
|
|
|
# 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):
|
2017-04-03 18:45:24 +03:00
|
|
|
"""Given a base manifest text as a bytearray and a list of changes
|
2014-10-08 23:20:14 +04:00
|
|
|
relative to that text, compute a delta that can be used by revlog.
|
|
|
|
"""
|
|
|
|
delta = []
|
|
|
|
dstart = None
|
|
|
|
dend = None
|
2020-01-29 18:38:41 +03:00
|
|
|
dline = [b""]
|
2014-10-08 23:20:14 +04:00
|
|
|
start = 0
|
|
|
|
# zero copy representation of base as a buffer
|
|
|
|
addbuf = util.buffer(base)
|
|
|
|
|
2015-11-06 05:56:40 +03:00
|
|
|
changes = list(changes)
|
|
|
|
if len(changes) < 1000:
|
|
|
|
# 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:
|
|
|
|
h, fl = self._lm[f]
|
2020-01-29 18:38:41 +03:00
|
|
|
l = encodeutf8("%s\0%s%s\n" % (f, revlog.hex(h), fl))
|
2015-11-06 05:56:40 +03:00
|
|
|
else:
|
|
|
|
if start == end:
|
|
|
|
# item we want to delete was not found, error out
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise AssertionError(_("failed to remove %s from manifest") % f)
|
2020-01-29 18:38:41 +03:00
|
|
|
l = b""
|
2015-11-06 05:56:40 +03:00
|
|
|
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:
|
2020-01-29 18:38:41 +03:00
|
|
|
delta.append([dstart, dend, b"".join(dline)])
|
2015-11-06 05:56:40 +03:00
|
|
|
dstart = start
|
2014-10-08 23:20:14 +04:00
|
|
|
dend = end
|
2015-11-06 05:56:40 +03:00
|
|
|
dline = [l]
|
|
|
|
|
|
|
|
if dstart is not None:
|
2020-01-29 18:38:41 +03:00
|
|
|
delta.append([dstart, dend, b"".join(dline)])
|
2015-11-06 05:56:40 +03:00
|
|
|
# apply the delta to the base, and get a delta for addrevision
|
|
|
|
deltatext, arraytext = _addlistdelta(base, delta)
|
|
|
|
else:
|
|
|
|
# For large changes, it's much cheaper to just build the text and
|
|
|
|
# diff it.
|
2017-03-12 10:32:21 +03:00
|
|
|
arraytext = bytearray(self.text())
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
deltatext = mdiff.textdiff(util.buffer(base), util.buffer(arraytext))
|
2015-11-06 05:56:40 +03:00
|
|
|
|
2014-10-08 23:20:14 +04:00
|
|
|
return arraytext, deltatext
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-10-08 23:21:59 +04:00
|
|
|
def _msearch(m, s, lo=0, hi=None):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""return a tuple (start, end) that says where to find s within m.
|
2014-10-08 23:21:59 +04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
2017-03-26 13:06:48 +03:00
|
|
|
m should be a buffer, a memoryview or a byte string.
|
2020-01-29 18:38:41 +03:00
|
|
|
s is str"""
|
|
|
|
assert not isinstance(m, unicode)
|
|
|
|
assert isinstance(s, str)
|
|
|
|
s = encodeutf8(s)
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-10-08 23:21:59 +04:00
|
|
|
def advance(i, c):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
while i < lenm and m[i : i + 1] != c:
|
2014-10-08 23:21:59 +04:00
|
|
|
i += 1
|
|
|
|
return i
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2014-10-08 23:21:59 +04:00
|
|
|
if not s:
|
|
|
|
return (lo, lo)
|
|
|
|
lenm = len(m)
|
|
|
|
if not hi:
|
|
|
|
hi = lenm
|
|
|
|
while lo < hi:
|
|
|
|
mid = (lo + hi) // 2
|
|
|
|
start = mid
|
2020-01-29 18:38:41 +03:00
|
|
|
while start > 0 and m[start - 1 : start] != b"\n":
|
2014-10-08 23:21:59 +04:00
|
|
|
start -= 1
|
2020-01-29 18:38:41 +03:00
|
|
|
end = advance(start, b"\0")
|
2017-03-26 13:06:48 +03:00
|
|
|
if bytes(m[start:end]) < s:
|
2014-10-08 23:21:59 +04:00
|
|
|
# we know that after the null there are 40 bytes of sha1
|
|
|
|
# this translates to the bisect lo = mid + 1
|
2020-01-29 18:38:41 +03:00
|
|
|
lo = advance(end + 40, b"\n") + 1
|
2014-10-08 23:21:59 +04:00
|
|
|
else:
|
|
|
|
# this translates to the bisect hi = mid
|
|
|
|
hi = start
|
2020-01-29 18:38:41 +03:00
|
|
|
end = advance(lo, b"\0")
|
2014-10-08 23:21:59 +04:00
|
|
|
found = m[lo:end]
|
|
|
|
if s == found:
|
|
|
|
# we know that after the null there are 40 bytes of sha1
|
2020-01-29 18:38:41 +03:00
|
|
|
end = advance(end + 40, b"\n")
|
2014-10-08 23:21:59 +04:00
|
|
|
return (lo, end + 1)
|
|
|
|
else:
|
|
|
|
return (lo, lo)
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
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:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if "\n" in f or "\r" in f:
|
2014-08-07 17:46:05 +04:00
|
|
|
raise error.RevlogError(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
_("'\\n' and '\\r' disallowed in filenames: %r") % f
|
|
|
|
)
|
|
|
|
|
2014-08-07 17:46:05 +04:00
|
|
|
|
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
|
2017-03-12 10:32:21 +03:00
|
|
|
newaddlist = bytearray()
|
2014-08-07 20:47:20 +04:00
|
|
|
|
|
|
|
for start, end, content in x:
|
|
|
|
newaddlist += addlist[currentposition:start]
|
|
|
|
if content:
|
2017-03-12 10:32:21 +03:00
|
|
|
newaddlist += bytearray(content)
|
2014-08-07 20:47:20 +04:00
|
|
|
|
|
|
|
currentposition = end
|
|
|
|
|
|
|
|
newaddlist += addlist[currentposition:]
|
|
|
|
|
2020-01-29 18:38:41 +03:00
|
|
|
deltatext = b"".join(
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
struct.pack(">lll", start, end, len(content)) + content
|
|
|
|
for start, end, content in x
|
|
|
|
)
|
2014-08-07 20:47:20 +04:00
|
|
|
return deltatext, newaddlist
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
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):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if "/" in f:
|
|
|
|
dir, subpath = f.split("/", 1)
|
|
|
|
return dir + "/", subpath
|
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:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return "", 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
|
|
|
|
2015-09-26 05:54:46 +03:00
|
|
|
_noop = lambda s: None
|
2015-04-10 03:14:35 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
class manifestrevlog(revlog.revlog):
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""A revlog that stores manifest texts. This is responsible for caching the
|
2016-08-17 23:25:13 +03:00
|
|
|
full-text manifest contents.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(
|
|
|
|
self, opener, dir="", dirlogcache=None, indexfile=None, treemanifest=False
|
|
|
|
):
|
2017-03-02 03:35:57 +03:00
|
|
|
"""Constructs a new manifest revlog
|
|
|
|
|
|
|
|
`indexfile` - used by extensions to have two manifests at once, like
|
|
|
|
when transitioning between flatmanifeset and treemanifests.
|
2017-05-09 23:56:46 +03:00
|
|
|
|
|
|
|
`treemanifest` - used to indicate this is a tree manifest revlog. Opener
|
|
|
|
options can also be used to make this a tree manifest revlog. The opener
|
|
|
|
option takes precedence, so if it is set to True, we ignore whatever
|
|
|
|
value is passed in to the constructor.
|
2017-03-02 03:35:57 +03:00
|
|
|
"""
|
2016-08-17 23:25:13 +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
|
2017-05-09 23:56:46 +03:00
|
|
|
optiontreemanifest = False
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
opts = getattr(opener, "options", None)
|
2016-08-17 23:25:13 +03:00
|
|
|
if opts is not None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
cachesize = opts.get("manifestcachesize", cachesize)
|
|
|
|
optiontreemanifest = opts.get("treemanifest", False)
|
2016-09-14 02:00:41 +03:00
|
|
|
|
2017-05-09 23:56:46 +03:00
|
|
|
self._treeondisk = optiontreemanifest or treemanifest
|
2016-09-14 02:00:41 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
self._fulltextcache = util.lrucachedict(cachesize)
|
|
|
|
|
2016-09-14 02:00:41 +03:00
|
|
|
if dir:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
assert self._treeondisk, "opts is %r" % opts
|
|
|
|
if not dir.endswith("/"):
|
|
|
|
dir = dir + "/"
|
2017-03-02 03:35:57 +03:00
|
|
|
|
|
|
|
if indexfile is None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
indexfile = "00manifest.i"
|
2017-03-02 03:35:57 +03:00
|
|
|
if dir:
|
|
|
|
indexfile = "meta/" + dir + indexfile
|
|
|
|
|
2016-09-14 02:00:41 +03:00
|
|
|
self._dir = dir
|
2016-09-14 02:00:41 +03:00
|
|
|
# The dirlogcache is kept on the root manifest log
|
|
|
|
if dir:
|
|
|
|
self._dirlogcache = dirlogcache
|
|
|
|
else:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self._dirlogcache = {"": self}
|
2016-09-14 02:00:41 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
super(manifestrevlog, self).__init__(
|
|
|
|
opener,
|
|
|
|
indexfile,
|
|
|
|
# only root indexfile is cached
|
|
|
|
checkambig=not bool(dir),
|
|
|
|
mmaplargeindex=True,
|
|
|
|
)
|
2016-09-14 02:00:41 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
@property
|
|
|
|
def fulltextcache(self):
|
|
|
|
return self._fulltextcache
|
|
|
|
|
|
|
|
def clearcaches(self):
|
|
|
|
super(manifestrevlog, self).clearcaches()
|
|
|
|
self._fulltextcache.clear()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self._dirlogcache = {"": self}
|
2016-09-14 02:00:41 +03:00
|
|
|
|
|
|
|
def dirlog(self, dir):
|
|
|
|
if dir:
|
|
|
|
assert self._treeondisk
|
|
|
|
if dir not in self._dirlogcache:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
mfrevlog = manifestrevlog(
|
|
|
|
self.opener, dir, self._dirlogcache, treemanifest=self._treeondisk
|
|
|
|
)
|
2017-05-09 23:56:46 +03:00
|
|
|
self._dirlogcache[dir] = mfrevlog
|
2016-09-14 02:00:41 +03:00
|
|
|
return self._dirlogcache[dir]
|
2016-08-17 23:25:13 +03:00
|
|
|
|
2016-11-10 13:13:19 +03:00
|
|
|
def add(self, m, transaction, link, p1, p2, added, removed, readtree=None):
|
2019-03-26 23:28:13 +03:00
|
|
|
if p1 in self.fulltextcache and util.safehasattr(m, "fastdelta"):
|
2016-09-20 22:24:01 +03: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.
|
|
|
|
|
|
|
|
_checkforbidden(added)
|
|
|
|
# combine the changed lists into one sorted iterator
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
work = heapq.merge(
|
|
|
|
[(x, False) for x in added], [(x, True) for x in removed]
|
|
|
|
)
|
2016-09-20 22:24:01 +03:00
|
|
|
|
|
|
|
arraytext, deltatext = m.fastdelta(self.fulltextcache[p1], work)
|
|
|
|
cachedelta = self.rev(p1), deltatext
|
|
|
|
text = util.buffer(arraytext)
|
|
|
|
n = self.addrevision(text, transaction, link, p1, p2, cachedelta)
|
|
|
|
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.
|
|
|
|
if self._treeondisk:
|
2016-11-10 13:13:19 +03:00
|
|
|
assert readtree, "readtree must be set for treemanifest writes"
|
|
|
|
m1 = readtree(self._dir, p1)
|
|
|
|
m2 = readtree(self._dir, p2)
|
|
|
|
n = self._addtree(m, transaction, link, m1, m2, readtree)
|
2016-09-20 22:24:01 +03:00
|
|
|
arraytext = None
|
|
|
|
else:
|
2019-03-26 23:28:13 +03:00
|
|
|
text = m.text()
|
2016-09-20 22:24:01 +03:00
|
|
|
n = self.addrevision(text, transaction, link, p1, p2)
|
2017-03-12 10:32:21 +03:00
|
|
|
arraytext = bytearray(text)
|
2016-09-20 22:24:01 +03:00
|
|
|
|
2016-10-18 08:51:22 +03:00
|
|
|
if arraytext is not None:
|
|
|
|
self.fulltextcache[n] = arraytext
|
2016-09-20 22:24:01 +03:00
|
|
|
|
|
|
|
return n
|
|
|
|
|
2016-11-10 13:13:19 +03:00
|
|
|
def _addtree(self, m, transaction, link, m1, m2, readtree):
|
2016-09-20 22:24:01 +03:00
|
|
|
# If the manifest is unchanged compared to one parent,
|
|
|
|
# don't write a new revision
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if self._dir != "" and (m.unmodifiedsince(m1) or m.unmodifiedsince(m2)):
|
2016-09-20 22:24:01 +03:00
|
|
|
return m.node()
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-09-20 22:24:01 +03:00
|
|
|
def writesubtree(subm, subp1, subp2):
|
|
|
|
sublog = self.dirlog(subm.dir())
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
sublog.add(
|
|
|
|
subm, transaction, link, subp1, subp2, None, None, readtree=readtree
|
|
|
|
)
|
|
|
|
|
2016-09-20 22:24:01 +03:00
|
|
|
m.writesubtrees(m1, m2, writesubtree)
|
2019-03-26 23:28:13 +03:00
|
|
|
text = m.dirtext()
|
treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.
In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.
While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-02 03:19:41 +03:00
|
|
|
n = None
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
if self._dir != "":
|
treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.
In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.
While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-02 03:19:41 +03:00
|
|
|
# Double-check whether contents are unchanged to one parent
|
2019-03-26 23:28:13 +03:00
|
|
|
if text == m1.dirtext():
|
treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.
In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.
While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-02 03:19:41 +03:00
|
|
|
n = m1.node()
|
2019-03-26 23:28:13 +03:00
|
|
|
elif text == m2.dirtext():
|
treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.
In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.
While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-02 03:19:41 +03:00
|
|
|
n = m2.node()
|
|
|
|
|
|
|
|
if not n:
|
2016-09-20 22:24:01 +03:00
|
|
|
n = self.addrevision(text, transaction, link, m1.node(), m2.node())
|
treemanifest: make node reuse match flat manifest behavior
In a flat manifest, a node with the same content but different parents is still
considered a new node. In the current tree manifests however, if the content is
the same, we ignore the parents entirely and just reuse the existing node.
In our external treemanifest extension, we want to allow having one treemanifest
for every flat manifests, as a way of easeing the migration to treemanifests. To
make this possible, let's change the root node treemanifest behavior to match
the behavior for flat manifests, so we can have a 1:1 relationship.
While this sounds like a BC breakage, it's not actually a state users can
normally get in because: A) you can't make empty commits, and B) even if you try
to make an empty commit (by making a commit then amending it's changes away),
the higher level commit logic in localrepo.commitctx() forces the commit to use
the original p1 manifest node if no files were changed. So this would only
affect extensions and automation that reached passed the normal
localrepo.commit() logic straight into the manifest logic.
2017-03-02 03:19:41 +03:00
|
|
|
|
2016-09-20 22:24:01 +03:00
|
|
|
# Save nodeid so parent manifest can calculate its nodeid
|
|
|
|
m.setnode(n)
|
|
|
|
return n
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
class manifestlog(object):
|
|
|
|
"""A collection class representing the collection of manifest snapshots
|
|
|
|
referenced by commits in the repository.
|
|
|
|
|
|
|
|
In this situation, 'manifest' refers to the abstract concept of a snapshot
|
|
|
|
of the list of files in the given commit. Consumers of the output of this
|
|
|
|
class do not care about the implementation details of the actual manifests
|
|
|
|
they receive (i.e. tree or flat or lazily loaded, etc)."""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
def __init__(self, opener, repo):
|
2016-09-20 22:24:01 +03:00
|
|
|
usetreemanifest = False
|
2016-11-10 13:13:19 +03:00
|
|
|
cachesize = 4
|
2016-09-20 22:24:01 +03:00
|
|
|
|
2018-02-27 22:10:35 +03:00
|
|
|
self.ui = repo.ui
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
opts = getattr(opener, "options", None)
|
2016-09-20 22:24:01 +03:00
|
|
|
if opts is not None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
usetreemanifest = opts.get("treemanifest", usetreemanifest)
|
|
|
|
cachesize = opts.get("manifestcachesize", cachesize)
|
2016-09-20 22:24:01 +03:00
|
|
|
self._treeinmem = usetreemanifest
|
|
|
|
|
2018-03-12 21:10:15 +03:00
|
|
|
self._opener = opener
|
2017-05-08 19:39:21 +03:00
|
|
|
self._revlog = repo._constructmanifest()
|
2020-07-07 00:00:16 +03:00
|
|
|
self._repo = repo
|
2016-10-19 03:33:39 +03:00
|
|
|
|
2016-11-03 03:10:47 +03:00
|
|
|
# A cache of the manifestctx or treemanifestctx for each directory
|
|
|
|
self._dirmancache = {}
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
self._dirmancache[""] = util.lrucachedict(cachesize)
|
2016-11-03 03:10:47 +03:00
|
|
|
|
2016-11-10 13:13:19 +03:00
|
|
|
self.cachesize = cachesize
|
2018-06-13 21:42:16 +03:00
|
|
|
self.recentlinknode = None
|
2016-08-17 23:25:13 +03:00
|
|
|
|
2018-03-06 21:40:35 +03:00
|
|
|
def __nonzero__(self):
|
|
|
|
return bool(self._revlog)
|
|
|
|
|
2020-01-28 21:29:59 +03:00
|
|
|
__bool__ = __nonzero__
|
|
|
|
|
2018-02-27 22:09:48 +03:00
|
|
|
def _maplinknode(self, linknode):
|
|
|
|
"""Turns a linknode into a linkrev. Only needed for revlog backed
|
|
|
|
manifestlogs."""
|
2018-03-22 08:33:29 +03:00
|
|
|
linkrev = self._repo.changelog.rev(linknode)
|
2018-02-27 22:09:48 +03:00
|
|
|
return linkrev
|
|
|
|
|
|
|
|
def _maplinkrev(self, linkrev):
|
|
|
|
"""Turns a linkrev into a linknode. Only needed for revlog backed
|
|
|
|
manifestlogs."""
|
2018-03-22 08:33:29 +03:00
|
|
|
if linkrev >= len(self._repo.changelog):
|
2018-03-15 23:40:17 +03:00
|
|
|
raise LookupError(_("linkrev %s not in changelog") % linkrev)
|
2018-03-22 08:33:29 +03:00
|
|
|
return self._repo.changelog.node(linkrev)
|
2018-02-27 22:09:48 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
def __getitem__(self, node):
|
2016-11-03 03:33:31 +03:00
|
|
|
"""Retrieves the manifest instance for the given node. Throws a
|
|
|
|
LookupError if not found.
|
2016-08-17 23:25:13 +03:00
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
return self.get("", node)
|
2016-11-03 03:24:06 +03:00
|
|
|
|
2016-11-15 02:17:27 +03:00
|
|
|
def get(self, dir, node, verify=True):
|
2016-11-03 03:24:06 +03:00
|
|
|
"""Retrieves the manifest instance for the given node. Throws a
|
|
|
|
LookupError if not found.
|
2016-11-15 02:17:27 +03:00
|
|
|
|
|
|
|
`verify` - if True an exception will be thrown if the node is not in
|
|
|
|
the revlog
|
2016-11-03 03:24:06 +03:00
|
|
|
"""
|
2016-11-03 03:10:47 +03:00
|
|
|
if node in self._dirmancache.get(dir, ()):
|
2017-05-06 00:10:58 +03:00
|
|
|
return self._dirmancache[dir][node]
|
2016-11-03 03:10:47 +03:00
|
|
|
|
2016-11-03 03:24:06 +03:00
|
|
|
if dir:
|
2020-04-10 20:56:22 +03:00
|
|
|
raise error.Abort(
|
2020-05-07 19:05:16 +03:00
|
|
|
_("cannot ask for manifest directory '%s' in a flat manifest") % dir
|
2020-04-10 20:56:22 +03:00
|
|
|
)
|
2016-08-31 23:29:49 +03:00
|
|
|
else:
|
2016-11-15 02:17:27 +03:00
|
|
|
if verify:
|
|
|
|
if node not in self._revlog.nodemap:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise LookupError(node, self._revlog.indexfile, _("no node"))
|
2016-11-03 03:24:06 +03:00
|
|
|
if self._treeinmem:
|
2020-04-10 20:56:22 +03:00
|
|
|
raise error.Abort("legacy upstream treemanifest no longer supported")
|
2016-11-03 03:24:06 +03:00
|
|
|
else:
|
2017-03-02 03:39:48 +03:00
|
|
|
m = manifestctx(self, node)
|
2016-11-03 03:10:47 +03:00
|
|
|
|
|
|
|
if node != revlog.nullid:
|
|
|
|
mancache = self._dirmancache.get(dir)
|
|
|
|
if not mancache:
|
|
|
|
mancache = util.lrucachedict(self.cachesize)
|
|
|
|
self._dirmancache[dir] = mancache
|
|
|
|
mancache[node] = m
|
2016-08-17 23:25:13 +03:00
|
|
|
return m
|
|
|
|
|
2016-11-10 13:13:19 +03:00
|
|
|
def clearcaches(self):
|
|
|
|
self._dirmancache.clear()
|
|
|
|
self._revlog.clearcaches()
|
|
|
|
|
2018-02-27 22:10:22 +03:00
|
|
|
def commitpending(self):
|
|
|
|
"""Used in alternative manifestlog implementations to flush additions to
|
|
|
|
disk."""
|
|
|
|
|
|
|
|
def abortpending(self):
|
|
|
|
"""Used in alternative manifestlog implementations to throw out pending
|
|
|
|
additions."""
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
class memmanifestctx(object):
|
2017-03-02 03:39:48 +03:00
|
|
|
def __init__(self, manifestlog):
|
|
|
|
self._manifestlog = manifestlog
|
2016-11-08 19:03:43 +03:00
|
|
|
self._manifestdict = manifestdict()
|
2018-02-27 22:10:03 +03:00
|
|
|
self._node = None
|
|
|
|
self._parents = None
|
2018-02-27 22:09:48 +03:00
|
|
|
self._linkrev = None
|
2016-11-08 19:03:43 +03:00
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def _revlog(self):
|
2017-03-02 03:39:48 +03:00
|
|
|
return self._manifestlog._revlog
|
2016-11-08 19:03:43 +03:00
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def new(self):
|
2017-03-02 03:39:48 +03:00
|
|
|
return memmanifestctx(self._manifestlog)
|
2016-11-08 19:03:43 +03:00
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def copy(self):
|
2017-03-02 03:39:48 +03:00
|
|
|
memmf = memmanifestctx(self._manifestlog)
|
2016-11-08 19:03:43 +03:00
|
|
|
memmf._manifestdict = self.read().copy()
|
|
|
|
return memmf
|
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def read(self):
|
|
|
|
return self._manifestdict
|
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def write(self, transaction, link, p1, p2, added, removed):
|
2018-02-27 22:10:03 +03:00
|
|
|
if self._node is not None:
|
|
|
|
raise error.ProgrammingError("calling memmanifestctx.write() twice")
|
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
node = self._revlog().add(
|
|
|
|
self._manifestdict, transaction, link, p1, p2, added, removed
|
|
|
|
)
|
2018-02-27 22:10:03 +03:00
|
|
|
self._node = node
|
|
|
|
self._parents = (p1, p2)
|
2018-02-27 22:09:48 +03:00
|
|
|
self._linkrev = link
|
|
|
|
return node
|
|
|
|
|
2018-02-27 22:10:03 +03:00
|
|
|
@property
|
|
|
|
def parents(self):
|
|
|
|
if self._parents is None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.ProgrammingError(
|
|
|
|
"accessing memmanifestctx.parents " "before write()"
|
|
|
|
)
|
2018-02-27 22:10:03 +03:00
|
|
|
return self._parents
|
|
|
|
|
|
|
|
def node(self):
|
|
|
|
if self._node is None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.ProgrammingError(
|
|
|
|
"accessing memmanifestctx.node() " "before write()"
|
|
|
|
)
|
2018-02-27 22:10:03 +03:00
|
|
|
return self._node
|
|
|
|
|
2018-02-27 22:09:48 +03:00
|
|
|
@property
|
|
|
|
def linknode(self):
|
|
|
|
if self._linkrev is None:
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
raise error.ProgrammingError(
|
|
|
|
_("accessing memmanifestctx.linknode " "before write()")
|
|
|
|
)
|
2018-02-27 22:09:48 +03:00
|
|
|
return self._manifestlog._maplinkrev(self._linkrev)
|
2016-11-08 19:03:43 +03:00
|
|
|
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2016-09-12 20:55:43 +03:00
|
|
|
class manifestctx(object):
|
2016-08-17 23:25:13 +03:00
|
|
|
"""A class representing a single revision of a manifest, including its
|
|
|
|
contents, its parent revs, and its linkrev.
|
|
|
|
"""
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
|
2017-03-02 03:39:48 +03:00
|
|
|
def __init__(self, manifestlog, node):
|
|
|
|
self._manifestlog = manifestlog
|
2016-09-12 20:55:43 +03:00
|
|
|
self._data = None
|
2016-08-17 23:25:13 +03:00
|
|
|
|
|
|
|
self._node = node
|
2016-08-31 23:29:49 +03:00
|
|
|
|
|
|
|
# TODO: We eventually want p1, p2, and linkrev exposed on this class,
|
|
|
|
# but let's add it later when something needs it and we can load it
|
|
|
|
# lazily.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
# self.p1, self.p2 = revlog.parents(node)
|
|
|
|
# rev = revlog.rev(node)
|
|
|
|
# self.linkrev = revlog.linkrev(rev)
|
2016-08-17 23:25:13 +03:00
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def _revlog(self):
|
2017-03-02 03:39:48 +03:00
|
|
|
return self._manifestlog._revlog
|
2016-11-08 19:03:43 +03:00
|
|
|
|
2016-08-17 23:25:13 +03:00
|
|
|
def node(self):
|
|
|
|
return self._node
|
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def new(self):
|
2017-03-02 03:39:48 +03:00
|
|
|
return memmanifestctx(self._manifestlog)
|
2016-11-08 19:03:43 +03:00
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def copy(self):
|
2017-03-02 03:39:48 +03:00
|
|
|
memmf = memmanifestctx(self._manifestlog)
|
2016-11-08 19:03:43 +03:00
|
|
|
memmf._manifestdict = self.read().copy()
|
|
|
|
return memmf
|
|
|
|
|
2016-11-17 21:59:15 +03:00
|
|
|
@propertycache
|
|
|
|
def parents(self):
|
|
|
|
return self._revlog().parents(self._node)
|
|
|
|
|
2018-02-27 22:09:48 +03:00
|
|
|
@propertycache
|
|
|
|
def linknode(self):
|
|
|
|
revlog = self._revlog()
|
|
|
|
linkrev = revlog.linkrev(revlog.rev(self._node))
|
|
|
|
return self._manifestlog._maplinkrev(linkrev)
|
|
|
|
|
2016-09-12 20:55:43 +03:00
|
|
|
def read(self):
|
2017-02-26 21:16:47 +03:00
|
|
|
if self._data is None:
|
2016-09-12 20:55:43 +03:00
|
|
|
if self._node == revlog.nullid:
|
|
|
|
self._data = manifestdict()
|
|
|
|
else:
|
2016-11-08 19:03:43 +03:00
|
|
|
rl = self._revlog()
|
2016-10-19 03:44:26 +03:00
|
|
|
text = rl.revision(self._node)
|
2017-03-12 10:32:21 +03:00
|
|
|
arraytext = bytearray(text)
|
2016-10-19 03:44:26 +03:00
|
|
|
rl._fulltextcache[self._node] = arraytext
|
2016-09-12 20:55:43 +03:00
|
|
|
self._data = manifestdict(text)
|
|
|
|
return self._data
|
|
|
|
|
2019-05-24 19:57:15 +03:00
|
|
|
def readnew(self, shallow=False):
|
|
|
|
"""Returns the entries that were introduced by this manifest revision.
|
2016-11-03 03:10:47 +03:00
|
|
|
|
2019-05-24 19:57:15 +03:00
|
|
|
If `shallow` is True, it returns only the immediate children in a tree.
|
codemod: join the auto-formatter party
Summary:
Turned on the auto formatter. Ran `arc lint --apply-patches --take BLACK **/*.py`.
Then run `arc lint` again so some other autofixers like spellchecker etc. looked
at the code base. Manually accept the changes whenever they make sense, or use
a workaround (ex. changing "dict()" to "dict constructor") where autofix is false
positive. Disabled linters on files that are hard (i18n/polib.py) to fix, or less
interesting to fix (hgsubversion tests), or cannot be fixed without breaking
OSS build (FBPYTHON4).
Conflicted linters (test-check-module-imports.t, part of test-check-code.t,
test-check-pyflakes.t) are removed or disabled.
Duplicated linters (test-check-pyflakes.t, test-check-pylint.t) are removed.
An issue of the auto-formatter is lines are no longer guarnateed to be <= 80
chars. But that seems less important comparing with the benefit auto-formatter
provides.
As we're here, also remove test-check-py3-compat.t, as it is currently broken
if `PYTHON3=/bin/python3` is set.
Reviewed By: wez, phillco, simpkins, pkaush, singhsrb
Differential Revision: D8173629
fbshipit-source-id: 90e248ae0c5e6eaadbe25520a6ee42d32005621b
2018-05-26 07:34:37 +03:00
|
|
|
"""
|
2016-11-08 19:03:43 +03:00
|
|
|
revlog = self._revlog()
|
2016-09-14 02:25:21 +03:00
|
|
|
r = revlog.rev(self._node)
|
2019-05-24 19:57:15 +03:00
|
|
|
d = mdiff.patchtext(revlog.revdiff(revlog.parentrevs(r)[0], r))
|
2016-09-14 02:25:21 +03:00
|
|
|
return manifestdict(d)
|
|
|
|
|
2016-11-08 19:03:43 +03:00
|
|
|
def find(self, key):
|
|
|
|
return self.read().find(key)
|