...
 
Commits (41)
......@@ -2,7 +2,7 @@
clang-format:command = clang-format --style file
clang-format:pattern = set:(**.c or **.cc or **.h) and not "include:contrib/clang-format-ignorelist"
rustfmt:command = rustfmt
rustfmt:command = $(rustup which --toolchain nightly rustfmt)
rustfmt:pattern = set:**.rs
black:command = black --config=black.toml -
......
......@@ -9,7 +9,6 @@ from __future__ import absolute_import
import collections
import contextlib
import hashlib
import os
from mercurial.i18n import _
......@@ -28,7 +27,10 @@ from mercurial import (
scmutil,
util,
)
from mercurial.utils import stringutil
from mercurial.utils import (
hashutil,
stringutil,
)
from . import (
error as faerror,
......@@ -148,7 +150,7 @@ def hashdiffopts(diffopts):
diffoptstr = stringutil.pprint(
sorted((k, getattr(diffopts, k)) for k in mdiff.diffopts.defaults)
)
return node.hex(hashlib.sha1(diffoptstr).digest())[:6]
return node.hex(hashutil.sha1(diffoptstr).digest())[:6]
_defaultdiffopthash = hashdiffopts(mdiff.defaultopts)
......
......@@ -108,7 +108,6 @@ created.
from __future__ import absolute_import
import codecs
import hashlib
import os
import stat
import sys
......@@ -132,7 +131,10 @@ from mercurial import (
util,
)
from mercurial import match as matchmod
from mercurial.utils import stringutil
from mercurial.utils import (
hashutil,
stringutil,
)
from . import (
pywatchman,
......@@ -235,7 +237,7 @@ def _hashignore(ignore):
copy.
"""
sha1 = hashlib.sha1()
sha1 = hashutil.sha1()
sha1.update(pycompat.byterepr(ignore))
return pycompat.sysbytes(sha1.hexdigest())
......
......@@ -105,11 +105,11 @@ class client(object):
)
return self._watchmanclient.query(*watchmanargs)
except pywatchman.CommandError as ex:
if b'unable to resolve root' in ex.msg:
if 'unable to resolve root' in ex.msg:
raise WatchmanNoRoot(
self._root, stringutil.forcebytestr(ex.msg)
)
raise Unavailable(ex.msg)
raise Unavailable(stringutil.forcebytestr(ex.msg))
except pywatchman.WatchmanError as ex:
raise Unavailable(stringutil.forcebytestr(ex))
......
......@@ -6,7 +6,6 @@
from __future__ import absolute_import
import abc
import hashlib
import os
import subprocess
import tempfile
......@@ -16,7 +15,10 @@ from mercurial import (
node,
pycompat,
)
from mercurial.utils import procutil
from mercurial.utils import (
hashutil,
procutil,
)
NamedTemporaryFile = tempfile.NamedTemporaryFile
......@@ -87,7 +89,7 @@ class filebundlestore(object):
return os.path.join(self._dirpath(filename), filename)
def write(self, data):
filename = node.hex(hashlib.sha1(data).digest())
filename = node.hex(hashutil.sha1(data).digest())
dirpath = self._dirpath(filename)
if not os.path.exists(dirpath):
......
......@@ -10,7 +10,6 @@
from __future__ import absolute_import
import errno
import hashlib
import os
import shutil
......@@ -29,6 +28,7 @@ from mercurial import (
scmutil,
util,
)
from mercurial.utils import hashutil
from ..convert import (
convcmd,
......@@ -273,7 +273,7 @@ def _lfconvert_addchangeset(
)
# largefile was modified, update standins
m = hashlib.sha1(b'')
m = hashutil.sha1(b'')
m.update(ctx[f].data())
hash = node.hex(m.digest())
if f not in lfiletohash or lfiletohash[f] != hash:
......
......@@ -11,7 +11,6 @@ from __future__ import absolute_import
import contextlib
import copy
import hashlib
import os
import stat
......@@ -32,6 +31,7 @@ from mercurial import (
util,
vfs as vfsmod,
)
from mercurial.utils import hashutil
shortname = b'.hglf'
shortnameslash = shortname + b'/'
......@@ -432,7 +432,7 @@ def writestandin(repo, standin, hash, executable):
def copyandhash(instream, outfile):
'''Read bytes from instream (iterable) and write them to outfile,
computing the SHA-1 hash of the data along the way. Return the hash.'''
hasher = hashlib.sha1(b'')
hasher = hashutil.sha1(b'')
for data in instream:
hasher.update(data)
outfile.write(data)
......@@ -472,7 +472,7 @@ def urljoin(first, second, *arg):
def hexsha1(fileobj):
"""hexsha1 returns the hex-encoded sha1 sum of the data in the file-like
object data"""
h = hashlib.sha1()
h = hashutil.sha1()
for chunk in util.filechunkiter(fileobj):
h.update(chunk)
return hex(h.digest())
......
......@@ -402,3 +402,25 @@ def debuglfsupload(ui, repo, **opts):
revs = opts.get('rev', [])
pointers = wrapper.extractpointers(repo, scmutil.revrange(repo, revs))
wrapper.uploadblobs(repo, pointers)
@eh.wrapcommand(
b'verify',
opts=[(b'', b'no-lfs', None, _(b'skip missing lfs blob content'))],
)
def verify(orig, ui, repo, **opts):
skipflags = repo.ui.configint(b'verify', b'skipflags')
no_lfs = opts.pop('no_lfs')
if skipflags:
# --lfs overrides the config bit, if set.
if no_lfs is False:
skipflags &= ~repository.REVISION_FLAG_EXTSTORED
else:
skipflags = 0
if no_lfs is True:
skipflags |= repository.REVISION_FLAG_EXTSTORED
with ui.configoverride({(b'verify', b'skipflags'): skipflags}):
return orig(ui, repo, **opts)
......@@ -588,7 +588,9 @@ class _gitlfsremote(object):
else:
oids = transfer(sorted(objects, key=lambda o: o.get(b'oid')))
with self.ui.makeprogress(topic, total=total) as progress:
with self.ui.makeprogress(
topic, unit=_(b"bytes"), total=total
) as progress:
progress.update(0)
processed = 0
blobs = 0
......
......@@ -225,6 +225,25 @@ def filelogsize(orig, self, rev):
return orig(self, rev)
@eh.wrapfunction(revlog, b'_verify_revision')
def _verify_revision(orig, rl, skipflags, state, node):
if _islfs(rl, node=node):
rawtext = rl.rawdata(node)
metadata = pointer.deserialize(rawtext)
# Don't skip blobs that are stored locally, as local verification is
# relatively cheap and there's no other way to verify the raw data in
# the revlog.
if rl.opener.lfslocalblobstore.has(metadata.oid()):
skipflags &= ~revlog.REVIDX_EXTSTORED
elif skipflags & revlog.REVIDX_EXTSTORED:
# The wrapped method will set `skipread`, but there's enough local
# info to check renames.
state[b'safe_renamed'].add(node)
orig(rl, skipflags, state, node)
@eh.wrapfunction(context.basefilectx, b'cmp')
def filectxcmp(orig, self, fctx):
"""returns True if text is different than fctx"""
......
......@@ -1065,6 +1065,7 @@ def phabsend(ui, repo, *revs, **opts):
opts = pycompat.byteskwargs(opts)
revs = list(revs) + opts.get(b'rev', [])
revs = scmutil.revrange(repo, revs)
revs.sort() # ascending order to preserve topological parent/child in phab
if not revs:
raise error.Abort(_(b'phabsend requires at least one changeset'))
......
......@@ -798,7 +798,7 @@ class rebaseruntime(object):
shouldupdate = repo[b'.'].rev() in updateifonnodes
# Update away from the rebase if necessary
if shouldupdate or needupdate(repo, self.state):
if shouldupdate:
mergemod.update(
repo, self.originalwd, branchmerge=False, force=True
)
......@@ -1056,10 +1056,9 @@ def rebase(ui, repo, **opts):
b'changesets'
),
)
if needupdate(repo, rbsrt.state):
# update to the current working revision
# to clear interrupted merge
hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
# update to the current working revision
# to clear interrupted merge
hg.updaterepo(repo, rbsrt.originalwd, overwrite=True)
rbsrt._finishrebase()
return 0
elif inmemory:
......@@ -1430,13 +1429,13 @@ def commitmemorynode(repo, p1, p2, wctx, editor, extra, user, date, commitmsg):
# By convention, ``extra['branch']`` (set by extrafn) clobbers
# ``branch`` (used when passing ``--keepbranches``).
branch = repo[p1].branch()
branch = None
if b'branch' in extra:
branch = extra[b'branch']
wctx.setparents(repo[p1].node(), repo[p2].node())
memctx = wctx.tomemctx(
commitmsg,
parents=(p1, p2),
date=date,
extra=extra,
user=user,
......@@ -1924,25 +1923,6 @@ def clearstatus(repo):
repo.vfs.unlinkpath(b"rebasestate", ignoremissing=True)
def needupdate(repo, state):
'''check whether we should `update --clean` away from a merge, or if
somehow the working dir got forcibly updated, e.g. by older hg'''
parents = [p.rev() for p in repo[None].parents()]
# Are we in a merge state at all?
if len(parents) < 2:
return False
# We should be standing on the first as-of-yet unrebased commit.
firstunrebased = min(
[old for old, new in pycompat.iteritems(state) if new == nullrev]
)
if firstunrebased in parents:
return True
return False
def sortsource(destmap):
"""yield source revisions in an order that we only rebase things once
......
......@@ -2,7 +2,6 @@ from __future__ import absolute_import
import collections
import errno
import hashlib
import mmap
import os
import struct
......@@ -20,6 +19,7 @@ from mercurial import (
util,
vfs as vfsmod,
)
from mercurial.utils import hashutil
from . import shallowutil
osutil = policy.importmod('osutil')
......@@ -392,7 +392,7 @@ class mutablebasepack(versionmixin):
)
self.packfp = os.fdopen(self.packfp, 'wb+')
self.idxfp = os.fdopen(self.idxfp, 'wb+')
self.sha = hashlib.sha1()
self.sha = hashutil.sha1()
self._closed = False
# The opener provides no way of doing permission fixup on files created
......
from __future__ import absolute_import
import errno
import hashlib
import os
import shutil
import stat
......@@ -15,6 +14,7 @@ from mercurial import (
pycompat,
util,
)
from mercurial.utils import hashutil
from . import (
constants,
shallowutil,
......@@ -166,7 +166,7 @@ class basestore(object):
# Start with a full manifest, since it'll cover the majority of files
for filename in self.repo[b'tip'].manifest():
sha = hashlib.sha1(filename).digest()
sha = hashutil.sha1(filename).digest()
if sha in missingfilename:
filenames[filename] = sha
missingfilename.discard(sha)
......@@ -178,7 +178,7 @@ class basestore(object):
break
files = cl.readfiles(cl.node(rev))
for filename in files:
sha = hashlib.sha1(filename).digest()
sha = hashutil.sha1(filename).digest()
if sha in missingfilename:
filenames[filename] = sha
missingfilename.discard(sha)
......
......@@ -6,7 +6,6 @@
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
import hashlib
import os
import zlib
......@@ -21,6 +20,7 @@ from mercurial import (
pycompat,
revlog,
)
from mercurial.utils import hashutil
from . import (
constants,
datapack,
......@@ -61,7 +61,7 @@ def debugremotefilelog(ui, path, **opts):
def buildtemprevlog(repo, file):
# get filename key
filekey = nodemod.hex(hashlib.sha1(file).digest())
filekey = nodemod.hex(hashutil.sha1(file).digest())
filedir = os.path.join(repo.path, b'store/data', filekey)
# sort all entries based on linkrev
......@@ -421,7 +421,7 @@ def dumpdeltachain(ui, deltachain, **opts):
% (
hashformatter(node),
hashformatter(deltabasenode),
nodemod.hex(hashlib.sha1(delta).digest()),
nodemod.hex(hashutil.sha1(delta).digest()),
len(delta),
)
)
......
......@@ -7,7 +7,6 @@
from __future__ import absolute_import
import hashlib
import io
import os
import threading
......@@ -25,7 +24,10 @@ from mercurial import (
util,
wireprotov1peer,
)
from mercurial.utils import procutil
from mercurial.utils import (
hashutil,
procutil,
)
from . import (
constants,
......@@ -45,12 +47,12 @@ _lfsmod = None
def getcachekey(reponame, file, id):
pathhash = node.hex(hashlib.sha1(file).digest())
pathhash = node.hex(hashutil.sha1(file).digest())
return os.path.join(reponame, pathhash[:2], pathhash[2:], id)
def getlocalkey(file, id):
pathhash = node.hex(hashlib.sha1(file).digest())
pathhash = node.hex(hashutil.sha1(file).digest())
return os.path.join(pathhash, id)
......
from __future__ import absolute_import
import hashlib
import struct
from mercurial.node import hex, nullid
......@@ -8,6 +7,7 @@ from mercurial import (
pycompat,
util,
)
from mercurial.utils import hashutil
from . import (
basepack,
constants,
......@@ -197,7 +197,7 @@ class historypack(basepack.basepack):
def _findsection(self, name):
params = self.params
namehash = hashlib.sha1(name).digest()
namehash = hashutil.sha1(name).digest()
fanoutkey = struct.unpack(
params.fanoutstruct, namehash[: params.fanoutprefix]
)[0]
......@@ -499,7 +499,7 @@ class mutablehistorypack(basepack.mutablebasepack):
# Record metadata for the index
self.files[filename] = (sectionstart, sectionlen)
node = hashlib.sha1(filename).digest()
node = hashutil.sha1(filename).digest()
self.entries[node] = node
def close(self, ledger=None):
......@@ -517,7 +517,7 @@ class mutablehistorypack(basepack.mutablebasepack):
nodeindexlength = self.NODEINDEXENTRYLENGTH
files = (
(hashlib.sha1(filename).digest(), filename, offset, size)
(hashutil.sha1(filename).digest(), filename, offset, size)
for filename, (offset, size) in pycompat.iteritems(self.files)
)
files = sorted(files)
......
......@@ -8,7 +8,6 @@ from __future__ import absolute_import
import collections
import errno
import hashlib
import os
import stat
import struct
......@@ -24,6 +23,7 @@ from mercurial import (
util,
)
from mercurial.utils import (
hashutil,
storageutil,
stringutil,
)
......@@ -39,12 +39,12 @@ def isenabled(repo):
def getcachekey(reponame, file, id):
pathhash = node.hex(hashlib.sha1(file).digest())
pathhash = node.hex(hashutil.sha1(file).digest())
return os.path.join(reponame, pathhash[:2], pathhash[2:], id)
def getlocalkey(file, id):
pathhash = node.hex(hashlib.sha1(file).digest())
pathhash = node.hex(hashutil.sha1(file).digest())
return os.path.join(pathhash, id)
......
......@@ -45,7 +45,6 @@ option to ``sqlite`` to enable new repositories to use SQLite for storage.
from __future__ import absolute_import
import hashlib
import sqlite3
import struct
import threading
......@@ -75,7 +74,10 @@ from mercurial.interfaces import (
repository,
util as interfaceutil,
)
from mercurial.utils import storageutil
from mercurial.utils import (
hashutil,
storageutil,
)
try:
from mercurial import zstd
......@@ -807,7 +809,7 @@ class sqlitefilestore(object):
self._db, pathid, node, {}, {-1: None}, zstddctx=self._dctx
)
deltahash = hashlib.sha1(fulltext).digest()
deltahash = hashutil.sha1(fulltext).digest()
if self._compengine == b'zstd':
deltablob = self._cctx.compress(fulltext)
......@@ -837,7 +839,7 @@ class sqlitefilestore(object):
# Now create the tombstone delta and replace the delta on the censored
# node.
deltahash = hashlib.sha1(tombstone).digest()
deltahash = hashutil.sha1(tombstone).digest()
tombstonedeltaid = insertdelta(
self._db, COMPRESSION_NONE, deltahash, tombstone
)
......@@ -1004,7 +1006,7 @@ class sqlitefilestore(object):
# us to de-duplicate. The table is configured to ignore conflicts
# and it is faster to just insert and silently noop than to look
# first.
deltahash = hashlib.sha1(delta).digest()
deltahash = hashutil.sha1(delta).digest()
if self._compengine == b'zstd':
deltablob = self._cctx.compress(delta)
......
......@@ -38,6 +38,7 @@ typedef struct {
} nodetreenode;
typedef struct {
int abi_version;
int (*index_parents)(PyObject *, int, int *);
} Revlog_CAPI;
......@@ -3037,6 +3038,9 @@ static PyTypeObject rustlazyancestorsType = {
#endif /* WITH_RUST */
static Revlog_CAPI CAPI = {
/* increment the abi_version field upon each change in the Revlog_CAPI
struct or in the ABI of the listed functions */
1,
HgRevlogIndex_GetParents,
};
......
......@@ -167,10 +167,10 @@ class appender(object):
def _divertopener(opener, target):
"""build an opener that writes in 'target.a' instead of 'target'"""
def _divert(name, mode=b'r', checkambig=False):
def _divert(name, mode=b'r', checkambig=False, **kwargs):
if name != target:
return opener(name, mode)
return opener(name + b".a", mode)
return opener(name, mode, **kwargs)
return opener(name + b".a", mode, **kwargs)
return _divert
......@@ -178,9 +178,10 @@ def _divertopener(opener, target):
def _delayopener(opener, target, buf):
"""build an opener that stores chunks in 'buf' instead of 'target'"""
def _delay(name, mode=b'r', checkambig=False):
def _delay(name, mode=b'r', checkambig=False, **kwargs):
if name != target:
return opener(name, mode)
return opener(name, mode, **kwargs)
assert not kwargs
return appender(opener, name, mode, buf)
return _delay
......
......@@ -41,7 +41,6 @@ Config
from __future__ import absolute_import
import hashlib
import inspect
import os
import re
......@@ -67,6 +66,7 @@ from . import (
)
from .utils import (
hashutil,
procutil,
stringutil,
)
......@@ -74,7 +74,7 @@ from .utils import (
def _hashlist(items):
"""return sha1 hexdigest for a list"""
return node.hex(hashlib.sha1(stringutil.pprint(items)).digest())
return node.hex(hashutil.sha1(stringutil.pprint(items)).digest())
# sensitive config sections affecting confighash
......
......@@ -2429,12 +2429,16 @@ def walkchangerevs(repo, match, opts, prepare):
def fns_generator():
if allfiles:
fiter = iter(ctx)
else:
fiter = ctx.files()
for f in fiter:
if match(f):
def bad(f, msg):
pass
for f in ctx.matches(matchmod.badmatch(match, bad)):
yield f
else:
for f in ctx.files():
if match(f):
yield f
fns = fns_generator()
prepare(ctx, fns)
......
......@@ -1528,6 +1528,23 @@ class workingctx(committablectx):
for n in p
]
def setparents(self, p1node, p2node=nullid):
dirstate = self._repo.dirstate
with dirstate.parentchange():
copies = dirstate.setparents(p1node, p2node)
pctx = self._repo[p1node]
if copies:
# Adjust copy records, the dirstate cannot do it, it
# requires access to parents manifests. Preserve them
# only for entries added to first parent.
for f in copies:
if f not in pctx and copies[f] in pctx:
dirstate.copy(copies[f], f)
if p2node == nullid:
for f, s in sorted(dirstate.copies().items()):
if f not in pctx and s not in pctx:
dirstate.copy(None, f)
def _fileinfo(self, path):
# populate __dict__['_manifest'] as workingctx has no _manifestdelta
self._manifest
......@@ -2161,6 +2178,10 @@ class overlayworkingctx(committablectx):
# ``overlayworkingctx`` (e.g. with --collapse).
util.clearcachedproperty(self, b'_manifest')
def setparents(self, p1node, p2node=nullid):
assert p1node == self._wrappedctx.node()
self._parents = [self._wrappedctx, self._repo.unfiltered()[p2node]]
def data(self, path):
if self.isdirty(path):
if self._cache[path][b'exists']:
......@@ -2415,9 +2436,9 @@ class overlayworkingctx(committablectx):
``text`` is the commit message.
``parents`` (optional) are rev numbers.
"""
# Default parents to the wrapped contexts' if not passed.
# Default parents to the wrapped context if not passed.
if parents is None:
parents = self._wrappedctx.parents()
parents = self.parents()
if len(parents) == 1:
parents = (parents[0], None)
......@@ -2445,6 +2466,9 @@ class overlayworkingctx(committablectx):
# necessary for memctx to register a deletion.
return None
if branch is None:
branch = self._wrappedctx.branch()
return memctx(
self._repo,
parents,
......
......@@ -27,6 +27,7 @@ from . import (
policy,
pycompat,
scmutil,
sparse,
txnutil,
util,
)
......@@ -1083,6 +1084,76 @@ class dirstate(object):
results[next(iv)] = st
return results
def _rust_status(self, matcher, list_clean, list_ignored, list_unknown):
# Force Rayon (Rust parallelism library) to respect the number of
# workers. This is a temporary workaround until Rust code knows
# how to read the config file.
numcpus = self._ui.configint(b"worker", b"numcpus")
if numcpus is not None:
encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % numcpus)
workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
if not workers_enabled:
encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
(
lookup,
modified,
added,
removed,
deleted,
clean,
ignored,
unknown,
warnings,
bad,
) = rustmod.status(
self._map._rustmap,
matcher,
self._rootdir,
self._ignorefiles(),
self._checkexec,
self._lastnormaltime,
bool(list_clean),
bool(list_ignored),
bool(list_unknown),
)
if self._ui.warn:
for item in warnings:
if isinstance(item, tuple):
file_path, syntax = item
msg = _(b"%s: ignoring invalid syntax '%s'\n") % (
file_path,
syntax,
)
self._ui.warn(msg)
else:
msg = _(b"skipping unreadable pattern file '%s': %s\n")
self._ui.warn(
msg
% (
pathutil.canonpath(
self._rootdir, self._rootdir, item
),
b"No such file or directory",
)
)
for (fn, message) in bad:
matcher.bad(fn, encoding.strtolocal(message))
status = scmutil.status(
modified=modified,
added=added,
removed=removed,
deleted=deleted,
unknown=unknown,
ignored=ignored,
clean=clean,
)
# print(lookup, status)
return (lookup, status)
def status(self, match, subrepos, ignored, clean, unknown):
'''Determine the status of the working copy relative to the
dirstate and return a pair of (unsure, status), where status is of type
......@@ -1108,65 +1179,33 @@ class dirstate(object):
use_rust = True
allowed_matchers = (matchmod.alwaysmatcher, matchmod.exactmatcher)
allowed_matchers = (
matchmod.alwaysmatcher,
matchmod.exactmatcher,
matchmod.includematcher,
)
if rustmod is None:
use_rust = False
elif subrepos:
use_rust = False
elif bool(listunknown):
# Pathauditor does not exist yet in Rust, unknown files
# can't be trusted.
elif sparse.enabled:
use_rust = False
elif self._ignorefiles() and listignored:
# Rust has no ignore mechanism yet, so don't use Rust for
# commands that need ignore.
elif match.traversedir is not None:
use_rust = False
elif not isinstance(match, allowed_matchers):
# Matchers have yet to be implemented
use_rust = False
if use_rust:
# Force Rayon (Rust parallelism library) to respect the number of
# workers. This is a temporary workaround until Rust code knows
# how to read the config file.
numcpus = self._ui.configint(b"worker", b"numcpus")
if numcpus is not None:
encoding.environ.setdefault(
b'RAYON_NUM_THREADS', b'%d' % numcpus
try:
return self._rust_status(
match, listclean, listignored, listunknown
)
workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
if not workers_enabled:
encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
(
lookup,
modified,
added,
removed,
deleted,
unknown,
clean,
) = rustmod.status(
dmap._rustmap,
match,
self._rootdir,
bool(listclean),
self._lastnormaltime,
self._checkexec,
)
status = scmutil.status(
modified=modified,
added=added,
removed=removed,
deleted=deleted,
unknown=unknown,
ignored=ignored,
clean=clean,
)
return (lookup, status)
except rustmod.FallbackError as e:
# FIXME warning?
# print("Fallback: ", e)
pass
def noop(f):
pass
......@@ -1248,13 +1287,11 @@ class dirstate(object):
aadd(fn)
elif state == b'r':
radd(fn)
return (
lookup,
scmutil.status(
modified, added, removed, deleted, unknown, ignored, clean
),
status = scmutil.status(
modified, added, removed, deleted, unknown, ignored, clean
)
# print(lookup, status)
return (lookup, status)
def matches(self, match):
'''
......
......@@ -8,7 +8,6 @@
from __future__ import absolute_import
import collections
import hashlib
from .i18n import _
from .node import (
......@@ -40,7 +39,10 @@ from . import (
wireprototypes,
)
from .interfaces import repository
from .utils import stringutil
from .utils import (
hashutil,
stringutil,
)
urlerr = util.urlerr
urlreq = util.urlreq
......@@ -2705,7 +2707,7 @@ def check_heads(repo, their_heads, context):
Used by peer for unbundling.
"""
heads = repo.heads()
heads_hash = hashlib.sha1(b''.join(sorted(heads))).digest()
heads_hash = hashutil.sha1(b''.join(sorted(heads))).digest()
if not (
their_heads == [b'force']
or their_heads == heads
......
......@@ -9,7 +9,6 @@
from __future__ import absolute_import
import errno
import hashlib
import os
import shutil
import stat
......@@ -48,7 +47,7 @@ from . import (
verify as verifymod,
vfs as vfsmod,
)
from .utils import hashutil
from .interfaces import repository as repositorymod
release = lock.release
......@@ -738,7 +737,7 @@ def clone(
)
elif sharenamemode == b'remote':
sharepath = os.path.join(
sharepool, node.hex(hashlib.sha1(source).digest())
sharepool, node.hex(hashutil.sha1(source).digest())
)
else:
raise error.Abort(
......
......@@ -878,7 +878,9 @@ class ifilestorage(ifileindex, ifiledata, ifilemutation):
If individual revisions cannot have their revision content resolved,
the method is expected to set the ``skipread`` key to a set of nodes
that encountered problems.
that encountered problems. If set, the method can also add the node(s)
to ``safe_renamed`` in order to indicate nodes that may perform the
rename checks with currently accessible data.
The method yields objects conforming to the ``iverifyproblem``
interface.
......
......@@ -8,7 +8,6 @@
from __future__ import absolute_import
import errno
import hashlib
import os
import random
import sys
......@@ -74,6 +73,7 @@ from .interfaces import (
)
from .utils import (
hashutil,
procutil,
stringutil,
)
......@@ -1644,7 +1644,7 @@ class localrepository(object):
user aliases, consider calling ``scmutil.revrange()`` or
``repo.anyrevs([expr], user=True)``.
Returns a revset.abstractsmartset, which is a list-like interface
Returns a smartset.abstractsmartset, which is a list-like interface
that contains integer revisions.
'''
tree = revsetlang.spectree(expr, *args)
......@@ -1886,20 +1886,7 @@ class localrepository(object):
return self.vfs.reljoin(self.root, f, *insidef)
def setparents(self, p1, p2=nullid):
with self.dirstate.parentchange():
copies = self.dirstate.setparents(p1, p2)
pctx = self[p1]
if copies:
# Adjust copy records, the dirstate cannot do it, it
# requires access to parents manifests. Preserve them
# only for entries added to first parent.
for f in copies:
if f not in pctx and copies[f] in pctx:
self.dirstate.copy(copies[f], f)
if p2 == nullid:
for f, s in sorted(self.dirstate.copies().items()):
if f not in pctx and s not in pctx:
self.dirstate.copy(None, f)
self[None].setparents(p1, p2)
def filectx(self, path, changeid=None, fileid=None, changectx=None):
"""changeid must be a changeset revision, if specified.
......@@ -2020,7 +2007,7 @@ class localrepository(object):
)
idbase = b"%.40f#%f" % (random.random(), time.time())
ha = hex(hashlib.sha1(idbase).digest())
ha = hex(hashutil.sha1(idbase).digest())
txnid = b'TXN:' + ha
self.hook(b'pretxnopen', throw=True, txnname=desc, txnid=txnid)
......
......@@ -24,7 +24,7 @@ from . import (
)
from .utils import stringutil
rustmod = policy.importrust('filepatterns')
rustmod = policy.importrust('dirstate')
allpatternkinds = (
b're',
......@@ -45,6 +45,7 @@ cwdrelativepatternkinds = (b'relpath', b'glob')
propertycache = util.propertycache
rustmod = policy.importrust('dirstate')
def _rematcher(regex):
'''compile the regexp with the best available regexp engine and return a
......@@ -666,7 +667,10 @@ class _dirchildren(object):
class includematcher(basematcher):
def __init__(self, root, kindpats, badfn=None):
super(includematcher, self).__init__(badfn)
if rustmod is not None:
# We need to pass the patterns to Rust because they can contain
# patterns from the user interface
self._kindpats = kindpats
self._pats, self.matchfn = _buildmatch(kindpats, b'(?:/|$)', root)
self._prefix = _prefix(kindpats)
roots, dirs, parents = _rootsdirsandparents(kindpats)
......@@ -1273,15 +1277,6 @@ def _regex(kind, pat, globsuffix):
'''Convert a (normalized) pattern of any kind into a
regular expression.
globsuffix is appended to the regexp of globs.'''
if rustmod is not None:
try:
return rustmod.build_single_regex(kind, pat, globsuffix)
except rustmod.PatternError:
raise error.ProgrammingError(
b'not a regex pattern: %s:%s' % (kind, pat)
)
if not pat and kind in (b'glob', b'relpath'):
return b''
if kind == b're':
......@@ -1554,18 +1549,6 @@ def readpatternfile(filepath, warn, sourceinfo=False):
This is useful to debug ignore patterns.
'''
if rustmod is not None:
result, warnings = rustmod.read_pattern_file(
filepath, bool(warn), sourceinfo,
)
for warning_params in warnings:
# Can't be easily emitted from Rust, because it would require
# a mechanism for both gettext and calling the `warn` function.
warn(_(b"%s: ignoring invalid syntax '%s'\n") % warning_params)
return result
syntaxes = {
b're': b'relre:',
b'regexp': b'relre:',
......
......@@ -8,7 +8,6 @@
from __future__ import absolute_import
import errno
import hashlib
import shutil
import stat
import struct
......@@ -39,6 +38,7 @@ from . import (
util,
worker,
)
from .utils import hashutil
_pack = struct.pack
_unpack = struct.unpack
......@@ -512,7 +512,7 @@ class mergestate(object):
"""hash the path of a local file context for storage in the .hg/merge
directory."""
return hex(hashlib.sha1(path).digest())
return hex(hashutil.sha1(path).digest())
def add(self, fcl, fco, fca, fd):
"""add a new (potentially?) conflicting file the merge state
......
......@@ -70,7 +70,6 @@ comment associated with each format for details.
from __future__ import absolute_import
import errno
import hashlib
import struct
from .i18n import _
......@@ -85,7 +84,10 @@ from . import (
pycompat,
util,
)
from .utils import dateutil
from .utils import (
dateutil,
hashutil,
)
parsers = policy.importmod('parsers')
......@@ -1028,7 +1030,7 @@ def _computecontentdivergentset(repo):
def makefoldid(relation, user):
folddigest = hashlib.sha1(user)
folddigest = hashutil.sha1(user)
for p in relation[0] + relation[1]:
folddigest.update(b'%d' % p.rev())
folddigest.update(p.node())
......
......@@ -12,7 +12,6 @@ import collections
import contextlib
import copy
import errno
import hashlib
import os
import re
import shutil
......@@ -41,6 +40,7 @@ from . import (
)
from .utils import (
dateutil,
hashutil,
procutil,
stringutil,
)
......@@ -2943,7 +2943,7 @@ def trydiff(
if not text:
text = b""
l = len(text)
s = hashlib.sha1(b'blob %d\0' % l)
s = hashutil.sha1(b'blob %d\0' % l)
s.update(text)
return hex(s.digest())
......
......@@ -243,49 +243,50 @@ class phasecache(object):
"""return a smartset for the given phases"""
self.loadphaserevs(repo) # ensure phase's sets are loaded
phases = set(phases)
publicphase = public in phases
if public not in phases:
# fast path: _phasesets contains the interesting sets,
# might only need a union and post-filtering.
if len(phases) == 1:
[p] = phases
revs = self._phasesets[p]
else:
revs = set.union(*[self._phasesets[p] for p in phases])
if publicphase:
# In this case, phases keeps all the *other* phases.
phases = set(allphases).difference(phases)
if not phases:
return smartset.fullreposet(repo)
# fast path: _phasesets contains the interesting sets,
# might only need a union and post-filtering.
revsneedscopy = False
if len(phases) == 1:
[p] = phases
revs = self._phasesets[p]
revsneedscopy = True # Don't modify _phasesets
else:
# revs has the revisions in all *other* phases.
revs = set.union(*[self._phasesets[p] for p in phases])
def _addwdir(wdirsubset, wdirrevs):
if wdirrev in wdirsubset and repo[None].phase() in phases:
if revsneedscopy:
wdirrevs = wdirrevs.copy()
# The working dir would never be in the # cache, but it was in
# the subset being filtered for its phase (or filtered out,
# depending on publicphase), so add it to the output to be
# included (or filtered out).
wdirrevs.add(wdirrev)
return wdirrevs
if not publicphase:
if repo.changelog.filteredrevs:
revs = revs - repo.changelog.filteredrevs
if subset is None:
return smartset.baseset(revs)
else:
if wdirrev in subset and repo[None].phase() in phases:
# The working dir would never be in the cache, but it was
# in the subset being filtered for its phase, so add it to
# the output.
revs.add(wdirrev)
revs = _addwdir(subset, revs)
return subset & smartset.baseset(revs)
else:
# phases keeps all the *other* phases.
phases = set(allphases).difference(phases)
if not phases:
return smartset.fullreposet(repo)
# revs has the revisions in all *other* phases.
if len(phases) == 1:
[p] = phases
revs = self._phasesets[p]
else:
revs = set.union(*[self._phasesets[p] for p in phases])
if subset is None:
subset = smartset.fullreposet(repo)
if wdirrev in subset and repo[None].phase() in phases:
# The working dir is in the subset being filtered, and its
# phase is in the phases *not* being returned, so add it to the
# set of revisions to filter out.
revs.add(wdirrev)
revs = _addwdir(subset, revs)
if not revs:
return subset
......
......@@ -9,7 +9,6 @@
from __future__ import absolute_import
import errno
import hashlib
from .i18n import _
from .node import (
......@@ -29,7 +28,10 @@ from . import (
pycompat,
util,
)
from .utils import stringutil
from .utils import (
hashutil,
stringutil,
)
def backupbundle(
......@@ -45,7 +47,7 @@ def backupbundle(
# Include a hash of all the nodes in the filename for uniqueness
allcommits = repo.set(b'%ln::%ln', bases, heads)
allhashes = sorted(c.hex() for c in allcommits)
totalhash = hashlib.sha1(b''.join(allhashes)).digest()
totalhash = hashutil.sha1(b''.join(allhashes)).digest()
name = b"%s/%s-%s-%s.hg" % (
backupdir,
short(node),
......
......@@ -592,10 +592,10 @@ class revlog(object):
self._storedeltachains = True
self._io = revlogio()
if rustrevlog is not None and self.opener.options.get(b'rust.index'):
self._io = rustrevlogio()
if self.version == REVLOGV0:
self._io = revlogoldio()
elif rustrevlog is not None and self.opener.options.get(b'rust.index'):
self._io = rustrevlogio()
try:
d = self._io.parseindex(indexdata, self._inline)
except (ValueError, IndexError):
......@@ -2874,6 +2874,7 @@ class revlog(object):
)
state[b'skipread'] = set()
state[b'safe_renamed'] = set()
for rev in self:
node = self.node(rev)
......
......@@ -33,10 +33,10 @@ the concept.
from __future__ import absolute_import
import hashlib
import struct
from .. import error
from ..utils import hashutil
## sidedata type constant