Re: [PATCH 01 of 10] revlog: split a `_revisiondata` method to file `revision` job

2019-08-07 Thread Gregory Szorc
On Wed, Aug 7, 2019 at 2:44 PM Pierre-Yves David <
pierre-yves.da...@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1565190888 -7200
> #  Wed Aug 07 17:14:48 2019 +0200
> # Node ID 3b49bb04851ea501f005e7a58403fee3b1c52958
> # Parent  4710384df490f426ba53055537b16030dc61d957
> # EXP-Topic rawdata
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 3b49bb04851e
> revlog: split a `_revisiondata` method to file `revision` job
>

I'll try to look at this series on Thursday. I apologize for not getting to
it today.


>
> We are about to introduce more public method to access revision data (eg:
> `rawdata`). revset subclass tend to recursively call `revision` which will
> create all kind of issue with the coming series. To avoid them we
> introduce an
> explicit difference between the internal call and the public all. This
> will be
> useful for later work anyway (so the subclass issue is just moving it
> earlier in
> the series). I am not sure if the subclass are actually doing something
> sensible. However, I am certain I don't want to be rabbit holed into
> figuring it
> out right now.
>
> diff --git a/mercurial/revlog.py b/mercurial/revlog.py
> --- a/mercurial/revlog.py
> +++ b/mercurial/revlog.py
> @@ -1651,6 +1651,9 @@ class revlog(object):
>  treated as raw data when applying flag transforms. 'raw' should
> be set
>  to True when generating changegroups or in debug commands.
>  """
> +return self._revisiondata(nodeorrev, _df, raw=raw)
> +
> +def _revisiondata(self, nodeorrev, _df=None, raw=False):
>  if isinstance(nodeorrev, int):
>  rev = nodeorrev
>  node = self.node(rev)
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 6 of 9] flagutil: introduce a flagprocessorsmixin class

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565219568 -7200
#  Thu Aug 08 01:12:48 2019 +0200
# Node ID 466943d2fed3602e08ac9117afef1c727bcb98a5
# Parent  82e7f9d4d0bac574e4aa1b8f81e81ac1df3f6ddc
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
466943d2fed3
flagutil: introduce a flagprocessorsmixin class

To avoid code duplication, we will provide a simple "ready to use" mixin that
carry the appropriate logic. First we use it in standard revlog, we'll remove
code duplication in later changesets.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -259,7 +259,7 @@ class revlogio(object):
 p = versionformat_pack(version) + p[4:]
 return p
 
-class revlog(object):
+class revlog(flagutil.flagprocessorsmixin):
 """
 the underlying revision storage object
 
@@ -1682,69 +1682,6 @@ class revlog(object):
 """
 return storageutil.hashrevisionsha1(text, p1, p2)
 
-def _processflags(self, text, flags, operation, raw=False):
-"""Inspect revision data flags and applies transforms defined by
-registered flag processors.
-
-``text`` - the revision data to process
-``flags`` - the revision flags
-``operation`` - the operation being performed (read or write)
-``raw`` - an optional argument describing if the raw transform should 
be
-applied.
-
-This method processes the flags in the order (or reverse order if
-``operation`` is 'write') defined by REVIDX_FLAGS_ORDER, applying the
-flag processors registered for present flags. The order of flags 
defined
-in REVIDX_FLAGS_ORDER needs to be stable to allow non-commutativity.
-
-Returns a 2-tuple of ``(text, validatehash)`` where ``text`` is the
-processed text and ``validatehash`` is a bool indicating whether the
-returned text should be checked for hash integrity.
-
-Note: If the ``raw`` argument is set, it has precedence over the
-operation and will only update the value of ``validatehash``.
-"""
-# fast path: no flag processors will run
-if flags == 0:
-return text, True
-if not operation in ('read', 'write'):
-raise error.ProgrammingError(_("invalid '%s' operation") %
- operation)
-# Check all flags are known.
-if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
-raise error.RevlogError(_("incompatible revision flag '%#x'") %
-(flags & ~flagutil.REVIDX_KNOWN_FLAGS))
-validatehash = True
-# Depending on the operation (read or write), the order might be
-# reversed due to non-commutative transforms.
-orderedflags = REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-
-for flag in orderedflags:
-# If a flagprocessor has been registered for a known flag, apply 
the
-# related operation transform and update result tuple.
-if flag & flags:
-vhash = True
-
-if flag not in self._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise error.RevlogError(message)
-
-processor = self._flagprocessors[flag]
-if processor is not None:
-readtransform, writetransform, rawtransform = processor
-
-if raw:
-vhash = rawtransform(self, text)
-elif operation == 'read':
-text, vhash = readtransform(self, text)
-else: # write operation
-text, vhash = writetransform(self, text)
-validatehash = validatehash and vhash
-
-return text, validatehash
-
 def checkhash(self, text, node, p1=None, p2=None, rev=None):
 """Check node hash integrity.
 
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -78,3 +78,90 @@ def insertflagprocessor(flag, processor,
 msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
 raise error.Abort(msg)
 flagprocessors[flag] = processor
+
+# Flag processors for REVIDX_ELLIPSIS.
+def ellipsisreadprocessor(rl, text):
+return text, False
+
+def ellipsiswriteprocessor(rl, text):
+return text, False
+
+def ellipsisrawprocessor(rl, text):
+return False
+
+ellipsisprocessor = (
+ellipsisreadprocessor,
+ellipsiswriteprocessor,
+ellipsisrawprocessor,
+)
+
+class flagprocessorsmixin(object):
+"""basic mixin to support revlog flag processing
+
+Make sure the 

[PATCH 9 of 9] flagutil: use it in simplestorerepo

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565223018 -7200
#  Thu Aug 08 02:10:18 2019 +0200
# Node ID 8bf3a649c932784a12ea49aeda0f3991980e8777
# Parent  9ee2ada7f37ba42787408c03074206cf0bb828de
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
8bf3a649c932
flagutil: use it in simplestorerepo

This remove the other code duplication of the `_processflags` code.

To be honest, this code looks very dead since it is not run by either developer
nor buildbot. However, we update the code to make the task of reviving this less
daunting.

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -89,7 +89,7 @@ class simplefilestoreproblem(object):
 node = attr.ib(default=None)
 
 @interfaceutil.implementer(repository.ifilestorage)
-class filestorage(object):
+class filestorage(flagutil.flagprocessorsmixin):
 """Implements storage for a tracked path.
 
 Data is stored in the VFS in a directory corresponding to the tracked
@@ -100,6 +100,8 @@ class filestorage(object):
 Fulltext data is stored in files having names of the node.
 """
 
+_flagserrorclass = simplestoreerror
+
 def __init__(self, svfs, path):
 self._svfs = svfs
 self._path = path
@@ -117,6 +119,8 @@ class filestorage(object):
 self._index = []
 self._refreshindex()
 
+self._flagprocessors = dict(flagutil.flagprocessors)
+
 def _refreshindex(self):
 self._indexbynode.clear()
 self._indexbyrev.clear()
@@ -261,45 +265,6 @@ class filestorage(object):
 
 return True
 
-def _processflags(self, text, flags, operation, raw=False):
-if flags == 0:
-return text, True
-
-if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
-raise simplestoreerror(_("incompatible revision flag '%#x'") %
-   (flags & ~flagutil.REVIDX_KNOWN_FLAGS))
-
-validatehash = True
-# Depending on the operation (read or write), the order might be
-# reversed due to non-commutative transforms.
-orderedflags = revlog.REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-
-for flag in orderedflags:
-# If a flagprocessor has been registered for a known flag, apply 
the
-# related operation transform and update result tuple.
-if flag & flags:
-vhash = True
-
-if flag not in revlog._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise simplestoreerror(message)
-
-processor = revlog._flagprocessors[flag]
-if processor is not None:
-readtransform, writetransform, rawtransform = processor
-
-if raw:
-vhash = rawtransform(self, text)
-elif operation == 'read':
-text, vhash = readtransform(self, text)
-else:  # write operation
-text, vhash = writetransform(self, text)
-validatehash = validatehash and vhash
-
-return text, validatehash
-
 def checkhash(self, text, node, p1=None, p2=None, rev=None):
 if p1 is None and p2 is None:
 p1, p2 = self.parents(node)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 7 of 9] flagutil: use the new mixin use in remotefilelog

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565219856 -7200
#  Thu Aug 08 01:17:36 2019 +0200
# Node ID 2e87598264f883b252a39664f2e2618e9de13e42
# Parent  466943d2fed3602e08ac9117afef1c727bcb98a5
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
2e87598264f8
flagutil: use the new mixin use in remotefilelog

This remove one of the code duplication. Hooray \o/.

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -25,6 +25,8 @@ from mercurial import (
 )
 from mercurial.utils import storageutil
 
+from mercurial.revlogutils import flagutil
+
 from . import (
 constants,
 fileserverclient,
@@ -45,7 +47,7 @@ class remotefilelognodemap(object):
 raise KeyError(node)
 return node
 
-class remotefilelog(object):
+class remotefilelog(flagutil.flagprocessorsmixin):
 
 _generaldelta = True
 
@@ -57,6 +59,8 @@ class remotefilelog(object):
 
 self.version = 1
 
+self._flagprocessors = dict(flagutil.flagprocessors)
+
 def read(self, node):
 """returns the file contents at this node"""
 t = self.revision(node)
@@ -324,28 +328,6 @@ class remotefilelog(object):
 text, verifyhash = self._processflags(rawtext, flags, 'read')
 return text
 
-def _processflags(self, text, flags, operation, raw=False):
-# mostly copied from hg/mercurial/revlog.py
-validatehash = True
-orderedflags = revlog.REVIDX_FLAGS_ORDER
-if operation == 'write':
-orderedflags = reversed(orderedflags)
-for flag in orderedflags:
-if flag & flags:
-vhash = True
-if flag not in revlog._flagprocessors:
-message = _("missing processor for flag '%#x'") % (flag)
-raise revlog.RevlogError(message)
-readfunc, writefunc, rawfunc = revlog._flagprocessors[flag]
-if raw:
-vhash = rawfunc(self, text)
-elif operation == 'read':
-text, vhash = readfunc(self, text)
-elif operation == 'write':
-text, vhash = writefunc(self, text)
-validatehash = validatehash and vhash
-return text, validatehash
-
 def _read(self, id):
 """reads the raw file blob from disk, cache, or server"""
 fileservice = self.repo.fileservice
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 8 of 9] flagutil: make the error class used by the mixin configurable

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565219744 -7200
#  Thu Aug 08 01:15:44 2019 +0200
# Node ID 9ee2ada7f37ba42787408c03074206cf0bb828de
# Parent  2e87598264f883b252a39664f2e2618e9de13e42
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
9ee2ada7f37b
flagutil: make the error class used by the mixin configurable

One of the code duplication use a different error class. So let's make it
possible to do so.

diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -103,6 +103,8 @@ class flagprocessorsmixin(object):
 See the documentation of the ``_processflags`` method for details.
 """
 
+_flagserrorclass = error.RevlogError
+
 def _processflags(self, text, flags, operation, raw=False):
 """Inspect revision data flags and applies transforms defined by
 registered flag processors.
@@ -133,8 +135,8 @@ class flagprocessorsmixin(object):
  operation)
 # Check all flags are known.
 if flags & ~REVIDX_KNOWN_FLAGS:
-raise error.RevlogError(_("incompatible revision flag '%#x'") %
-(flags & ~REVIDX_KNOWN_FLAGS))
+raise self._flagserrorclass(_("incompatible revision flag '%#x'") %
+(flags & ~REVIDX_KNOWN_FLAGS))
 validatehash = True
 # Depending on the operation (read or write), the order might be
 # reversed due to non-commutative transforms.
@@ -150,7 +152,7 @@ class flagprocessorsmixin(object):
 
 if flag not in self._flagprocessors:
 message = _("missing processor for flag '%#x'") % (flag)
-raise error.RevlogError(message)
+raise self._flagserrorclass(message)
 
 processor = self._flagprocessors[flag]
 if processor is not None:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 9] flagutil: move insertflagprocessor to the new module (API)

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565220337 -7200
#  Thu Aug 08 01:25:37 2019 +0200
# Node ID c446e19887223d1e7299ea6123b408564f3832d9
# Parent  c084756962a2c842af5dc0e23cc67234e4fb1d59
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
c446e1988722
flagutil: move insertflagprocessor to the new module (API)

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -150,19 +150,7 @@ def addflagprocessor(flag, processor):
   debug commands. In this case the transform only indicates whether the
   contents can be used for hash integrity checks.
 """
-_insertflagprocessor(flag, processor, flagutil.flagprocessors)
-
-def _insertflagprocessor(flag, processor, flagprocessors):
-if not flag & flagutil.REVIDX_KNOWN_FLAGS:
-msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
-raise error.ProgrammingError(msg)
-if flag not in REVIDX_FLAGS_ORDER:
-msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag)
-raise error.ProgrammingError(msg)
-if flag in flagprocessors:
-msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
-raise error.Abort(msg)
-flagprocessors[flag] = processor
+flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors)
 
 def getoffset(q):
 return int(q >> 16)
@@ -438,7 +426,7 @@ class revlog(object):
 
 # revlog v0 doesn't have flag processors
 for flag, processor in opts.get(b'flagprocessors', {}).iteritems():
-_insertflagprocessor(flag, processor, self._flagprocessors)
+flagutil.insertflagprocessor(flag, processor, self._flagprocessors)
 
 if self._chunkcachesize <= 0:
 raise error.RevlogError(_('revlog chunk cache size %r is not '
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -8,6 +8,8 @@
 
 from __future__ import absolute_import
 
+from ..i18n import _
+
 from .constants import (
 REVIDX_DEFAULT_FLAGS,
 REVIDX_ELLIPSIS,
@@ -18,6 +20,7 @@ from .constants import (
 )
 
 from .. import (
+error,
 util
 )
 
@@ -37,3 +40,14 @@ flagprocessors = {
 REVIDX_ISCENSORED: None,
 }
 
+def insertflagprocessor(flag, processor, flagprocessors):
+if not flag & REVIDX_KNOWN_FLAGS:
+msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
+raise error.ProgrammingError(msg)
+if flag not in REVIDX_FLAGS_ORDER:
+msg = _("flag '%#x' undefined in REVIDX_FLAGS_ORDER.") % (flag)
+raise error.ProgrammingError(msg)
+if flag in flagprocessors:
+msg = _("cannot register multiple processors on flag '%#x'.") % (flag)
+raise error.Abort(msg)
+flagprocessors[flag] = processor
diff --git a/tests/test-flagprocessor.t b/tests/test-flagprocessor.t
--- a/tests/test-flagprocessor.t
+++ b/tests/test-flagprocessor.t
@@ -206,8 +206,8 @@ Ensure the data got to the server OK
 File "*/tests/flagprocessorext.py", line *, in extsetup (glob)
   validatehash,
 File "*/mercurial/revlog.py", line *, in addflagprocessor (glob)
-  _insertflagprocessor(flag, processor, flagutil.flagprocessors)
-File "*/mercurial/revlog.py", line *, in _insertflagprocessor (glob)
+  flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors)
+File "*/mercurial/revlogutils/flagutil.py", line *, in insertflagprocessor 
(glob)
   raise error.Abort(msg)
   mercurial.error.Abort: b"cannot register multiple processors on flag '0x8'." 
(py3 !)
   Abort: cannot register multiple processors on flag '0x8'. (no-py3 !)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 9] flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565220514 -7200
#  Thu Aug 08 01:28:34 2019 +0200
# Node ID c084756962a2c842af5dc0e23cc67234e4fb1d59
# Parent  6e9396b0817a0e161ff340eab6aeb9c220b1d4df
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
c084756962a2
flagutil: move REVIDX_KNOWN_FLAGS source of truth in flagutil (API)

Since REVIDX_KNOWN_FLAGS is "not really a constant" (extension can update it)
and python integer,... it needs to be the responsability of a single module and
always accessed through the module. We update all the user and move the source
of truth in flagutil.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -53,7 +53,6 @@ from .revlogutils.flagutil import (
 REVIDX_EXTSTORED,
 REVIDX_FLAGS_ORDER,
 REVIDX_ISCENSORED,
-REVIDX_KNOWN_FLAGS,
 REVIDX_RAWTEXT_CHANGING_FLAGS,
 )
 from .thirdparty import (
@@ -97,7 +96,6 @@ REVIDX_ELLIPSIS
 REVIDX_EXTSTORED
 REVIDX_DEFAULT_FLAGS
 REVIDX_FLAGS_ORDER
-REVIDX_KNOWN_FLAGS
 REVIDX_RAWTEXT_CHANGING_FLAGS
 
 parsers = policy.importmod(r'parsers')
@@ -155,7 +153,7 @@ def addflagprocessor(flag, processor):
 _insertflagprocessor(flag, processor, flagutil.flagprocessors)
 
 def _insertflagprocessor(flag, processor, flagprocessors):
-if not flag & REVIDX_KNOWN_FLAGS:
+if not flag & flagutil.REVIDX_KNOWN_FLAGS:
 msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
 raise error.ProgrammingError(msg)
 if flag not in REVIDX_FLAGS_ORDER:
@@ -173,7 +171,7 @@ def gettype(q):
 return int(q & 0x)
 
 def offset_type(offset, type):
-if (type & ~REVIDX_KNOWN_FLAGS) != 0:
+if (type & ~flagutil.REVIDX_KNOWN_FLAGS) != 0:
 raise ValueError('unknown revlog index flags')
 return int(int(offset) << 16 | type)
 
@@ -685,7 +683,7 @@ class revlog(object):
 # fast path: if no "read" flag processor could change the content,
 # size is rawsize. note: ELLIPSIS is known to not change the content.
 flags = self.flags(rev)
-if flags & (REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0:
+if flags & (flagutil.REVIDX_KNOWN_FLAGS ^ REVIDX_ELLIPSIS) == 0:
 return self.rawsize(rev)
 
 return len(self.revision(rev, raw=False))
@@ -1752,9 +1750,9 @@ class revlog(object):
 raise error.ProgrammingError(_("invalid '%s' operation") %
  operation)
 # Check all flags are known.
-if flags & ~REVIDX_KNOWN_FLAGS:
+if flags & ~flagutil.REVIDX_KNOWN_FLAGS:
 raise error.RevlogError(_("incompatible revision flag '%#x'") %
-(flags & ~REVIDX_KNOWN_FLAGS))
+(flags & ~flagutil.REVIDX_KNOWN_FLAGS))
 validatehash = True
 # Depending on the operation (read or write), the order might be
 # reversed due to non-commutative transforms.
diff --git a/mercurial/revlogutils/constants.py 
b/mercurial/revlogutils/constants.py
--- a/mercurial/revlogutils/constants.py
+++ b/mercurial/revlogutils/constants.py
@@ -11,7 +11,6 @@ from __future__ import absolute_import
 
 from .. import (
 repository,
-util,
 )
 
 # revlog header flags
@@ -48,7 +47,7 @@ REVIDX_FLAGS_ORDER = [
 REVIDX_ELLIPSIS,
 REVIDX_EXTSTORED,
 ]
-REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER)
+
 # bitmark for flags that could cause rawdata content change
 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED
 
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -14,10 +14,13 @@ from .constants import (
 REVIDX_EXTSTORED,
 REVIDX_FLAGS_ORDER,
 REVIDX_ISCENSORED,
-REVIDX_KNOWN_FLAGS,
 REVIDX_RAWTEXT_CHANGING_FLAGS,
 )
 
+from .. import (
+util
+)
+
 # blanked usage of all the name to prevent pyflakes constraints
 # We need these name available in the module for extensions.
 REVIDX_ISCENSORED
@@ -25,9 +28,10 @@ REVIDX_ELLIPSIS
 REVIDX_EXTSTORED
 REVIDX_DEFAULT_FLAGS
 REVIDX_FLAGS_ORDER
-REVIDX_KNOWN_FLAGS
 REVIDX_RAWTEXT_CHANGING_FLAGS
 
+REVIDX_KNOWN_FLAGS = util.bitsfrom(REVIDX_FLAGS_ORDER)
+
 # Store flag processors (cf. 'addflagprocessor()' to register)
 flagprocessors = {
 REVIDX_ISCENSORED: None,
diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
--- a/tests/flagprocessorext.py
+++ b/tests/flagprocessorext.py
@@ -12,6 +12,9 @@ from mercurial import (
 revlog,
 util,
 )
+from mercurial.revlogutils import (
+flagutil,
+)
 
 # Test only: These flags are defined here only in the context of testing the
 # behavior of the flag processor. The canonical way to add flags is to get in
@@ -58,7 +61,7 @@ def makewrappedfile(obj):
 class 

[PATCH 2 of 9] flagutil: move the `flagprocessors` mapping in the new module

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565219088 -7200
#  Thu Aug 08 01:04:48 2019 +0200
# Node ID 6e9396b0817a0e161ff340eab6aeb9c220b1d4df
# Parent  536a1081efbe3cf9ae150af69ab10c6152e8197d
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
6e9396b0817a
flagutil: move the `flagprocessors` mapping in the new module

This module is meant to host most of the flag processing logic. We start with
the mapping between flag and processors.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -72,6 +72,7 @@ from . import (
 )
 from .revlogutils import (
 deltas as deltautil,
+flagutil,
 )
 from .utils import (
 interfaceutil,
@@ -110,11 +111,6 @@ rustdagop = policy.importrust(r'dagop')
 _maxinline = 131072
 _chunksize = 1048576
 
-# Store flag processors (cf. 'addflagprocessor()' to register)
-_flagprocessors = {
-REVIDX_ISCENSORED: None,
-}
-
 # Flag processors for REVIDX_ELLIPSIS.
 def ellipsisreadprocessor(rl, text):
 return text, False
@@ -156,7 +152,7 @@ def addflagprocessor(flag, processor):
   debug commands. In this case the transform only indicates whether the
   contents can be used for hash integrity checks.
 """
-_insertflagprocessor(flag, processor, _flagprocessors)
+_insertflagprocessor(flag, processor, flagutil.flagprocessors)
 
 def _insertflagprocessor(flag, processor, flagprocessors):
 if not flag & REVIDX_KNOWN_FLAGS:
@@ -386,7 +382,7 @@ class revlog(object):
 
 # Make copy of flag processors so each revlog instance can support
 # custom flags.
-self._flagprocessors = dict(_flagprocessors)
+self._flagprocessors = dict(flagutil.flagprocessors)
 
 # 2-tuple of file handles being used for active writing.
 self._writinghandles = None
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -28,4 +28,8 @@ REVIDX_FLAGS_ORDER
 REVIDX_KNOWN_FLAGS
 REVIDX_RAWTEXT_CHANGING_FLAGS
 
+# Store flag processors (cf. 'addflagprocessor()' to register)
+flagprocessors = {
+REVIDX_ISCENSORED: None,
+}
 
diff --git a/tests/test-flagprocessor.t b/tests/test-flagprocessor.t
--- a/tests/test-flagprocessor.t
+++ b/tests/test-flagprocessor.t
@@ -206,7 +206,7 @@ Ensure the data got to the server OK
 File "*/tests/flagprocessorext.py", line *, in extsetup (glob)
   validatehash,
 File "*/mercurial/revlog.py", line *, in addflagprocessor (glob)
-  _insertflagprocessor(flag, processor, _flagprocessors)
+  _insertflagprocessor(flag, processor, flagutil.flagprocessors)
 File "*/mercurial/revlog.py", line *, in _insertflagprocessor (glob)
   raise error.Abort(msg)
   mercurial.error.Abort: b"cannot register multiple processors on flag '0x8'." 
(py3 !)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 9] flagutil: move addflagprocessor to the new module (API)

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565222383 -7200
#  Thu Aug 08 01:59:43 2019 +0200
# Node ID 82e7f9d4d0bac574e4aa1b8f81e81ac1df3f6ddc
# Parent  c446e19887223d1e7299ea6123b408564f3832d9
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
82e7f9d4d0ba
flagutil: move addflagprocessor to the new module (API)

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -125,33 +125,6 @@ ellipsisprocessor = (
 ellipsisrawprocessor,
 )
 
-def addflagprocessor(flag, processor):
-"""Register a flag processor on a revision data flag.
-
-Invariant:
-- Flags need to be defined in REVIDX_KNOWN_FLAGS and REVIDX_FLAGS_ORDER,
-  and REVIDX_RAWTEXT_CHANGING_FLAGS if they can alter rawtext.
-- Only one flag processor can be registered on a specific flag.
-- flagprocessors must be 3-tuples of functions (read, write, raw) with the
-  following signatures:
-  - (read)  f(self, rawtext) -> text, bool
-  - (write) f(self, text) -> rawtext, bool
-  - (raw)   f(self, rawtext) -> bool
-  "text" is presented to the user. "rawtext" is stored in revlog data, not
-  directly visible to the user.
-  The boolean returned by these transforms is used to determine whether
-  the returned text can be used for hash integrity checking. For example,
-  if "write" returns False, then "text" is used to generate hash. If
-  "write" returns True, that basically means "rawtext" returned by "write"
-  should be used to generate hash. Usually, "write" and "read" return
-  different booleans. And "raw" returns a same boolean as "write".
-
-  Note: The 'raw' transform is used for changegroup generation and in some
-  debug commands. In this case the transform only indicates whether the
-  contents can be used for hash integrity checks.
-"""
-flagutil.insertflagprocessor(flag, processor, flagutil.flagprocessors)
-
 def getoffset(q):
 return int(q >> 16)
 
@@ -2599,7 +2572,7 @@ class revlog(object):
 #
 # L1 should be equal to L2. L3 could be different from them.
 # "text" may or may not affect commit hash depending on flag
-# processors (see revlog.addflagprocessor).
+# processors (see flagutil.addflagprocessor).
 #
 #  | common  | rename | meta  | ext
 # -
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
--- a/mercurial/revlogutils/flagutil.py
+++ b/mercurial/revlogutils/flagutil.py
@@ -40,6 +40,33 @@ flagprocessors = {
 REVIDX_ISCENSORED: None,
 }
 
+def addflagprocessor(flag, processor):
+"""Register a flag processor on a revision data flag.
+
+Invariant:
+- Flags need to be defined in REVIDX_KNOWN_FLAGS and REVIDX_FLAGS_ORDER,
+  and REVIDX_RAWTEXT_CHANGING_FLAGS if they can alter rawtext.
+- Only one flag processor can be registered on a specific flag.
+- flagprocessors must be 3-tuples of functions (read, write, raw) with the
+  following signatures:
+  - (read)  f(self, rawtext) -> text, bool
+  - (write) f(self, text) -> rawtext, bool
+  - (raw)   f(self, rawtext) -> bool
+  "text" is presented to the user. "rawtext" is stored in revlog data, not
+  directly visible to the user.
+  The boolean returned by these transforms is used to determine whether
+  the returned text can be used for hash integrity checking. For example,
+  if "write" returns False, then "text" is used to generate hash. If
+  "write" returns True, that basically means "rawtext" returned by "write"
+  should be used to generate hash. Usually, "write" and "read" return
+  different booleans. And "raw" returns a same boolean as "write".
+
+  Note: The 'raw' transform is used for changegroup generation and in some
+  debug commands. In this case the transform only indicates whether the
+  contents can be used for hash integrity checks.
+"""
+insertflagprocessor(flag, processor, flagprocessors)
+
 def insertflagprocessor(flag, processor, flagprocessors):
 if not flag & REVIDX_KNOWN_FLAGS:
 msg = _("cannot register processor on unknown flag '%#x'.") % (flag)
diff --git a/tests/flagprocessorext.py b/tests/flagprocessorext.py
--- a/tests/flagprocessorext.py
+++ b/tests/flagprocessorext.py
@@ -113,7 +113,7 @@ def extsetup(ui):
 exchange._bundlespeccontentopts[k][b"cg.version"] = b"03"
 
 # Register flag processors for each extension
-revlog.addflagprocessor(
+flagutil.addflagprocessor(
 REVIDX_NOOP,
 (
 noopdonothing,
@@ -121,7 +121,7 @@ def extsetup(ui):
 validatehash,
 )
 )
-revlog.addflagprocessor(
+

[PATCH 1 of 9] flagutil: create a `mercurial.revlogutils.flagutil` module

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565218981 -7200
#  Thu Aug 08 01:03:01 2019 +0200
# Node ID 536a1081efbe3cf9ae150af69ab10c6152e8197d
# Parent  11498aa91c036c6d70f7ac5ee5af2664a84a1130
# EXP-Topic flag-processors
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
536a1081efbe
flagutil: create a `mercurial.revlogutils.flagutil` module

The flagprocessings logic is duplicated in 2 extra places, and usually in a less
robust flavor. This is a maintenance nightmare that I would like to see cleaned
up. To do so I am creating a `flagutil` module to move flag processings related
code and make it easily reusable by other code.

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -31,6 +31,7 @@ allowsymbolimports = (
 'mercurial.node',
 # for revlog to re-export constant to extensions
 'mercurial.revlogutils.constants',
+'mercurial.revlogutils.flagutil',
 # for cffi modules to re-export pure functions
 'mercurial.pure.base85',
 'mercurial.pure.bdiff',
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -38,13 +38,6 @@ from .i18n import _
 from .revlogutils.constants import (
 FLAG_GENERALDELTA,
 FLAG_INLINE_DATA,
-REVIDX_DEFAULT_FLAGS,
-REVIDX_ELLIPSIS,
-REVIDX_EXTSTORED,
-REVIDX_FLAGS_ORDER,
-REVIDX_ISCENSORED,
-REVIDX_KNOWN_FLAGS,
-REVIDX_RAWTEXT_CHANGING_FLAGS,
 REVLOGV0,
 REVLOGV1,
 REVLOGV1_FLAGS,
@@ -54,6 +47,15 @@ from .revlogutils.constants import (
 REVLOG_DEFAULT_FORMAT,
 REVLOG_DEFAULT_VERSION,
 )
+from .revlogutils.flagutil import (
+REVIDX_DEFAULT_FLAGS,
+REVIDX_ELLIPSIS,
+REVIDX_EXTSTORED,
+REVIDX_FLAGS_ORDER,
+REVIDX_ISCENSORED,
+REVIDX_KNOWN_FLAGS,
+REVIDX_RAWTEXT_CHANGING_FLAGS,
+)
 from .thirdparty import (
 attr,
 )
diff --git a/mercurial/revlogutils/flagutil.py 
b/mercurial/revlogutils/flagutil.py
new file mode 100644
--- /dev/null
+++ b/mercurial/revlogutils/flagutil.py
@@ -0,0 +1,31 @@
+# flagutils.py - code to deal with revlog flags and their processors
+#
+# Copyright 2016 Remi Chaintron 
+# Copyright 2016-2019 Pierre-Yves David 
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+from __future__ import absolute_import
+
+from .constants import (
+REVIDX_DEFAULT_FLAGS,
+REVIDX_ELLIPSIS,
+REVIDX_EXTSTORED,
+REVIDX_FLAGS_ORDER,
+REVIDX_ISCENSORED,
+REVIDX_KNOWN_FLAGS,
+REVIDX_RAWTEXT_CHANGING_FLAGS,
+)
+
+# blanked usage of all the name to prevent pyflakes constraints
+# We need these name available in the module for extensions.
+REVIDX_ISCENSORED
+REVIDX_ELLIPSIS
+REVIDX_EXTSTORED
+REVIDX_DEFAULT_FLAGS
+REVIDX_FLAGS_ORDER
+REVIDX_KNOWN_FLAGS
+REVIDX_RAWTEXT_CHANGING_FLAGS
+
+
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6712: config: remove pycompat.bytestr() for defaultvalue

2019-08-07 Thread yuja (Yuya Nishihara)
yuja added a comment.


  > The `pycompat.bytestr()` was there for py3 compatibility,
  
  Not really for the "value" variable which may be unprintable object, but
  I think it's okay to assume defaultvalues are None/bool/int/float/bytes type.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

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


Re: D6712: config: fix defaultvalue template keyword (patch 1 of 2)

2019-08-07 Thread Yuya Nishihara
> The `pycompat.bytestr()` was there for py3 compatibility,

Not really for the "value" variable which may be unprintable object, but
I think it's okay to assume defaultvalues are None/bool/int/float/bytes type.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 V3] copies: extract an explicit `computechangesetfilesremoved` method from context

2019-08-07 Thread Yuya Nishihara
On Wed, 07 Aug 2019 15:46:50 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1560343372 -3600
> #  Wed Jun 12 13:42:52 2019 +0100
> # Node ID 49740823dab3e2673ece70974080a274f2b8cf94
> # Parent  791b66f0c3e2f67dd7cb093cf58d662f63e4273f
> # EXP-Topic extrameta
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 49740823dab3
> copies: extract an explicit `computechangesetfilesremoved` method from context

Queued with s/copies:/changectx:/, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6697: cmdutil: add allowunfinished to prevent checkunfinished() on docommit()

2019-08-07 Thread pulkit (Pulkit Goyal)
This revision now requires changes to proceed.
pulkit added a comment.
pulkit requested changes to this revision.


  The test still fails.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6697/new/

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

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


D6717: mypy: add a mypy.ini config file

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  I am +1 on this. If I don't hear any objection on it until next week, I will 
queue it. Thanks for doing this work!

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6717/new/

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

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


D6699: tests: add test for unshelve --interactive --keep

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  You are already working on improving things with `--keep` and 
`--interactive`, so let's have this patch as a part of that patch.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6699/new/

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

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


D6659: graft: split graft code into seperate functions

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> cmdutil.py:3431
> +"""logic to execute graft once revs are generated"""
> +graftstate = statemod.cmdstate(repo, 'graftstate')
> +for pos, ctx in enumerate(repo.set("%ld", revs)):

let's initialize `graftstate` only where we need it.

> cmdutil.py:3495
> +
> +def continuegraftstate(repo, graftstate, opts):
> +"""updates opts based on the interrupted graftstate once

the function name is not correct with respect to what it does, maybe something 
like `getopts` or something. Also, we no longer update the `opts`, so we can 
drop that as argument and also need to update the function description.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6659/new/

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

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


D6678: continue: added support for histedit

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> histedit.py:1842
>  
> +def hgcontinuehistedit(ui, repo):
> +state = histeditstate(repo)

I see that we can have a unified function, `resumehistedit(..)` which can be 
called from `_histedit()` too.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6678/new/

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

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


D6689: continue: added support for transplant

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> transplant.py:743
> +tp = transplanter(ui, repo, opts)
> +tp.resume(repo, repo, opts)
> +return

I don't see `transplanter` modifying opts. So we can directly pass empty dict 
in both of the above function.

> transplant.py:744
> +tp.resume(repo, repo, opts)
> +return
> +

`return tp.resume(..)` will be better here

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6689/new/

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

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


[PATCH 08 of 10] rawdata: implement the method for `remotefilelog` too

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565203912 -7200
#  Wed Aug 07 20:51:52 2019 +0200
# Node ID cfad2ef930798575f52a6a20313b0b57a5b16e1f
# Parent  614e6f874408568cda406299e714b0d711e970be
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
cfad2ef93079
rawdata: implement the method for `remotefilelog` too

This is needed for all storage implementations.

diff --git a/hgext/remotefilelog/remotefilelog.py 
b/hgext/remotefilelog/remotefilelog.py
--- a/hgext/remotefilelog/remotefilelog.py
+++ b/hgext/remotefilelog/remotefilelog.py
@@ -324,6 +324,9 @@ class remotefilelog(object):
 text, verifyhash = self._processflags(rawtext, flags, 'read')
 return text
 
+def rawdata(self, node):
+return self.revision(node, raw=False)
+
 def _processflags(self, text, flags, operation, raw=False):
 # mostly copied from hg/mercurial/revlog.py
 validatehash = True
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 10 of 10] rawdata: register the method for `ifiledata`

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565208169 -7200
#  Wed Aug 07 22:02:49 2019 +0200
# Node ID 798e48124c8f0297f0eeab0277c58f38f88b9284
# Parent  9c998f6ff099877a0e53722a1c35a8e059cb17ee
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
798e48124c8f
rawdata: register the method for `ifiledata`

The interface have a `revision(..., raw=False)` method so it should get a
`rawdata` one. I am not sure why nothing complained about the lack of it
earlier.

diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -597,6 +597,10 @@ class ifiledata(interfaceutil.Interface)
 consumers should use ``read()`` to obtain the actual file data.
 """
 
+def rawdata(node):
+"""Obtain raw data for a node.
+"""
+
 def read(node):
 """Resolve file fulltext data.
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 07 of 10] rawdata: implement `rawdata` for `simplestore` too

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565203685 -7200
#  Wed Aug 07 20:48:05 2019 +0200
# Node ID 614e6f874408568cda406299e714b0d711e970be
# Parent  61aefd21e509dac932964c332744f42e7d619546
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
614e6f874408
rawdata: implement `rawdata` for `simplestore` too

This is needed for all implementation.

diff --git a/tests/simplestorerepo.py b/tests/simplestorerepo.py
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -326,6 +326,9 @@ class filestorage(object):
 
 return text
 
+def rawdata(self, nodeorrev):
+return self.revision(raw=True)
+
 def read(self, node):
 validatenode(node)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 09 of 10] rawdata: implement the method for `unionrepo` too

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565205468 -7200
#  Wed Aug 07 21:17:48 2019 +0200
# Node ID 9c998f6ff099877a0e53722a1c35a8e059cb17ee
# Parent  cfad2ef930798575f52a6a20313b0b57a5b16e1f
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
9c998f6ff099
rawdata: implement the method for `unionrepo` too

