D9572: revlog: support none compression

2020-12-12 Thread joerg.sonnenberger (Joerg Sonnenberger)
joerg.sonnenberger created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  revlog files had uncompressed revlog entries support since forever, but
  it wasn't selectable or exposed explicitly. It is occassionally useful
  for performance testing as it avoids the latency of zlib or zstd. It
  also has the nice side effect of providing a non-default compression
  engine out-of-the-box.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9572

AFFECTED FILES
  mercurial/utils/compression.py
  tests/test-repo-compengines.t

CHANGE DETAILS

diff --git a/tests/test-repo-compengines.t b/tests/test-repo-compengines.t
--- a/tests/test-repo-compengines.t
+++ b/tests/test-repo-compengines.t
@@ -43,6 +43,27 @@
 
   $ cd ..
 
+Specifying a new format.compression on an existing repo won't introduce data
+with that engine or a requirement
+
+  $ cd default
+  $ touch bar
+  $ hg --config format.revlog-compression=none -q commit -A -m 'add bar with a 
lot of repeated repeated repeated text'
+
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  revlogv1
+  sparserevlog
+  store
+  testonly-simplestore (reposimplestore !)
+
+  $ hg debugrevlog -c | grep 0x78
+  0x78 (x)  :   2 (100.00%)
+  0x78 (x)  : 199 (100.00%)
+  $ cd ..
+
 #if zstd
 
   $ hg --config format.revlog-compression=zstd init zstd
@@ -66,25 +87,6 @@
 
   $ cd ..
 
-Specifying a new format.compression on an existing repo won't introduce data
-with that engine or a requirement
-
-  $ cd default
-  $ touch bar
-  $ hg --config format.revlog-compression=zstd -q commit -A -m 'add bar with a 
lot of repeated repeated repeated text'
-
-  $ cat .hg/requires
-  dotencode
-  fncache
-  generaldelta
-  revlogv1
-  sparserevlog
-  store
-  testonly-simplestore (reposimplestore !)
-
-  $ hg debugrevlog -c | grep 0x78
-  0x78 (x)  :   2 (100.00%)
-  0x78 (x)  : 199 (100.00%)
 
 #endif
 
