diff --git a/.hgsigs b/.hgsigs --- a/.hgsigs +++ b/.hgsigs @@ -254,3 +254,4 @@ c083d9776cb2fb6056715b2988d1ea48055f3162 27055614b68538576fb0439007009acf93fe0a49 0 iQHNBAABCgA3FiEEH2b4zfZU6QXBHaBhoR4BzQ4F2VYFAmVKXukZHGFscGhhcmVAcmFwaGFlbGdvbWVzLmRldgAKCRChHgHNDgXZVg5UDACTnRyxApQMQLaRX9khRB6E5XkSJqpR3wqXr5yMLaqgaUGzUUaupA8zTjWoIDM730V1hWliWinQGD/3XA7qUQ31VALRQq8PlvzMEkSz0NB2IDBU6uHdhNAkZQeYm7qJwpzCIuPs/diVm97oUJr0+Y7KJKV7ZxUtZ1bEBHq/FUgyVnLkVQJdb1p28ECIKQ8SS7XY5C8rdYGa1fHYpsLAfTbAunVOEl6Phi3Y3ZqNgcet8WAP+6MwXpgf6ye9O1p2HSaM4BFq2d8AizksjSCuVTTRtuCkpcLDGCtvb6dOJxb4TpMyaYWXerolEGF3ZJsaVgOi/bH7aDsoJP0I5IJnmxiyVjOvOUDd5o3nn0SElsp45r0udGlos5r6tW+kZ9OBBH8nv3AcFxuGD8YFPB3AMRcqIBG1tNLa02bOAaF+uFKVB+YGWHowZtC+SdN2XZ1tp7BD/3CQo+PrpZzEDdVs9S30wef5k+2Nrj2/8tOF/XULy1BRxQV+k2PTlE1/mTaEY60= 26c57e7a0890b96e2c473b394de380d6753c9230 0 iQHNBAABCgA3FiEEH2b4zfZU6QXBHaBhoR4BzQ4F2VYFAmVcykAZHGFscGhhcmVAcmFwaGFlbGdvbWVzLmRldgAKCRChHgHNDgXZVoGeC/0Uvynfd4xJMSa3ef4lOrw3l0PsOMzLwcITC5b4SlMfo8sHDq1Vr169z/IvI/FhJ8LmK/Spg7OK6TkqJ33fOmpnKZji8oCstM8q0P6xZh55RIE4St8Px/TuC99HvB41sPgcBDQf/dfvXqUKHImxH5C21p93AkvdCie9sdeYzy23VSn1URBBRkfToB6U7QDvktiKE4Hy/mJolN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gAKCRChHgHNDgXZVtVFDACX0F3mxc9xtIlaQaze8z9LnTg0dluNZiuM2C74o9jdVW5Jq+jhF7HjiGxRr2D5a/RhaPHg3bgRSf3Pjm0js9XSE0D9+HHZW3t29M37ShgknA2g9N1kADXkrg5frdOHYfa9tqhyWp78Vupydkh08iK4/5Prb/EPrDF3+GXwOJcIJ7xo4aQ7MVjwAzQkbUjzVqDd4x4HCRsT1jzUetnzuPXB6nWXcM521wbQjD9s4PceaAFPNyYXnckuSaNribSyCU6t3IqgMSxIr73khijc3+yCFHyTznEa3fNI7gp1VJygi69Ukt18YWJOG/dm0GGHvKunQUKcYFAAX2FY7NnQAqI/zqUDyg2vHE3ufy/F2tmNbpOnVuOz2/YYlIcTSF4llyt80IB89WrfdwTZqNUfZcwPgFG8ajW5v/jHvic5DZSxvDfmCvNIxhtOoz8BVZMXi3DzDOMbT20D9leCcBwmHoFYNAZC/z4QwkrXFgrbFiy27Sj5LqFqO1hlY3NVpk01F2w= diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -270,3 +270,4 @@ c083d9776cb2fb6056715b2988d1ea48055f3162 27055614b68538576fb0439007009acf93fe0a49 6.6rc0 26c57e7a0890b96e2c473b394de380d6753c9230 6.6 71bd09bebbe36a09569cbfb388f371433360056b 6.6.1 +136902b3a95db38854ebaf5198a627641065c2ea 6.6.2 diff --git a/hgext/narrow/narrowwirepeer.py b/hgext/narrow/narrowwirepeer.py --- a/hgext/narrow/narrowwirepeer.py +++ b/hgext/narrow/narrowwirepeer.py @@ -6,6 +6,10 @@ # GNU General Public License version 2 or any later version. +from mercurial.i18n import _ + +from mercurial.utils import stringutil + from mercurial import ( bundle2, error, @@ -82,20 +86,38 @@ def narrow_widen( # work around ''.split(',') => [''] return data.split(b',') if data else [] - oldincludes = splitpaths(oldincludes) - newincludes = splitpaths(newincludes) - oldexcludes = splitpaths(oldexcludes) - newexcludes = splitpaths(newexcludes) + oldincludes = set(splitpaths(oldincludes)) + newincludes = set(splitpaths(newincludes)) + oldexcludes = set(splitpaths(oldexcludes)) + newexcludes = set(splitpaths(newexcludes)) # enforce narrow acl if set if repo.ui.has_section(exchange._NARROWACL_SECTION): - exchange.applynarrowacl(repo, {'includepats': newincludes}) + kwargs = exchange.applynarrowacl( + repo, {'includepats': newincludes, 'excludepats': newexcludes} + ) + newincludes = kwargs['includepats'] + requiredexcludes = kwargs['excludepats'] - newexcludes + if requiredexcludes: + # XXX: The below code to get the username was copied from exchange.py, + # where it is noted that this is technically a layering violation for + # assuming the existence of HTTP. Using it anyway to make the error + # message consistent with the error message for invalid includes. + ui = repo.ui + username = ui.shortuser( + ui.environ.get(b'REMOTE_USER') or ui.username() + ) + raise error.Abort( + _(b"The following excludes cannot be removed for %s: %s") + % (username, stringutil.pprint(list(requiredexcludes))) + ) + newexcludes = kwargs['excludepats'] # validate the patterns - narrowspec.validatepatterns(set(oldincludes)) - narrowspec.validatepatterns(set(newincludes)) - narrowspec.validatepatterns(set(oldexcludes)) - narrowspec.validatepatterns(set(newexcludes)) + narrowspec.validatepatterns(oldincludes) + narrowspec.validatepatterns(newincludes) + narrowspec.validatepatterns(oldexcludes) + narrowspec.validatepatterns(newexcludes) common = wireprototypes.decodelist(commonheads) known = wireprototypes.decodelist(known) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1593,13 +1593,13 @@ def bundle(ui, repo, fname, *dests, **op _(b'packed bundles cannot be produced by "hg bundle"'), hint=_(b"use 'hg debugcreatestreamclonebundle'"), ) - + base_opt = opts.get('base') if opts.get('all'): if dests: raise error.InputError( _(b"--all is incompatible with specifying destinations") ) - if opts.get('base'): + if base_opt: ui.warn(_(b"ignoring --base because --all was specified\n")) if opts.get('exact'): ui.warn(_(b"ignoring --exact because --all was specified\n")) @@ -1609,19 +1609,24 @@ def bundle(ui, repo, fname, *dests, **op raise error.InputError( _(b"--exact is incompatible with specifying destinations") ) - if opts.get('base'): + if base_opt: ui.warn(_(b"ignoring --base because --exact was specified\n")) base = repo.revs(b'parents(%ld) - %ld', revs, revs) if not base: base = [nullrev] + elif base_opt: + base = logcmdutil.revrange(repo, base_opt) + if not base: + # base specified, but nothing was selected + base = [nullrev] else: - base = logcmdutil.revrange(repo, opts.get('base')) + base = None if cgversion not in changegroup.supportedoutgoingversions(repo): raise error.Abort( _(b"repository does not support bundle version %s") % cgversion ) - if base: + if base is not None: if dests: raise error.InputError( _(b"--base is incompatible with specifying destinations") diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -202,6 +202,13 @@ class bytestr(bytes): >>> bytestr(bytesable()) 'bytes' + ...unless the argument is the bytes *type* itself: it gets a + __bytes__() method in Python 3.11, which cannot be used as in an instance + of bytes: + + >>> bytestr(bytes) + "" + There's no implicit conversion from non-ascii str as its encoding is unknown: @@ -251,10 +258,9 @@ class bytestr(bytes): def __new__(cls: Type[_Tbytestr], s: object = b'') -> _Tbytestr: if isinstance(s, bytestr): return s - if not isinstance( - s, (bytes, bytearray) - ) and not builtins.hasattr( # hasattr-py3-only - s, u'__bytes__' + if not isinstance(s, (bytes, bytearray)) and ( + isinstance(s, type) + or not builtins.hasattr(s, u'__bytes__') # hasattr-py3-only ): s = str(s).encode('ascii') return bytes.__new__(cls, s) diff --git a/relnotes/6.6 b/relnotes/6.6 --- a/relnotes/6.6 +++ b/relnotes/6.6 @@ -1,3 +1,12 @@ += Mercurial 6.6.2 = + + * histedit: remove superfluous echo() and endwin() calls (issue6859) + * persistent-nodemap: avoid writing nodemap for empty revlog + * persistent-nodemap: respect the mmap setting when refreshing data + * bundle: do not detect --base argument that match nothing as lack of argument + * narrow: prevent removal of ACL-defined excludes + * pycompat: fix bytestr(bytes) in Python 3.11 + = Mercurial 6.6.1 = The first two patches fix aborted transactions that could happen since 6.6. diff --git a/tests/test-bundle-r.t b/tests/test-bundle-r.t --- a/tests/test-bundle-r.t +++ b/tests/test-bundle-r.t @@ -140,6 +140,10 @@ should fail $ hg -R test bundle --base 2 --all test-bundle-all-2.hg ignoring --base because --all was specified 9 changesets found + $ hg -R test bundle --base 3-3 -r tip test-base-match-nothing-with-dest.hg --config paths.default=$TESTTMP/test-3 + 5 changesets found + $ hg -R test bundle --base 3-3 -r tip test-base-match-nothing-no-dest.hg + 5 changesets found $ hg -R test bundle --base 3 -r tip test-bundle-should-fail.hg 1 changesets found diff --git a/tests/test-narrow-acl.t b/tests/test-narrow-acl-excludes.t copy from tests/test-narrow-acl.t copy to tests/test-narrow-acl-excludes.t --- a/tests/test-narrow-acl.t +++ b/tests/test-narrow-acl-excludes.t @@ -1,4 +1,4 @@ -Make a narrow clone then archive it +Test exclusion-based ACL enforcement $ . "$TESTDIR/narrow-library.sh" $ hg init master @@ -11,7 +11,9 @@ Make a narrow clone then archive it > done $ cat >> .hg/hgrc << EOF > [narrowacl] - > default.includes=f1 f2 + > default.includes=* + > default.excludes=f2 f3 + > test.excludes=f3 > EOF $ hg serve -a localhost -p $HGPORT1 -d --pid-file=hg.pid $ cat hg.pid >> "$DAEMON_PIDS" @@ -37,43 +39,37 @@ Requirements should contain narrowhg $ hg debugrequires -R narrowclone1 | grep narrowhg narrowhg-experimental -NarrowHG should track f1 and f2 +NarrowHG should exclude f3. $ hg -R narrowclone1 tracked - I path:f1 - I path:f2 + I path:. + X path:f3 Narrow should not be able to widen to include f3 $ hg -R narrowclone1 tracked --addinclude f3 comparing with http://localhost:$HGPORT1/ searching for changes - abort: The following includes are not accessible for test: ['path:f3'] + adding changesets + adding manifests + adding file changes + $ ls -A -1 narrowclone1 | sort + .hg + f1 + f2 + $ hg -R narrowclone1 tracked + I path:. + X path:f3 + + +Narrow should not be able to remove the exclusion for f3 + $ hg -R narrowclone1 tracked --removeexclude f3 + comparing with http://localhost:$HGPORT1/ + searching for changes + abort: The following excludes cannot be removed for test: ['path:f3'] [255] $ ls -A -1 narrowclone1 | sort .hg f1 f2 $ hg -R narrowclone1 tracked - I path:f1 - I path:f2 - -Narrow should allow widen to include f2 - $ hg -R narrowclone1 tracked --removeinclude f2 > /dev/null - $ hg -R narrowclone1 tracked - I path:f1 - $ ls -A -1 narrowclone1 | sort - .hg - f1 - $ hg -R narrowclone1 tracked --addinclude f2 - comparing with http://localhost:$HGPORT1/ - searching for changes - adding changesets - adding manifests - adding file changes - added 0 changesets with 1 changes to 1 files - $ hg -R narrowclone1 tracked - I path:f1 - I path:f2 - $ ls -A -1 narrowclone1 | sort - .hg - f1 - f2 + I path:. + X path:f3