This is required for all implementations.

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -116,6 +116,9 @@ class unionrevlog(revlog.revlog):
 # already cached
 return text
 
+def rawdata(self, nodeorrev, _df=None):
+return self.revision(nodeorrev, _df=_df, raw=True)
+
 def baserevision(self, nodeorrev):
 # Revlog subclasses may override 'revision' method to modify format of
 # content retrieved from revlog. To use unionrevlog with such class one
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 06 of 10] rawdata: forward `rawdata` call on `manifestlog`

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565208484 -7200
#  Wed Aug 07 22:08:04 2019 +0200
# Node ID 61aefd21e509dac932964c332744f42e7d619546
# Parent  07298d6c4c98ee1f59ab1aa563226e8d1f91dbcf
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
61aefd21e509
rawdata: forward `rawdata` call on `manifestlog`

This needs to be sent to the underlying `revlog` too.

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1620,6 +1620,9 @@ class manifestrevlog(object):
 def revision(self, node, _df=None, raw=False):
 return self._revlog.revision(node, _df=_df, raw=raw)
 
+def rawdata(self, node, _df=None):
+return self._revlog.rawdata(node, _df=_df)
+
 def revdiff(self, rev1, rev2):
 return self._revlog.revdiff(rev1, rev2)
 
diff --git a/mercurial/repository.py b/mercurial/repository.py
--- a/mercurial/repository.py
+++ b/mercurial/repository.py
@@ -1164,6 +1164,9 @@ class imanifeststorage(interfaceutil.Int
 def revision(node, _df=None, raw=False):
 """Obtain fulltext data for a node."""
 
+def rawdata(node, _df=None):
+"""Obtain raw data for a node."""
+
 def revdiff(rev1, rev2):
 """Obtain a delta between two revision numbers.
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 03 of 10] rawdata: forward the method call on `filelog` object

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565207960 -7200
#  Wed Aug 07 21:59:20 2019 +0200
# Node ID 948b50c3f67ae6a7812823ead71760ef88647f7e
# Parent  fe5517914e9f519855d5f8c0ef89098e039d68c6
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
948b50c3f67a
rawdata: forward the method call on `filelog` object

We have a new method, we need to expose it.

diff --git a/mercurial/filelog.py b/mercurial/filelog.py
--- a/mercurial/filelog.py
+++ b/mercurial/filelog.py
@@ -90,6 +90,9 @@ class filelog(object):
 def revision(self, node, _df=None, raw=False):
 return self._revlog.revision(node, _df=_df, raw=raw)
 
+def rawdata(self, node, _df=None):
+return self._revlog.rawdata(node, _df=_df)
+
 def emitrevisions(self, nodes, nodesorder=None,
   revisiondata=False, assumehaveparentrevisions=False,
   deltamode=repository.CG_DELTAMODE_STD):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 10] rawdata: implement `rawdata` for `sqlitestore` too

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565208112 -7200
#  Wed Aug 07 22:01:52 2019 +0200
# Node ID 07298d6c4c98ee1f59ab1aa563226e8d1f91dbcf
# Parent  b358cc7a35d219848f1366c29610eb46beb91225
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
07298d6c4c98
rawdata: implement `rawdata` for `sqlitestore` too

This is a different store, it needs it declared.

diff --git a/hgext/sqlitestore.py b/hgext/sqlitestore.py
--- a/hgext/sqlitestore.py
+++ b/hgext/sqlitestore.py
@@ -549,6 +549,9 @@ class sqlitefilestore(object):
 
 return fulltext
 
+def rawdata(self, *args, **kwargs):
+return self.revision(*args, **kwargs)
+
 def read(self, node):
 return storageutil.filtermetadata(self.revision(node))
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 02 of 10] rawdata: introduce a `rawdata` method on revlog

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565207669 -7200
#  Wed Aug 07 21:54:29 2019 +0200
# Node ID fe5517914e9f519855d5f8c0ef89098e039d68c6
# Parent  3b49bb04851ea501f005e7a58403fee3b1c52958
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
fe5517914e9f
rawdata: introduce a `rawdata` method on revlog

This method aims at replacing `revision(..., raw=True)` call. The purpose of
data returned without and without raw are different enough that having two
different method would make sense.

This split is motivated by other work aiming at storing data on the side of the
main revision of a revlog. Having a cleaner API makes it simpler to add this
work.

The series following this first changesets is organised as follow:
1) add `rawdata` method everywhere it is useful
2) update all caller
3) implement all `rawdata` method without using `revision`
4) deprecate the `rawdata` parameter of `revision`

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1720,6 +1720,13 @@ class revlog(object):
 
 return text
 
+def rawdata(self, nodeorrev, _df=None, raw=False):
+"""return an uncompressed raw data of a given node or revision number.
+
+_df - an existing file handle to read from. (internal-only)
+"""
+return self._revisiondata(nodeorrev, _df, raw=True)
+
 def hash(self, text, p1, p2):
 """Compute a node hash.
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 04 of 10] rawdata: add the method to bundlerevlog

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565208057 -7200
#  Wed Aug 07 22:00:57 2019 +0200
# Node ID b358cc7a35d219848f1366c29610eb46beb91225
# Parent  948b50c3f67ae6a7812823ead71760ef88647f7e
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
b358cc7a35d2
rawdata: add the method to bundlerevlog

The bundlerepo logic has its own `revision` method on its own `revlog` object.
We need to "implement" `rawdata` there too.

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -146,6 +146,9 @@ class bundlerevlog(revlog.revlog):
 self._revisioncache = (node, rev, rawtext)
 return text
 
+def rawdata(self, nodeorrev, _df=None):
+return self.revision(nodeorrev, _df=_df, raw=True)
+
 def baserevision(self, nodeorrev):
 # Revlog subclasses may override 'revision' method to modify format of
 # content retrieved from revlog. To use bundlerevlog with such class 
one
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 01 of 10] revlog: split a `_revisiondata` method to file `revision` job

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565190888 -7200
#  Wed Aug 07 17:14:48 2019 +0200
# Node ID 3b49bb04851ea501f005e7a58403fee3b1c52958
# Parent  4710384df490f426ba53055537b16030dc61d957
# EXP-Topic rawdata
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
3b49bb04851e
revlog: split a `_revisiondata` method to file `revision` job

We are about to introduce more public method to access revision data (eg:
`rawdata`). revset subclass tend to recursively call `revision` which will
create all kind of issue with the coming series. To avoid them we introduce an
explicit difference between the internal call and the public all. This will be
useful for later work anyway (so the subclass issue is just moving it earlier in
the series). I am not sure if the subclass are actually doing something
sensible. However, I am certain I don't want to be rabbit holed into figuring it
out right now.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1651,6 +1651,9 @@ class revlog(object):
 treated as raw data when applying flag transforms. 'raw' should be set
 to True when generating changegroups or in debug commands.
 """
+return self._revisiondata(nodeorrev, _df, raw=raw)
+
+def _revisiondata(self, nodeorrev, _df=None, raw=False):
 if isinstance(nodeorrev, int):
 rev = nodeorrev
 node = self.node(rev)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6712: config: remove pycompat.bytestr() for defaultvalue

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
Closed by commit rHG049b2ac3252e: config: remove pycompat.bytestr() for 
defaultvalue (authored by navaneeth.suresh).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6712?vs=16148=16151

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -70,7 +70,7 @@
   $ hg showconfig Section.KeY -Tjson
   [
{
-"defaultvalue": "None",
+"defaultvalue": null,
 "name": "Section.KeY",
 "source": "*.hgrc:*", (glob)
 "value": "Case Sensitive"
@@ -103,7 +103,7 @@
   $ hg config empty.source -Tjson
   [
{
-"defaultvalue": "None",
+"defaultvalue": null,
 "name": "empty.source",
 "source": "",
 "value": "value"
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1872,7 +1872,7 @@
 for section, name, value in ui.walkconfig(untrusted=untrusted):
 source = ui.configsource(section, name, untrusted)
 value = pycompat.bytestr(value)
-defaultvalue = pycompat.bytestr(ui.configdefault(section, name))
+defaultvalue = ui.configdefault(section, name)
 if fm.isplain():
 source = source or 'none'
 value = value.replace('\n', '\\n')



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


D6720: config: fix fm.data() handling of defaultvalue

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
Closed by commit rHG60789444acd6: config: fix fm.data() handling of 
defaultvalue (authored by navaneeth.suresh).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6720?vs=16150=16152

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6720/new/

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -57,11 +57,13 @@
   $ hg showconfig Section -Tjson
   [
{
+"defaultvalue": null,
 "name": "Section.KeY",
 "source": "*.hgrc:*", (glob)
 "value": "Case Sensitive"
},
{
+"defaultvalue": null,
 "name": "Section.key",
 "source": "*.hgrc:*", (glob)
 "value": "lower case"
@@ -77,8 +79,8 @@
}
   ]
   $ hg showconfig -Tjson | tail -7
-   },
{
+"defaultvalue": null,
 "name": "*", (glob)
 "source": "*", (glob)
 "value": "*" (glob)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1882,10 +1882,11 @@
 fm.startitem()
 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
 if uniquesel:
-fm.data(name=entryname, defaultvalue=defaultvalue)
+fm.data(name=entryname)
 fm.write('value', '%s\n', value)
 else:
 fm.write('name value', '%s=%s\n', entryname, value)
+fm.data(defaultvalue=defaultvalue)
 matched = True
 fm.end()
 if matched:



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


D6696: abort: added support for transplant

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> transplant.py:779
> +tp = transplanter(ui, repo, {})
> +tp.abort(ui, repo)
> +return

`return tp.abort(..)` instead.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6696/new/

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

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


D6695: transplant: added support for --abort flag

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> transplant.py:416
>  
> +def clear(self):
> +"""clear the state file if it exists"""

We already have `self.unlog` doing the same here.

> transplant.py:421
> +
> +def abort(self, ui ,repo):
> +"""logic to abort an interrupted transplant"""

the `,` after ui is misplaced a bit

> transplant.py:705
> +raise error.Abort(_('no transplant to abort'))
> +tp.abort(ui, repo)
> +return

`return tp.abort(...)` here

> transplant.py:801
>  continuefunc=continuetransplant,
>  statushint=_('To continue:hg transplant --continue\n'
> + 'To abort:   hg transplant --abort'),

IIUC, we don't need to manually pass statushint and cmdhint now.

> test-transplant.t:466
> +  working directory is now at e8643552fde5
> +Repo log after abort
> +  $ hg glog

A better candidate here will be to show `hg status -v` as that will show 
whether there is an unfinished transplant or not.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6695/new/

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

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


D6712: config: remove pycompat.bytestr() for defaultvalue

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  In D6712#98424 , @pulkit wrote:
  
  > The `pycompat.bytestr()` was there for py3 compatibility, however removing 
it should be fine in this case. Can you make sure `test-config.t` passes with 
this patch on Python 3?
  
  Yes, `test-config.t` passes with this patch on py3.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

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


D6720: config: fix fm.data() handling of defaultvalue

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh updated this revision to Diff 16150.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6720?vs=16149=16150

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6720/new/

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -57,11 +57,13 @@
   $ hg showconfig Section -Tjson
   [
{
+"defaultvalue": null,
 "name": "Section.KeY",
 "source": "*.hgrc:*", (glob)
 "value": "Case Sensitive"
},
{
+"defaultvalue": null,
 "name": "Section.key",
 "source": "*.hgrc:*", (glob)
 "value": "lower case"
@@ -77,8 +79,8 @@
}
   ]
   $ hg showconfig -Tjson | tail -7
-   },
{
+"defaultvalue": null,
 "name": "*", (glob)
 "source": "*", (glob)
 "value": "*" (glob)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1882,10 +1882,11 @@
 fm.startitem()
 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
 if uniquesel:
-fm.data(name=entryname, defaultvalue=defaultvalue)
+fm.data(name=entryname)
 fm.write('value', '%s\n', value)
 else:
 fm.write('name value', '%s=%s\n', entryname, value)
+fm.data(defaultvalue=defaultvalue)
 matched = True
 fm.end()
 if matched:



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


D6720: config: fix fm.data() handling of defaultvalue

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> navaneeth.suresh wrote in commands.py:1884
> I did this but, couldn't see a difference in the test output.

ah, I guess the output is sorted. Anyway, the suggested one is a correct way to 
do this, because otherwise we are writing name to fm two times in case of 
`uniquesel`.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6720/new/

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

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


D6720: config: fix fm.data() handling of defaultvalue

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added inline comments.

INLINE COMMENTS

> pulkit wrote in commands.py:1884
> A better fix will be to move `fm.data(name=entryname)` inside the if, i.e. 
> where it was before https://phab.mercurial-scm.org/D6704.
> 
> And add `fm.data(defaultvalue=...)` below the if-else which will also move 
> the `defaultvalue` to last in json output.

I did this but, couldn't see a difference in the test output.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6720/new/

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

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


[PATCH 2 of 3 V2] upgrade: add an argument to control changelog upgrade

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1564500316 -7200
#  Tue Jul 30 17:25:16 2019 +0200
# Node ID acf1937e39ba1db0ab81a14bc0c0082c93df838b
# Parent  8a77cda93b1a7252482a4ca4e420b76936c9ae27
# EXP-Topic upgrade-select
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
acf1937e39ba
upgrade: add an argument to control changelog upgrade

Same as for `--manifest` we can now select more selection.

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2848,6 +2848,7 @@ def debugupdatecaches(ui, repo, *pats, *
 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
 ('', 'run', False, _('performs an upgrade')),
 ('', 'backup', True, _('keep the old repository content around')),
+('', 'changelog', None, _('select the changelog for upgrade')),
 ('', 'manifest', None, _('select the manifest for upgrade')),
 ])
 def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True, **opts):
@@ -2874,6 +2875,8 @@ def debugupgraderepo(ui, repo, run=False
 
   * `--manifest`: only optimize the manifest
   * `--no-manifest`: optimize all revlog but the manifest
+  * `--changelog`: optimize the changelog only
+  * `--no-changelog --no-manifest`: optimize filelogs only
 """
 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize,
backup=backup, **opts)
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -865,7 +865,7 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
 return backuppath
 
 def upgraderepo(ui, repo, run=False, optimize=None, backup=True,
-manifest=None):
+manifest=None, changelog=None):
 """Upgrade a repository in place."""
 if optimize is None:
 optimize = []
@@ -873,7 +873,7 @@ def upgraderepo(ui, repo, run=False, opt
 repo = repo.unfiltered()
 
 revlogs = set(UPGRADE_ALL_REVLOGS)
-specentries = (('m', manifest),)
+specentries = (('c', changelog), ('m', manifest))
 specified = [(y, x) for (y, x) in specentries if x is not None]
 if specified:
 # we have some limitation on revlogs to be recloned
@@ -881,15 +881,18 @@ def upgraderepo(ui, repo, run=False, opt
 revlogs = set()
 for r, enabled in specified:
 if enabled:
-if r == 'm':
+if r == 'c':
+revlogs.add(UPGRADE_CHANGELOG)
+elif r == 'm':
 revlogs.add(UPGRADE_MANIFEST)
 else:
 # none are enabled
 for r, __ in specified:
-if r == 'm':
+if r == 'c':
+revlogs.discard(UPGRADE_CHANGELOG)
+elif r == 'm':
 revlogs.discard(UPGRADE_MANIFEST)
 
-
 # Ensure the repository can be upgraded.
 missingreqs = requiredsourcerequirements(repo) - repo.requirements
 if missingreqs:
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -312,7 +312,7 @@ Show all commands + options
   debuguigetpass: prompt
   debuguiprompt: prompt
   debugupdatecaches: 
-  debugupgraderepo: optimize, run, backup, manifest
+  debugupgraderepo: optimize, run, backup, changelog, manifest
   debugwalk: include, exclude
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -636,6 +636,98 @@ Check we can select negatively
   checking files
   checked 3 changesets with 3 changes to 3 files
 
+Check that we can select changelog only
+
+  $ hg debugupgrade --optimize re-delta-parent --run --changelog --no-backup 
--debug --traceback
+  upgrade will perform the following actions:
+  
+  requirements
+ preserved: dotencode, fncache, generaldelta, revlogv1, sparserevlog, store
+  
+  re-delta-parent
+ deltas within internal storage will choose a new base revision if needed
+  
+  beginning upgrade...
+  repository locked and read-only
+  creating temporary repository to stage migrated data: 
$TESTTMP/upgradegd/.hg/upgrade.* (glob)
+  (it is safe to interrupt this process any time before data migration 
completes)
+  migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
+  migrating 917 bytes in store; 401 bytes tracked data
+  migrating 3 filelogs containing 3 revisions (192 bytes in store; 0 bytes 
tracked data)
+  blindly copying data/f0.i containing 1 revisions
+  blindly copying data/f1.i containing 1 revisions
+  blindly copying data/f2.i containing 1 revisions
+  finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 

[PATCH 1 of 3 V2] upgrade: add an argument to control manifest upgrade

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1564439752 -7200
#  Tue Jul 30 00:35:52 2019 +0200
# Node ID 8a77cda93b1a7252482a4ca4e420b76936c9ae27
# Parent  0812d9fb63fe1f417a1bdec3bc292dd953a5fc62
# EXP-Topic upgrade-select
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
8a77cda93b1a
upgrade: add an argument to control manifest upgrade

The argument can be used to only "clone" manifest revlog or clone all of them
but this one. The selection will make more sense once we have a `--changelog`
flag in the next changesets.

diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -2848,8 +2848,9 @@ def debugupdatecaches(ui, repo, *pats, *
 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
 ('', 'run', False, _('performs an upgrade')),
 ('', 'backup', True, _('keep the old repository content around')),
+('', 'manifest', None, _('select the manifest for upgrade')),
 ])
-def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True):
+def debugupgraderepo(ui, repo, run=False, optimize=None, backup=True, **opts):
 """upgrade a repository to use different features
 
 If no arguments are specified, the repository is evaluated for upgrade
@@ -2867,9 +2868,15 @@ def debugupgraderepo(ui, repo, run=False
 rename some directories inside the ``.hg`` directory. On most machines, 
this
 should complete almost instantaneously and the chances of a consumer being
 unable to access the repository should be low.
+
+By default, all revlog will be upgraded. You can restrict this using flag
+such as `--manifest`:
+
+  * `--manifest`: only optimize the manifest
+  * `--no-manifest`: optimize all revlog but the manifest
 """
 return upgrade.upgraderepo(ui, repo, run=run, optimize=optimize,
-   backup=backup)
+   backup=backup, **opts)
 
 @command('debugwalk', cmdutil.walkopts, _('[OPTION]... [FILE]...'),
  inferrepo=True)
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -864,13 +864,32 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
 
 return backuppath
 
-def upgraderepo(ui, repo, run=False, optimize=None, backup=True):
+def upgraderepo(ui, repo, run=False, optimize=None, backup=True,
+manifest=None):
 """Upgrade a repository in place."""
 if optimize is None:
 optimize = []
 optimize = set(legacy_opts_map.get(o, o) for o in optimize)
 repo = repo.unfiltered()
 
+revlogs = set(UPGRADE_ALL_REVLOGS)
+specentries = (('m', manifest),)
+specified = [(y, x) for (y, x) in specentries if x is not None]
+if specified:
+# we have some limitation on revlogs to be recloned
+if any(x for y, x in specified):
+revlogs = set()
+for r, enabled in specified:
+if enabled:
+if r == 'm':
+revlogs.add(UPGRADE_MANIFEST)
+else:
+# none are enabled
+for r, __ in specified:
+if r == 'm':
+revlogs.discard(UPGRADE_MANIFEST)
+
+
 # Ensure the repository can be upgraded.
 missingreqs = requiredsourcerequirements(repo) - repo.requirements
 if missingreqs:
@@ -1020,7 +1039,7 @@ def upgraderepo(ui, repo, run=False, opt
 
 with dstrepo.wlock(), dstrepo.lock():
 backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
-  upgradeactions)
+  upgradeactions, revlogs=revlogs)
 if not (backup or backuppath is None):
 ui.write(_('removing old repository content%s\n') % backuppath)
 repo.vfs.rmtree(backuppath, forcibly=True)
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -312,7 +312,7 @@ Show all commands + options
   debuguigetpass: prompt
   debuguiprompt: prompt
   debugupdatecaches: 
-  debugupgraderepo: optimize, run, backup
+  debugupgraderepo: optimize, run, backup, manifest
   debugwalk: include, exclude
   debugwhyunstable: 
   debugwireargs: three, four, five, ssh, remotecmd, insecure
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -518,9 +518,126 @@ unless --no-backup is passed
   removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
   $ ls -1 .hg/ | grep upgradebackup
   [1]
+
+We can restrict optimization to some revlog:
+
+  $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup 
--debug --traceback
+  upgrade will perform the following actions:
+  
+  requirements
+ preserved: dotencode, 

[PATCH 3 of 3 V2] upgrade: make sure we reclone all revlogs when updating to some format

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565018724 -7200
#  Mon Aug 05 17:25:24 2019 +0200
# Node ID e585aec755459c4169c2db87b8ffbd523be19f87
# Parent  acf1937e39ba1db0ab81a14bc0c0082c93df838b
# EXP-Topic upgrade-select
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
e585aec75545
upgrade: make sure we reclone all revlogs when updating to some format

Adding or removing some requirement (eg: sparserevlog), requires to reclone
revlog to use the new format. We cannot simply copy the original files.

In this case we issue a warning a proceed with clone every revlogs.

diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -28,6 +28,12 @@ from .utils import (
 compression,
 )
 
+# list of requirements that request a clone of all revlog if added/removed
+RECLONES_REQUIREMENTS = set([
+'generaldelta',
+localrepo.SPARSEREVLOG_REQUIREMENT,
+])
+
 def requiredsourcerequirements(repo):
 """Obtain requirements required to be present to upgrade a repo.
 
@@ -952,6 +958,17 @@ def upgraderepo(ui, repo, run=False, opt
# determineactions could have added optimisation
if o not in actions)
 
+removedreqs = repo.requirements - newreqs
+addedreqs = newreqs - repo.requirements
+
+if revlogs != UPGRADE_ALL_REVLOGS:
+incompatible = RECLONES_REQUIREMENTS & (removedreqs | addedreqs)
+if incompatible:
+msg = _('ignoring revlogs selection flags, format requirement '
+'change: %s')
+ui.warn(msg % ', '.join(sorted(incompatible)))
+revlogs = UPGRADE_ALL_REVLOGS
+
 def printrequirements():
 ui.write(_('requirements\n'))
 ui.write(_('   preserved: %s\n') %
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -728,6 +728,107 @@ Check that we can select filelog only
   checking files
   checked 3 changesets with 3 changes to 3 files
 
+
+Check you can't skip revlog clone during important format downgrade
+
+  $ echo "[format]" > .hg/hgrc
+  $ echo "sparse-revlog=no" >> .hg/hgrc
+  $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup 
--debug --traceback
+  ignoring revlogs selection flags, format requirement change: 
sparserevlogupgrade will perform the following actions:
+  
+  requirements
+ preserved: dotencode, fncache, generaldelta, revlogv1, store
+ removed: sparserevlog
+  
+  re-delta-parent
+ deltas within internal storage will choose a new base revision if needed
+  
+  beginning upgrade...
+  repository locked and read-only
+  creating temporary repository to stage migrated data: 
$TESTTMP/upgradegd/.hg/upgrade.* (glob)
+  (it is safe to interrupt this process any time before data migration 
completes)
+  migrating 9 total revisions (3 in filelogs, 3 in manifests, 3 in changelog)
+  migrating 917 bytes in store; 401 bytes tracked data
+  migrating 3 filelogs containing 3 revisions (192 bytes in store; 0 bytes 
tracked data)
+  cloning 1 revisions from data/f0.i
+  cloning 1 revisions from data/f1.i
+  cloning 1 revisions from data/f2.i
+  finished migrating 3 filelog revisions across 3 filelogs; change in size: 0 
bytes
+  migrating 1 manifests containing 3 revisions (349 bytes in store; 220 bytes 
tracked data)
+  cloning 3 revisions from 00manifest.i
+  finished migrating 3 manifest revisions across 1 manifests; change in size: 
0 bytes
+  migrating changelog containing 3 revisions (376 bytes in store; 181 bytes 
tracked data)
+  cloning 3 revisions from 00changelog.i
+  finished migrating 3 changelog revisions; change in size: 0 bytes
+  finished migrating 9 total revisions; total change in store size: 0 bytes
+  copying phaseroots
+  data fully migrated to temporary repository
+  marking source repository as being upgraded; clients will be unable to read 
from repository
+  starting in-place swap of repository data
+  replaced files will be backed up at $TESTTMP/upgradegd/.hg/upgradebackup.* 
(glob)
+  replacing store...
+  store replacement complete; repository was inconsistent for *s (glob)
+  finalizing requirements file and making repository readable again
+  removing old repository content$TESTTMP/upgradegd/.hg/upgradebackup.* (glob)
+  removing temporary repository $TESTTMP/upgradegd/.hg/upgrade.* (glob)
+  $ hg verify
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 3 changesets with 3 changes to 3 files
+
+Check you can't skip revlog clone during important format upgrade
+
+  $ echo "sparse-revlog=yes" >> .hg/hgrc
+  $ hg debugupgrade --optimize re-delta-parent --run --manifest --no-backup 
--debug --traceback
+  ignoring revlogs selection flags, format requirement change: 
sparserevlogupgrade will perform the 

D6712: config: fix defaultvalue template keyword (patch 1 of 2)

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  This patch needs a better description.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

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


D6720: config: fix defaultvalue template keyword (patch 2 of 2)

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  This patch also needs a better description, something like: `config: fix 
fm.data() handling of defaultvalue`.

INLINE COMMENTS

> commands.py:1884
>  fm.condwrite(ui.debugflag, 'source', '%s: ', source)
> +fm.data(name=entryname, defaultvalue=defaultvalue)
>  if uniquesel:

A better fix will be to move `fm.data(name=entryname)` inside the if, i.e. 
where it was before https://phab.mercurial-scm.org/D6704.

And add `fm.data(defaultvalue=...)` below the if-else which will also move the 
`defaultvalue` to last in json output.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6720/new/

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

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


D6709: config: add --registered flag to show all known configs

2019-08-07 Thread marmoute (Pierre-Yves David)
This revision now requires changes to proceed.
marmoute added inline comments.
marmoute requested changes to this revision.

INLINE COMMENTS

> pulkit wrote in test-config.t:228
> In cases when the default value and the value of config set are different, 
> let's do something like ` (default=)`

Displaying the default vs current is good idea, but the current proposal might 
be a bit odd:

If nothing is set we will have:

  annotate.ignoreblanklines=False

If something is set and is the same as the default we'll have

  annotate.ignoreblanklines=False

If something is set and is different from the repo we will have

  annotate.ignoreblanklines=True (default: False)

The first two cases can't be distinguish while they probably should, and the 
default value is displayed differently between the first and third case.

> test-config.t:229
> +  $ hg showconfig --registered
> +  annotate.git=False
> +  annotate.ignoreblanklines=False

Note: we I think we should use `yes/no` instead of `True` and `False`.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6709/new/

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

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


D6712: config: fix defaultvalue template keyword (patch 1 of 2)

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  The `pycompat.bytestr()` was there for py3 compatibility, however removing it 
should be fine in this case. Can you make sure `test-config.t` passes with this 
patch on Python 3?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

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


D6709: config: add --registered flag to show all known configs

2019-08-07 Thread pulkit (Pulkit Goyal)
pulkit added inline comments.

INLINE COMMENTS

> ui.py:821
>  
> +def walkallconfig(self, untrusted=False):
> +"""walk through all known config options in the registrar"""

Since, we renamed the flag which was good idea, let's rename the function too.

Also, this should better return `section, name, value, default_value`.

> navaneeth.suresh wrote in test-config.t:238
> I have ignored the cases with `dynamicdefault`. But, there are three cases 
> showing a `devel-warn: accessing unregistered config item` message. Couldn't 
> figure out why it is coming.

Just for record, @av6 comment here is not done as there are still 
devel-warnings.

> test-config.t:228
> +
> +  $ hg showconfig --registered
> +  annotate.git=False

In cases when the default value and the value of config set are different, 
let's do something like ` (default=)`

> test-config.t:827
> +  fsmonitor.warn_when_unused=True
> +  devel-warn: accessing unregistered config item: 'help.hidden-command\..*' 
> at: /tmp/hgtests.7aNapb/install/lib/python/mercurial/commands.py:1876 (config)
> +  help.hidden-command\..*=

Can you look as why these devel-warning are coming up?

Since we are using `--registered`, having warnings related to unregistered 
config does not seems good.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6709/new/

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

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


D6720: config: fix defaultvalue template keyword (patch 2 of 2)

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is a follow-up patch to rHG51a2e3102db2 
. 
This moves
  `fm.data()` out of the if block in `commands.config()`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -57,11 +57,13 @@
   $ hg showconfig Section -Tjson
   [
{
+"defaultvalue": null,
 "name": "Section.KeY",
 "source": "*.hgrc:*", (glob)
 "value": "Case Sensitive"
},
{
+"defaultvalue": null,
 "name": "Section.key",
 "source": "*.hgrc:*", (glob)
 "value": "lower case"
@@ -77,8 +79,8 @@
}
   ]
   $ hg showconfig -Tjson | tail -7
-   },
{
+"defaultvalue": null,
 "name": "*", (glob)
 "source": "*", (glob)
 "value": "*" (glob)
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1881,8 +1881,8 @@
 continue
 fm.startitem()
 fm.condwrite(ui.debugflag, 'source', '%s: ', source)
+fm.data(name=entryname, defaultvalue=defaultvalue)
 if uniquesel:
-fm.data(name=entryname, defaultvalue=defaultvalue)
 fm.write('value', '%s\n', value)
 else:
 fm.write('name value', '%s=%s\n', entryname, value)



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


[PATCH 2 of 3 V3] copies: extract an explicit `computechangesetfilesadded` method from context

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560343342 -3600
#  Wed Jun 12 13:42:22 2019 +0100
# Node ID 791b66f0c3e2f67dd7cb093cf58d662f63e4273f
# Parent  fc8e461200c7262246ebd610100bcf9a75ded461
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
791b66f0c3e2
copies: extract an explicit `computechangesetfilesadded` method from context

Right now, the logic around changeset centric added files data are buried into
the "changectx" code. We extract this code in a dedicated method (in the scmutil
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -459,12 +459,7 @@ class changectx(basectx):
 (source == 'compatibility' and
  self._changeset.filesadded is not None)):
 return self._changeset.filesadded or []
-
-added = []
-for f in self.files():
-if not any(f in p for p in self.parents()):
-added.append(f)
-return added
+return scmutil.computechangesetfilesadded(self)
 def filesremoved(self):
 source = self._repo.ui.config('experimental', 'copies.read-from')
 if (source == 'changeset-only' or
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1984,3 +1984,12 @@ def bookmarkrevs(repo, mark):
  "ancestors(head() and not bookmark(%s)) - "
  "ancestors(bookmark() and not bookmark(%s))",
  mark, mark, mark)
+
+def computechangesetfilesadded(ctx):
+"""return the list of files added in a changeset
+"""
+added = []
+for f in ctx.files():
+if not any(f in p for p in ctx.parents()):
+added.append(f)
+return added
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 3 V3] copies: extract an explicit `computechangesetfilesremoved` method from context

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560343372 -3600
#  Wed Jun 12 13:42:52 2019 +0100
# Node ID 49740823dab3e2673ece70974080a274f2b8cf94
# Parent  791b66f0c3e2f67dd7cb093cf58d662f63e4273f
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
49740823dab3
copies: extract an explicit `computechangesetfilesremoved` method from context

Right now, the logic around changeset centric removed files data are buried into
the "changectx" code. We extract this code in a dedicated method (in the scmutil
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -466,12 +466,7 @@ class changectx(basectx):
 (source == 'compatibility' and
  self._changeset.filesremoved is not None)):
 return self._changeset.filesremoved or []
-
-removed = []
-for f in self.files():
-if f not in self:
-removed.append(f)
-return removed
+return scmutil.computechangesetfilesremoved(self)
 
 @propertycache
 def _copies(self):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1993,3 +1993,12 @@ def computechangesetfilesadded(ctx):
 if not any(f in p for p in ctx.parents()):
 added.append(f)
 return added
+
+def computechangesetfilesremoved(ctx):
+"""return the list of files removed in a changeset
+"""
+removed = []
+for f in ctx.files():
+if f not in ctx:
+removed.append(f)
+return removed
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3 V3] copies: extract an explicit `computechangesetcopie` method from context

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565054260 -7200
#  Tue Aug 06 03:17:40 2019 +0200
# Node ID fc8e461200c7262246ebd610100bcf9a75ded461
# Parent  f95b59ffc307c4549d9640a81d750a99bd75f423
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
fc8e461200c7
copies: extract an explicit `computechangesetcopie` method from context

Right now, the logic around changeset centric copies data are buried into the
"changectx" code. We extract this code in a dedicated method (in the copies
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -24,6 +24,7 @@ from .node import (
 wdirhex,
 )
 from . import (
+copies,
 dagop,
 encoding,
 error,
@@ -274,23 +275,7 @@ class basectx(object):
 
 @propertycache
 def _copies(self):
-p1copies = {}
-p2copies = {}
-p1 = self.p1()
-p2 = self.p2()
-narrowmatch = self._repo.narrowmatch()
-for dst in self.files():
-if not narrowmatch(dst) or dst not in self:
-continue
-copied = self[dst].renamed()
-if not copied:
-continue
-src, srcnode = copied
-if src in p1 and p1[src].filenode() == srcnode:
-p1copies[dst] = src
-elif src in p2 and p2[src].filenode() == srcnode:
-p2copies[dst] = src
-return p1copies, p2copies
+return copies.computechangesetcopies(self)
 def p1copies(self):
 return self._copies[0]
 def p2copies(self):
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -809,3 +809,28 @@ def duplicatecopies(repo, wctx, rev, fro
 continue
 if dst in wctx:
 wctx[dst].markcopied(src)
+
+def computechangesetcopies(ctx):
+"""return the copies data for a changeset
+
+The copies data are returned as a pair of dictionnary (p1copies, p2copies).
+
+Each dictionnary are in the form: `{newname: oldname}`
+"""
+p1copies = {}
+p2copies = {}
+p1 = ctx.p1()
+p2 = ctx.p2()
+narrowmatch = ctx._repo.narrowmatch()
+for dst in ctx.files():
+if not narrowmatch(dst) or dst not in ctx:
+continue
+copied = ctx[dst].renamed()
+if not copied:
+continue
+src, srcnode = copied
+if src in p1 and p1[src].filenode() == srcnode:
+p1copies[dst] = src
+elif src in p2 and p2[src].filenode() == srcnode:
+p2copies[dst] = src
+return p1copies, p2copies
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6712: config: fix defaultvalue template keyword (patch 1 of 2)

2019-08-07 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh retitled this revision from "config: fix defaultvalue template 
keyword" to "config: fix defaultvalue template keyword (patch 1 of 2)".
navaneeth.suresh edited the summary of this revision.
navaneeth.suresh updated this revision to Diff 16148.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6712?vs=16144=16148

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-config.t

CHANGE DETAILS

diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -70,7 +70,7 @@
   $ hg showconfig Section.KeY -Tjson
   [
{
-"defaultvalue": "None",
+"defaultvalue": null,
 "name": "Section.KeY",
 "source": "*.hgrc:*", (glob)
 "value": "Case Sensitive"
@@ -103,7 +103,7 @@
   $ hg config empty.source -Tjson
   [
{
-"defaultvalue": "None",
+"defaultvalue": null,
 "name": "empty.source",
 "source": "",
 "value": "value"
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1872,7 +1872,7 @@
 for section, name, value in ui.walkconfig(untrusted=untrusted):
 source = ui.configsource(section, name, untrusted)
 value = pycompat.bytestr(value)
-defaultvalue = pycompat.bytestr(ui.configdefault(section, name))
+defaultvalue = ui.configdefault(section, name)
 if fm.isplain():
 source = source or 'none'
 value = value.replace('\n', '\\n')



To: navaneeth.suresh, #hg-reviewers
Cc: durin42, marmoute, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Improving file name encoding support on Windows

2019-08-07 Thread Yuya Nishihara
On Wed, 07 Aug 2019 04:14:54 +0200, Manuel Jacob wrote:
> Unix-derived systems use bytes as the native type for file names.
> 
> Windows uses Unicode (this mostly means "UTF-16") as the native type for 
> file names.  Windows provides a subset of the filesystem API accepting 
> bytes (for some weird reason it’s called "ANSI APIs"), but in my 
> understanding it’s provided mostly for backward compatibility and its 
> use is discouraged.

Correct.

> On Windows, Python 2 and Python 3 up to Python 3.5 called the bytes API 
> iff a Python standard library filesystem function was called with bytes, 
> but it was deprecated in Python 3.3. [2]  Python 3.6 and later always 
> call the Unicode filesystem API, using UTF-8 to convert between bytes 
> and Unicode. [3]

Correct. And that's one reason why our Python 3 support is still in beta.

> Mercurial stores file names as bytes.  Because on Linux, the filesystem 
> API is bytes-native, that strategy works fine.  On Windows, passing 
> bytes to the filesystem API has some problems:
> 
> - Only the characters in the currently active code page can be used.  I 
> think that the current strategy limits the set of usable characters for 
> the majority of users, but I didn’t check.
> - Filename encoding interoperability between Windows and Unix-derived 
> systems is reduced because most users on Unix-derived systems have UTF-8 
> set as the system locale, but most Windows users don’t have UTF-8 set as 
> the code page.
> - Python 3.6 changed the behavior when passing bytes to the filesystem 
> functions in the standard library. [3]

Correct.

> Instead, I think that only Unicode strings should be passed to the 
> standard library filesystem functions.  This means that the bytes stored 
> by Mercurial need to be decoded using some codec, and file names 
> returned from the standard library filesystem functions need to be 
> encoded using some codec.

Yes. That's the idea behind WindowsUTF8Plan.

https://www.mercurial-scm.org/wiki/WindowsUTF8Plan

> How should that encoding be chosen?  I see a few possibilities:
> 
> - Always use UTF-8.  This is what will happen on Python 3.6 or later if 
> we do nothing.  It has the problem that existing non-ASCII file names 
> will break on Windows.

Yep. We'll need to get around the Python 3.6+ behavior change.

> - Use UTF-8 if all / some(?) file names in the manifest are in UTF-8 
> (this includes ASCII).  This is known as "hybrid strategy" or "Windows 
> UTF-8 Plan" in the Wiki.  I’m not sure whether this can be detected 
> reliably.

Not reliable in general.

> - Use encoding defined in a global setting.  People who care about 
> interoperability with other systems can set it to whatever the other 
> systems are using.
> - Store encoding in repository (either per manifest or per file).  I 
> think that this doesn’t solve the backward compatibility problem.

Perhaps, encoding can be stored in .hg/requires file. If "utf8-filename" is
in requires for example, u16vfs will be used on Windows. No behavior change
for existing repositories unless they are "upgraded" to utf8.

And there will be a config knob to enable "utf8-filename" by default.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 3 V2] copies: extract an explicit `computechangesetcopie` method from context

2019-08-07 Thread Yuya Nishihara
On Wed, 07 Aug 2019 11:24:25 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1565054260 -7200
> #  Tue Aug 06 03:17:40 2019 +0200
> # Node ID fc8e461200c7262246ebd610100bcf9a75ded461
> # Parent  f95b59ffc307c4549d9640a81d750a99bd75f423
> # EXP-Topic extrameta
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> fc8e461200c7
> copies: extract an explicit `computechangesetcopie` method from context

I meant to move all extracted functions to scmutil (or new module.)

I'm fine with this series (copies to copies, added/removed to scmutil)
if you prefer, but please update the commit messages of the PATCH 2-3
appropriately.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6712: config: fix defaultvalue template keyword

2019-08-07 Thread durin42 (Augie Fackler)
durin42 added a comment.
durin42 resigned from this revision.


  I agree with marmoute on all points.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

To: navaneeth.suresh, #hg-reviewers
Cc: durin42, marmoute, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Hosting Mercurial Sprint 5.2

2019-08-07 Thread Pulkit Goyal
Hey everyone,

Good news, Jane Street is happy to host us for the sprint in New York.

We plan to decide on a date in 7-10 days as that will give enough time
for people to book their travel. If you haven't filled your
preferences yet and want to attend the sprint, it will be a nice time
to do so at https://www.mercurial-scm.org/wiki/5.2sprint.

To people who already filled their preferences, Valentin found that
the dates were off by one, i.e. Sat-Mon instead of Fri-Sun. I fixed
the dates. It will be nice if you can check that the availabilities
has no changes with respect to date change.

Thanks and regards
Pulkit

On Wed, Jun 19, 2019 at 4:43 PM Pulkit Goyal <7895pul...@gmail.com> wrote:
>
> Hey everyone,
>
> I hope you're doing well.
>
> We are planning to have the next bi-yearly developer sprint 5.2 in sometime 
> in September or October. Since the last sprint happened in Europe, we are 
> planning to have this one in US.
>
> We are looking for location to host. Mercurial sprint happens for 3 
> consecutive days on Friday, Saturday and Sunday. Last time we had around 25 
> people. It is good to have a large main room and couple of small rooms for 
> sub-meetings. If you want to host, reply to this or can write in person to me 
> too.
>
> If you want to attend, it will be nice if you fill your availability at 
> https://www.mercurial-scm.org/wiki/5.2sprint.
>
> Thanks and Regards
> Pulkit
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3 V2] copies: extract an explicit `computechangesetcopie` method from context

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1565054260 -7200
#  Tue Aug 06 03:17:40 2019 +0200
# Node ID fc8e461200c7262246ebd610100bcf9a75ded461
# Parent  f95b59ffc307c4549d9640a81d750a99bd75f423
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
fc8e461200c7
copies: extract an explicit `computechangesetcopie` method from context

Right now, the logic around changeset centric copies data are buried into the
"changectx" code. We extract this code in a dedicated method (in the copies
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -24,6 +24,7 @@ from .node import (
 wdirhex,
 )
 from . import (
+copies,
 dagop,
 encoding,
 error,
@@ -274,23 +275,7 @@ class basectx(object):
 
 @propertycache
 def _copies(self):
-p1copies = {}
-p2copies = {}
-p1 = self.p1()
-p2 = self.p2()
-narrowmatch = self._repo.narrowmatch()
-for dst in self.files():
-if not narrowmatch(dst) or dst not in self:
-continue
-copied = self[dst].renamed()
-if not copied:
-continue
-src, srcnode = copied
-if src in p1 and p1[src].filenode() == srcnode:
-p1copies[dst] = src
-elif src in p2 and p2[src].filenode() == srcnode:
-p2copies[dst] = src
-return p1copies, p2copies
+return copies.computechangesetcopies(self)
 def p1copies(self):
 return self._copies[0]
 def p2copies(self):
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -809,3 +809,28 @@ def duplicatecopies(repo, wctx, rev, fro
 continue
 if dst in wctx:
 wctx[dst].markcopied(src)
+
+def computechangesetcopies(ctx):
+"""return the copies data for a changeset
+
+The copies data are returned as a pair of dictionnary (p1copies, p2copies).
+
+Each dictionnary are in the form: `{newname: oldname}`
+"""
+p1copies = {}
+p2copies = {}
+p1 = ctx.p1()
+p2 = ctx.p2()
+narrowmatch = ctx._repo.narrowmatch()
+for dst in ctx.files():
+if not narrowmatch(dst) or dst not in ctx:
+continue
+copied = ctx[dst].renamed()
+if not copied:
+continue
+src, srcnode = copied
+if src in p1 and p1[src].filenode() == srcnode:
+p1copies[dst] = src
+elif src in p2 and p2[src].filenode() == srcnode:
+p2copies[dst] = src
+return p1copies, p2copies
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 3 V2] copies: extract an explicit `computechangesetfilesadded` method from context

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560343342 -3600
#  Wed Jun 12 13:42:22 2019 +0100
# Node ID f6b2517c3651915610cee753ff8351e90078685d
# Parent  fc8e461200c7262246ebd610100bcf9a75ded461
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
f6b2517c3651
copies: extract an explicit `computechangesetfilesadded` method from context

Right now, the logic around changeset centric added files data are buried into
the "changectx" code. We extract this code in a dedicated method (in the copies
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -459,12 +459,7 @@ class changectx(basectx):
 (source == 'compatibility' and
  self._changeset.filesadded is not None)):
 return self._changeset.filesadded or []
-
-added = []
-for f in self.files():
-if not any(f in p for p in self.parents()):
-added.append(f)
-return added
+return scmutil.computechangesetfilesadded(self)
 def filesremoved(self):
 source = self._repo.ui.config('experimental', 'copies.read-from')
 if (source == 'changeset-only' or
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1984,3 +1984,12 @@ def bookmarkrevs(repo, mark):
  "ancestors(head() and not bookmark(%s)) - "
  "ancestors(bookmark() and not bookmark(%s))",
  mark, mark, mark)
+
+def computechangesetfilesadded(ctx):
+"""return the list of files added in a changeset
+"""
+added = []
+for f in ctx.files():
+if not any(f in p for p in ctx.parents()):
+added.append(f)
+return added
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 3 V2] copies: extract an explicit `computechangesetfilesremoved` method from context

2019-08-07 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1560343372 -3600
#  Wed Jun 12 13:42:52 2019 +0100
# Node ID 961d24dfe801ac0c5ad5737d98d553075cef4089
# Parent  f6b2517c3651915610cee753ff8351e90078685d
# EXP-Topic extrameta
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
961d24dfe801
copies: extract an explicit `computechangesetfilesremoved` method from context

Right now, the logic around changeset centric removed files data are buried into
the "changectx" code. We extract this code in a dedicated method (in the copies
module) for clarity. This clarity will help to explicitly compute and caches
these data in the future.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -466,12 +466,7 @@ class changectx(basectx):
 (source == 'compatibility' and
  self._changeset.filesremoved is not None)):
 return self._changeset.filesremoved or []
-
-removed = []
-for f in self.files():
-if f not in self:
-removed.append(f)
-return removed
+return scmutil.computechangesetfilesremoved(self)
 
 @propertycache
 def _copies(self):
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1993,3 +1993,12 @@ def computechangesetfilesadded(ctx):
 if not any(f in p for p in ctx.parents()):
 added.append(f)
 return added
+
+def computechangesetfilesremoved(ctx):
+"""return the list of files removed in a changeset
+"""
+removed = []
+for f in ctx.files():
+if f not in ctx:
+removed.append(f)
+return removed
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D6712: config: fix defaultvalue template keyword

2019-08-07 Thread marmoute (Pierre-Yves David)
marmoute added a comment.


  For some reasons, my previous comment seems to have never made it to 
phabricator:
  
  You description says the changesets does three things. So it should be three 
different changesets. Can you split them ?
  
  I don't understand why we are adding a warning here. The API usage seems 
valid.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6712/new/

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

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