@@ -116,10 +118,12 @@
   > done
 
   $ $RUNTESTDIR/f -s */.hg/store/data/*
-  default/.hg/store/data/foo.i: size=64 (pure !)
+  default/.hg/store/data/bar.i: size=64
+  default/.hg/store/data/foo.i: size=64
   zlib-level-1/.hg/store/data/a.i: size=4146
   zlib-level-9/.hg/store/data/a.i: size=4138
   zlib-level-default/.hg/store/data/a.i: size=4138
+  zstd/.hg/store/data/foo.i: size=64 (zstd !)
 
 Test error cases
 
@@ -144,6 +148,41 @@
   abort: invalid value for `storage.revlog.zlib.level` config: 42
   [255]
 
+checking details of none compression
+
+
+  $ hg init none-compression --config format.revlog-compression=none
+
+  $ commitone() {
+  >repo=$1
+  >cp $RUNTESTDIR/bundles/issue4438-r1.hg $repo/a
+  >hg -R $repo add $repo/a
+  >hg -R $repo commit -m some-commit
+  > }
+
+  $ commitone none-compression
+
+  $ hg log -R none-compression
+  changeset:   0:68b53da39cd8
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: some-commit
+  
+
+  $ cat none-compression/.hg/requires
+  dotencode
+  exp-compression-none
+  fncache
+  generaldelta
+  revlogv1
+  sparserevlog
+  store
+  testonly-simplestore (reposimplestore !)
+
+  $ $RUNTESTDIR/f -s none-compression/.hg/store/data/*
+  none-compression/.hg/store/data/a.i: size=4216
+
 #if zstd
 
 checking zstd options
diff --git a/mercurial/utils/compression.py b/mercurial/utils/compression.py
--- a/mercurial/utils/compression.py
+++ b/mercurial/utils/compression.py
@@ -617,8 +617,10 @@
 def wireprotosupport(self):
 return compewireprotosupport(b'none', 0, 10)
 
-# We don't implement revlogheader because it is handled specially
-# in the revlog class.
+# revlog special cases the uncompressed case, but implementing
+# revlogheader allows forcing uncompressed storage.
+def revlogheader(self):
+return b'\0'
 
 def compressstream(self, it, opts=None):
 return it



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 6455] New: TypeError in debuguigetpass

2020-12-12 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=6455

Bug ID: 6455
   Summary: TypeError in debuguigetpass
   Product: Mercurial
   Version: 5.6
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: z...@zash.se
CC: mercurial-devel@mercurial-scm.org
Python Version: 3.7

For reasons unknown, I tried a random debug command, got this traceback:

$ HOME=/tmp/emptydir HGPLAIN=y hg debuguigetpass
password: 
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
** Mercurial Distributed SCM (version 5.6)
** Extensions loaded: 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mercurial/commandserver.py", line 499,
in _serverequest
sv.serve()
  File "/usr/lib/python3/dist-packages/mercurial/commandserver.py", line 403,
in serve
while self.serveone():
  File "/usr/lib/python3/dist-packages/mercurial/commandserver.py", line 377,
in serveone
handler(self)
  File "/usr/lib/python3/dist-packages/mercurial/chgserver.py", line 563, in
runcommand
return super(chgcmdserver, self).runcommand()
  File "/usr/lib/python3/dist-packages/mercurial/commandserver.py", line 358,
in runcommand
ret = self._dispatchcommand(req) & 255
  File "/usr/lib/python3/dist-packages/mercurial/commandserver.py", line 297,
in _dispatchcommand
return dispatch.dispatch(req)
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 303, in
dispatch
ret = _runcatch(req) or 0
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 479, in
_runcatch
return _callcatch(ui, _runcatchfunc)
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 488, in
_callcatch
return scmutil.callcatch(ui, func)
  File "/usr/lib/python3/dist-packages/mercurial/scmutil.py", line 153, in
callcatch
return func()
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 469, in
_runcatchfunc
return _dispatch(req)
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1233, in
_dispatch
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 917, in
runcommand
ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1244, in
_runcommand
return cmdfunc()
  File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1230, in

d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/usr/lib/python3/dist-packages/mercurial/util.py", line 1867, in check
return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/mercurial/debugcommands.py", line 3790,
in debuguigetpass
ui.writenoi18n(b'response: %s\n' % r)
TypeError: %b requires a bytes-like object, or an object that implements
__bytes__, not 'str'


In default:d42809b6b10f this happens:

hg$ HOME=/tmp/emptydir HGPLAIN=y python3 ./hg debuguigetpass 
password: 
** unknown exception encountered, please report by visiting
** https://mercurial-scm.org/wiki/BugTracker
** Python 3.7.3 (default, Jul 25 2020, 13:03:44) [GCC 8.3.0]
** Mercurial Distributed SCM (version unknown)
** Extensions loaded: 
Traceback (most recent call last):
  File "./hg", line 43, in 
dispatch.run()
  File "/home/zash/src/hg/mercurial/dispatch.py", line 115, in run
status = dispatch(req)
  File "/home/zash/src/hg/mercurial/dispatch.py", line 266, in dispatch
ret = _runcatch(req) or 0
  File "/home/zash/src/hg/mercurial/dispatch.py", line 442, in _runcatch
return _callcatch(ui, _runcatchfunc)
  File "/home/zash/src/hg/mercurial/dispatch.py", line 451, in _callcatch
return scmutil.callcatch(ui, func)
  File "/home/zash/src/hg/mercurial/scmutil.py", line 155, in callcatch
return func()
  File "/home/zash/src/hg/mercurial/dispatch.py", line 432, in _runcatchfunc
return _dispatch(req)
  File "/home/zash/src/hg/mercurial/dispatch.py", line 1229, in _dispatch
lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions
  File "/home/zash/src/hg/mercurial/dispatch.py", line 883, in runcommand
ret = _runcommand(ui, options, cmd, d)
  File "/home/zash/src/hg/mercurial/dispatch.py", line 1240, in _runcommand
return cmdfunc()
  File "/home/zash/src/hg/mercurial/dispatch.py", line 1226, in 
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/home/zash/src/hg/mercurial/util.py", line 1867, in check
return func(*args, **kwargs)
  File "/home/zash/src/hg/mercurial/debugcommands.py", line 3801, in
debuguigetpass
r = encoding.strtolocal(r)
  File "/home/zash/src/hg/mercurial/encoding.py", line 248, in unitolocal
return tolocal(u.encode('utf-8'))
AttributeError: 'bytes' object has 

D9570: debugcommands: introduce command to upgrade/downgrade shares

2020-12-12 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In past few months, we have developed functionality to share requirements and
  configs of share-source and a way to upgrade repository from old format to
  share-safe format using `debugupgraderepo` command.
  
  However there is still no way to upgrade the shares as `debugupgraderepo` does
  not support upgrading that.
  
  Having share-safe rolled out in existing setup is quite important and hence we
  need a way to upgrade existing shares once share-source upgrades.
  
  This patch introduces a new debug command `debugsharesafe` which can be used 
to
  upgrade or downgrade shares.
  
  Functionality to upgrade shares to use the new method is the last thing left 
in
  the whole work.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9570

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-completion.t
  tests/test-help.t
  tests/test-share-safe.t

CHANGE DETAILS

diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -70,6 +70,16 @@
   $ echo c > c
   $ hg ci -Aqm "added c"
 
+  $ hg debugsharesafe
+  abort: nothing specified
+  [10]
+  $ hg debugsharesafe --upgrade --downgrade
+  abort: cannot specify both --upgrade and --downgrade
+  [10]
+  $ hg debugsharesafe --upgrade
+  abort: repository already uses share-safe method
+  [20]
+
 Check that config of the source repository is also loaded
 
   $ hg showconfig ui.curses
@@ -399,6 +409,26 @@
   o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
   
 
+  $ hg debugsharesafe -R ../nss-share --downgrade
+  warning: source repository supports share-safe functionality. Reshare to 
upgrade.
+  abort: repository does not uses share safe method, nothing to do
+  [20]
+
+  $ hg debugsharesafe -R ../nss-share --upgrade
+  warning: source repository supports share-safe functionality. Reshare to 
upgrade.
+  repository upgraded to use share-safe functionality
+  requirements and configs of shared-source will be read from now onwards
+
+  $ hg log -GT "{node}: {desc}\n" -R ../nss-share
+  @  f63db81e6dde1d9c78814167f77fb1fb49283f4f: added bar
+  |
+  o  f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo
+  
+
+  $ hg debugsharesafe -R ../nss-share --downgrade
+  repository downgraded to not use share-safe functionality
+
+
 
 Create a safe share from upgrade one
 
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -1068,6 +1068,8 @@
debugserverun a server with advanced settings
debugsetparents
  manually set the parents of the current working directory
+   debugsharesafe
+ upgrade or downgrade shares to enable/disable share-safe mode
debugsidedata
  dump the side data for a cl/manifest/file revision
debugssl  test a secure connection to a server
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -129,6 +129,7 @@
   debugrevspec
   debugserve
   debugsetparents
+  debugsharesafe
   debugsidedata
   debugssl
   debugstrip
@@ -318,6 +319,7 @@
   debugrevspec: optimize, show-revs, show-set, show-stage, no-optimized, 
verify-optimized
   debugserve: sshstdio, logiofd, logiofile
   debugsetparents: 
+  debugsharesafe: upgrade, downgrade, force
   debugsidedata: changelog, manifest, dir
   debugssl: 
   debugstrip: rev, force, no-backup, nobackup, , keep, bookmark, soft
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -69,6 +69,7 @@
 pycompat,
 registrar,
 repair,
+requirements as requirementsmod,
 revlog,
 revset,
 revsetlang,
@@ -3695,6 +3696,107 @@
 
 
 @command(
+b'debugsharesafe',
+[
+(b'', b'upgrade', False, _(b'upgrade current share to share safe')),
+(b'', b'downgrade', False, _(b'downgrade current share')),
+(b'', b'force', False, _(b'forcefully perform operation')),
+],
+)
+def debugsharesafe(ui, repo, *args, **opts):
+"""upgrade or downgrade shares to enable/disable share-safe mode"""
+if not repo.shared():
+raise error.InputError(_(b"current repository is not shared one"))
+
+cmdutil.check_at_most_one_arg(opts, 'upgrade', 'downgrade')
+upgrade = opts.get('upgrade')
+downgrade = opts.get('downgrade')
+
+if not upgrade and not downgrade:
+raise error.InputError(_(b"nothing specified"))
+
+current_requirements = repo.requirements
+if upgrade:
+if requirementsmod.SHARESAFE_REQUIREMENT in current_requirements:
+raise error.StateError(
+_(b"repository already uses share-safe method")
+)
+
+sharesourcerequires = localrepo._readrequires(
+

D9571: debugsharesafe: recommend from `debugupgraderepo` and `help -e share -v`

2020-12-12 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Recommending one debug command from another one sounds fine to me.
  
  Also documentation about share-safe in `hg help -e share -v` was lacking 
correct
  description on how upgrade existing shares. This fixes that and also start
  mentioning about debugsharesafe.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9571

AFFECTED FILES
  hgext/share.py
  mercurial/upgrade.py
  tests/test-share-safe.t

CHANGE DETAILS

diff --git a/tests/test-share-safe.t b/tests/test-share-safe.t
--- a/tests/test-share-safe.t
+++ b/tests/test-share-safe.t
@@ -372,7 +372,8 @@
 - changelog
 - manifest
   
-  repository upgraded to share safe mode, existing shares will still work in 
old non-safe mode. Re-share existing shares to use them in safe mode New shares 
will be created in safe mode.
+  repository upgraded to share safe mode, existing shares will still work in 
old non-safe mode.
+  (Run `hg debugsharesafe --upgrade` in shares to  update them to use share 
safe mode.)
 
   $ hg debugrequirements
   dotencode
@@ -475,7 +476,8 @@
 - changelog
 - manifest
   
-  repository downgraded to not use share safe mode, existing shares will not 
work and needs to be reshared.
+  repository downgraded to not use share safe mode, existing shares will not 
work.
+  (Run `hg debugsharesafe --downgrade` in shares to downgrade them.)
 
   $ hg debugrequirements
   dotencode
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -309,16 +309,17 @@
 ui.warn(
 _(
 b'repository upgraded to share safe mode, existing'
-b' shares will still work in old non-safe mode. '
-b'Re-share existing shares to use them in safe mode'
-b' New shares will be created in safe mode.\n'
+b' shares will still work in old non-safe mode.\n'
+b'(Run `hg debugsharesafe --upgrade` in shares to '
+b' update them to use share safe mode.)\n'
 )
 )
 if upgrade_actions.sharesafe.name in removedreqs:
 ui.warn(
 _(
 b'repository downgraded to not use share safe mode, '
-b'existing shares will not work and needs to'
-b' be reshared.\n'
+b'existing shares will not work.\n(Run `hg '
+b'debugsharesafe --downgrade` in shares '
+b'to downgrade them.)\n'
 )
 )
diff --git a/hgext/share.py b/hgext/share.py
--- a/hgext/share.py
+++ b/hgext/share.py
@@ -59,10 +59,9 @@
 requirements. This only applies to shares which are done after enabling
 the config option.
 
-For enabling this in existing shares, enable the config option and reshare.
-
-For resharing existing shares, make sure your working directory is clean
-and there are no untracked files, delete that share and create a new share.
+For enabling this in existing shares, upgrade the shared-source using
+`hg debugupgraderepo` and then upgrade shares using
+`hg debugsharesafe --upgrade` command.
 '''
 
 from __future__ import absolute_import



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9569: contrib: run python3+chg tests too in heptapod CI

2020-12-12 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Recent patches made the CI on python3+chg green. Let's enable this before 
there
  are more failures to fix.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9569

AFFECTED FILES
  contrib/heptapod-ci.yml

CHANGE DETAILS

diff --git a/contrib/heptapod-ci.yml b/contrib/heptapod-ci.yml
--- a/contrib/heptapod-ci.yml
+++ b/contrib/heptapod-ci.yml
@@ -114,3 +114,10 @@
 variables:
 RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt --chg"
 TEST_HGMODULEPOLICY: "c"
+
+test-py3-chg:
+<<: *runtests
+variables:
+PYTHON: python3
+RUNTEST_ARGS: "--blacklist /tmp/check-tests.txt --chg"
+TEST_HGMODULEPOLICY: "c"



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D9568: scmutil: improve documentation of writereporequirements()

2020-12-12 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This makes it easier to understand the difference between `writerequires()`
  and `writereporequirements()`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9568

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1572,7 +1572,12 @@
 
 
 def writereporequirements(repo, requirements=None):
-""" writes requirements for the repo to .hg/requires """
+"""writes requirements for the repo
+
+Requirements are written to .hg/requires and .hg/store/requires based
+on whether share-safe mode is enabled and which requirements are wdir
+requirements and which are store requirements
+"""
 if requirements:
 repo.requirements = requirements
 wcreq, storereq = filterrequirements(repo.requirements)



To: pulkit, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel