D7576: hg-core: add configparser to library

2019-12-12 Thread Raphaël Gomès
Alphare added inline comments.

INLINE COMMENTS

> Cargo.toml:14
>  byteorder = "1.3.1"
> +bytes = "0.4.10"
>  dirs = "2.0.2"

I wonder about this dependency. It uses 4 `usize` for every slice of bytes, and 
adds some overhead, albeit minimal, that I am trying to justify.
Are we looking at reaping the benefits down the line? The crate itself is good 
quality, maintained by the Tokio people, so I'm not *too* worried about it 
being pre-1.0, but do we need this?

REPOSITORY
  rHG Mercurial

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

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

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


D7522: rust-dirs: handle forgotten `Result`s

2019-12-12 Thread Raphaël Gomès
Alphare added a comment.


  @martinvonz I was scratching my head trying to find this changeset to 
update/rebase it, here's `hg obslog -r 5a1ff3d75f35 --hidden`:
  
x  5a1ff3d75f35 (46379) rust-dirs: handle forgotten `Result`s
|rewritten as 80c3e3d4ddea by Martin von Zweigbergk 
 (Wed Dec 11 10:51:38 2019 -0800)
|
x  2c62ed1a015a (46378) rust-dirs: handle forgotten `Result`s
 rewritten(description) as 5a1ff3d75f35 using phabsend by Raphaël Gomès 
 (Wed Nov 27 14:30:10 2019 +0100)
  
  I don't have `80c3e3d4ddea` in my local repository. I could just revive 
`2c62ed1a015a` and edit from here, but I'm worried that might complicate things 
further.

REPOSITORY
  rHG Mercurial

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

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

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


D7605: formatting: fix some recent formatting regressions

2019-12-12 Thread pulkit (Pulkit Goyal)
This revision is now accepted and ready to land.
pulkit added a comment.
pulkit accepted this revision.


  Thanks for this. I installed black now, so I hope I will catch these next 
time before pushing changes.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

To: martinvonz, #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


D7595: status: outputting structured unfinished-operation information

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


  Applying this on top of D7605  failed. 
So unfortunately you have to rebase again and resend. Also, I think you are 
`pip install black` away from preventing such conflicts.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7492: localrepo: also fastpath access to working copy parents when possible

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


  In D7492#111595 , @martinvonz 
wrote:
  
  > Hmm, I thought this entire series had been queued. I'd like to queue it. 
Can you include perf numbers?
  
  Now that we have a reference filtered repository, I am planning to use the 
benchmark suite to gather timing (probably next week). We already track status 
and diff. addign `hg export` is easy. However I am not sure what's your 
criteria for annotate ? Can you clarify them and offer a file to test for each 
for the reference repositories ?

REPOSITORY
  rHG Mercurial

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

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

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


D7606: fuzz: fix mpatch_corpus to not have an overridden __repr__ on py3

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


  Amended following diff to make test-check-format.t happy:
  
diff --git a/contrib/fuzz/mpatch_corpus.py b/contrib/fuzz/mpatch_corpus.py
--- a/contrib/fuzz/mpatch_corpus.py
+++ b/contrib/fuzz/mpatch_corpus.py
@@ -16,11 +16,15 @@ args = ap.parse_args()
 
 
 if sys.version_info[0] < 3:
+
 class py2reprhack(object):
 def __repr__(self):
 """Py2 calls __repr__ for `bytes(foo)`, forward to __bytes__"""
 return self.__bytes__()
+
+
 else:
+
 class py2reprhack(object):
 """Not needed on py3."""

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7606: fuzz: fix mpatch_corpus to not have an overridden __repr__ on py3

2019-12-12 Thread spectral (Kyle Lippincott)
Closed by commit rHG229215fc1c1c: fuzz: fix mpatch_corpus to not have an 
overridden __repr__ on py3 (authored by spectral).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7606?vs=18622&id=18627#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7606?vs=18622&id=18627

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

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

AFFECTED FILES
  contrib/fuzz/mpatch_corpus.py

CHANGE DETAILS

diff --git a/contrib/fuzz/mpatch_corpus.py b/contrib/fuzz/mpatch_corpus.py
--- a/contrib/fuzz/mpatch_corpus.py
+++ b/contrib/fuzz/mpatch_corpus.py
@@ -2,6 +2,7 @@
 
 import argparse
 import struct
+import sys
 import zipfile
 
 from mercurial import (
@@ -14,16 +15,26 @@
 args = ap.parse_args()
 
 
-class deltafrag(object):
+if sys.version_info[0] < 3:
+
+class py2reprhack(object):
+def __repr__(self):
+"""Py2 calls __repr__ for `bytes(foo)`, forward to __bytes__"""
+return self.__bytes__()
+
+
+else:
+
+class py2reprhack(object):
+"""Not needed on py3."""
+
+
+class deltafrag(py2reprhack):
 def __init__(self, start, end, data):
 self.start = start
 self.end = end
 self.data = data
 
-def __repr__(self):
-# py2 calls __repr__ when you do `bytes(foo)`
-return self.__bytes__()
-
 def __bytes__(self):
 return (
 struct.pack(">lll", self.start, self.end, len(self.data))
@@ -31,27 +42,19 @@
 )
 
 
-class delta(object):
+class delta(py2reprhack):
 def __init__(self, frags):
 self.frags = frags
 
-def __repr__(self):
-# py2 calls __repr__ when you do `bytes(foo)`
-return self.__bytes__()
-
 def __bytes__(self):
 return b''.join(bytes(f) for f in self.frags)
 
 
-class corpus(object):
+class corpus(py2reprhack):
 def __init__(self, base, deltas):
 self.base = base
 self.deltas = deltas
 
-def __repr__(self):
-# py2 calls __repr__ when you do `bytes(foo)`
-return self.__bytes__()
-
 def __bytes__(self):
 deltas = [bytes(d) for d in self.deltas]
 parts = (



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


D7607: phabricator: add the "Changes Planned" status name

2019-12-12 Thread mharbison72 (Matt Harbison)
Closed by commit rHG74ec6ca0eb75: phabricator: add the "Changes 
Planned" status name (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7607?vs=18623&id=18628

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

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

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -1268,6 +1268,7 @@
 b'needsrevision',
 b'closed',
 b'abandoned',
+b'changesplanned',
 }
 
 



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


D7608: phabricator: color the status in the "phabstatus" view

2019-12-12 Thread mharbison72 (Matt Harbison)
Closed by commit rHGb0867b7751ba: phabricator: color the status in the 
"phabstatus" view (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7608?vs=18624&id=18629

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

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

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -130,6 +130,12 @@
 b'phabricator.desc': b'',
 b'phabricator.drev': b'bold',
 b'phabricator.node': b'',
+b'phabricator.status.abandoned': b'magenta dim',
+b'phabricator.status.accepted': b'green bold',
+b'phabricator.status.closed': b'green',
+b'phabricator.status.needsreview': b'yellow',
+b'phabricator.status.needsrevision': b'red',
+b'phabricator.status.changesplanned': b'red',
 }
 
 _VCR_FLAGS = [
@@ -1728,7 +1734,11 @@
 
 def phabstatus(ctx):
 drev = drevsbyrev[ctx.rev()]
-ui.write(b"\n%(uri)s %(statusName)s\n" % drev)
+status = ui.label(
+b'%(statusName)s' % drev,
+b'phabricator.status.%s' % _getstatusname(drev),
+)
+ui.write(b"\n%s %s\n" % (drev[b'uri'], status))
 
 revs -= smartset.baseset(unknownrevs)
 revdag = graphmod.dagwalker(repo, revs)



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


D7605: formatting: fix some recent formatting regressions

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
Closed by commit rHG612951e08278: formatting: fix some recent formatting 
regressions (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7605?vs=18617&id=18626

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

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

AFFECTED FILES
  contrib/fuzz/mpatch_corpus.py
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -793,14 +793,17 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
-statemsg = _(b'The repository is in an unfinished *%s* state.'
- ) % self.unfinishedop
+statemsg = (
+_(b'The repository is in an unfinished *%s* state.')
+% self.unfinishedop
+)
 fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
 
 self._formatconflicts(fm)
 if self.unfinishedmsg:
-fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
- label=self._label)
+fm.plain(
+b'%s\n' % _commentlines(self.unfinishedmsg), label=self._label
+)
 
 def _formatconflicts(self, fm):
 if not self.inmergestate:
@@ -809,8 +812,8 @@
 if self.unresolvedpaths:
 mergeliststr = b'\n'.join(
 [
-b'%s' % util.pathto(self.reporoot, encoding.getcwd(),
-path)
+b'%s'
+% util.pathto(self.reporoot, encoding.getcwd(), path)
 for path in self.unresolvedpaths
 ]
 )
@@ -841,8 +844,13 @@
 unresolved = None
 if mergestate.active():
 unresolved = sorted(mergestate.unresolved())
-return morestatus(repo.root, unfinishedop, unfinishedmsg,
-  unresolved is not None, unresolved)
+return morestatus(
+repo.root,
+unfinishedop,
+unfinishedmsg,
+unresolved is not None,
+unresolved,
+)
 
 
 def findpossible(cmd, table, strict=False):
diff --git a/contrib/fuzz/mpatch_corpus.py b/contrib/fuzz/mpatch_corpus.py
--- a/contrib/fuzz/mpatch_corpus.py
+++ b/contrib/fuzz/mpatch_corpus.py
@@ -70,15 +70,15 @@
 # Manually constructed entries
 zf.writestr(
 "one_delta_applies",
-bytes(corpus(b'a', [delta([deltafrag(0, 1, b'b')])]))
+bytes(corpus(b'a', [delta([deltafrag(0, 1, b'b')])])),
 )
 zf.writestr(
 "one_delta_starts_late",
-bytes(corpus(b'a', [delta([deltafrag(3, 1, b'b')])]))
+bytes(corpus(b'a', [delta([deltafrag(3, 1, b'b')])])),
 )
 zf.writestr(
 "one_delta_ends_late",
-bytes(corpus(b'a', [delta([deltafrag(0, 20, b'b')])]))
+bytes(corpus(b'a', [delta([deltafrag(0, 20, b'b')])])),
 )
 
 try:



To: martinvonz, #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


D7592: fuzz: add support for fuzzing under either Python 2 or 3

2019-12-12 Thread durin42 (Augie Fackler)
Closed by commit rHG8766728dbce6: fuzz: add support for fuzzing under either 
Python 2 or 3 (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7592?vs=18559&id=18630

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

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

AFFECTED FILES
  contrib/fuzz/dirs.cc
  contrib/fuzz/dirstate.cc
  contrib/fuzz/fm1readmarkers.cc
  contrib/fuzz/fncache.cc
  contrib/fuzz/jsonescapeu8fast.cc
  contrib/fuzz/manifest.cc
  contrib/fuzz/pyutil.cc
  contrib/fuzz/pyutil.h
  contrib/fuzz/revlog.cc

CHANGE DETAILS

diff --git a/contrib/fuzz/revlog.cc b/contrib/fuzz/revlog.cc
--- a/contrib/fuzz/revlog.cc
+++ b/contrib/fuzz/revlog.cc
@@ -9,16 +9,15 @@
 
 extern "C" {
 
-static PyCodeObject *code;
+static PYCODETYPE *code;
 
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
 {
contrib::initpy(*argv[0]);
-   code = (PyCodeObject *)Py_CompileString(R"py(
-from parsers import parse_index2
+   code = (PYCODETYPE *)Py_CompileString(R"py(
 for inline in (True, False):
 try:
-index, cache = parse_index2(data, inline)
+index, cache = parsers.parse_index2(data, inline)
 index.slicechunktodensity(list(range(len(index))), 0.5, 262144)
 index.stats()
 index.findsnapshots({}, 0)
@@ -35,7 +34,7 @@
 # to debug failures.
 # print e
 )py",
-   "fuzzer", Py_file_input);
+ "fuzzer", Py_file_input);
return 0;
 }
 
diff --git a/contrib/fuzz/pyutil.h b/contrib/fuzz/pyutil.h
--- a/contrib/fuzz/pyutil.h
+++ b/contrib/fuzz/pyutil.h
@@ -1,5 +1,11 @@
 #include 
 
+#if PY_MAJOR_VERSION >= 3
+#define PYCODETYPE PyObject
+#else
+#define PYCODETYPE PyCodeObject
+#endif
+
 namespace contrib
 {
 
diff --git a/contrib/fuzz/pyutil.cc b/contrib/fuzz/pyutil.cc
--- a/contrib/fuzz/pyutil.cc
+++ b/contrib/fuzz/pyutil.cc
@@ -6,17 +6,26 @@
 namespace contrib
 {
 
+#if PY_MAJOR_VERSION >= 3
+#define HG_FUZZER_PY3 1
+PyMODINIT_FUNC PyInit_parsers(void);
+#else
+PyMODINIT_FUNC initparsers(void);
+#endif
+
 static char cpypath[8192] = "\0";
 
 static PyObject *mainmod;
 static PyObject *globals;
 
-/* TODO: use Python 3 for this fuzzing? */
-PyMODINIT_FUNC initparsers(void);
-
 void initpy(const char *cselfpath)
 {
+#ifdef HG_FUZZER_PY3
+   const std::string subdir = "/sanpy/lib/python3.7";
+#else
const std::string subdir = "/sanpy/lib/python2.7";
+#endif
+
/* HACK ALERT: we need a full Python installation built without
   pymalloc and with ASAN, so we dump one in
   $OUT/sanpy/lib/python2.7. This helps us wire that up. */
@@ -39,11 +48,24 @@
setenv("PYTHONNOUSERSITE", "1", 1);
/* prevent Python from looking up users in the fuzz environment */
setenv("PYTHONUSERBASE", cpypath, 1);
+#ifdef HG_FUZZER_PY3
+   std::wstring wcpypath(pypath.begin(), pypath.end());
+   Py_SetPythonHome(wcpypath.c_str());
+#else
Py_SetPythonHome(cpypath);
+#endif
Py_InitializeEx(0);
mainmod = PyImport_AddModule("__main__");
globals = PyModule_GetDict(mainmod);
+
+#ifdef HG_FUZZER_PY3
+   PyObject *mod = PyInit_parsers();
+#else
initparsers();
+   PyObject *mod = PyImport_ImportModule("parsers");
+#endif
+
+   PyDict_SetItemString(globals, "parsers", mod);
 }
 
 PyObject *pyglobals()
diff --git a/contrib/fuzz/manifest.cc b/contrib/fuzz/manifest.cc
--- a/contrib/fuzz/manifest.cc
+++ b/contrib/fuzz/manifest.cc
@@ -9,15 +9,14 @@
 
 extern "C" {
 
-static PyCodeObject *code;
+static PYCODETYPE *code;
 
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
 {
contrib::initpy(*argv[0]);
-   code = (PyCodeObject *)Py_CompileString(R"py(
-from parsers import lazymanifest
+   code = (PYCODETYPE *)Py_CompileString(R"py(
 try:
-  lm = lazymanifest(mdata)
+  lm = parsers.lazymanifest(mdata)
   # iterate the whole thing, which causes the code to fully parse
   # every line in the manifest
   for e, _, _ in lm.iterentries():
@@ -41,7 +40,7 @@
   # to debug failures.
   # print e
 )py",
-   "fuzzer", Py_file_input);
+ "fuzzer", Py_file_input);
return 0;
 }
 
diff --git a/contrib/fuzz/jsonescapeu8fast.cc b/contrib/fuzz/jsonescapeu8fast.cc
--- a/contrib/fuzz/jsonescapeu8fast.cc
+++ b/contrib/fuzz/jsonescapeu8fast.cc
@@ -11,23 +11,21 @@
 
 extern "C" {
 
-static PyCodeObject *code;
+static PYCODETYPE *code;
 
 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
 {
contrib::initpy(*argv[0]);
-   code = (PyCodeObject *)Py_CompileString(R"py(
-from parsers import jsonescapeu8fast
-
+   code = (PYCODETYPE *)Py_CompileString(R"py(
 try:
-jsonescapeu8fast(data, paranoid)
+p

Re: D7550: chg: fix chg to work with py3.7+ "coercing" the locale

2019-12-12 Thread Yuya Nishihara
>   > Sigh. Can we work around this weird behavior by making chg do
>   > `putenv("PYTHONCOERCECLOCALE=0")`? I think it's simple and more desired
>   > behavior than the default of Python 3.
>   
>   I had considered that and was concerned it would create an observable, 
> surprising/confusing difference between chg and non-chg: if chg sets 
> PYTHONCOERCECLOCALE=0, hg won't have LC_CTYPE in the environment, and it WILL 
> have PYTHONCOERCECLOCALE in the environment. When it starts external tools 
> (like merge tools), this may change behavior in some observable fashion, and 
> if the user stops using chg and uses just plain hg, it will have LC_CTYPE in 
> the environment.

Yeah, that could happen. I checked the CPython code, but there's no easy way
to disable PYTHONCOERCECLOCALE at all without writing a C wrapper or rebuilding
Python itself with --without-c-locale-coercion.

I don't care much about the pollution of subprocess environments since Python
does pollute LC_CTYPE by default, which is IMHO worse, but I agree it isn't
nice to introduce behavior change between pure hg and chg. So we'll have to
take this patch, sigh.

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


D7550: chg: fix chg to work with py3.7+ "coercing" the locale

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


  >   > Sigh. Can we work around this weird behavior by making chg do
  >   > `putenv("PYTHONCOERCECLOCALE=0")`? I think it's simple and more desired
  >   > behavior than the default of Python 3.
  >   I had considered that and was concerned it would create an observable, 
surprising/confusing difference between chg and non-chg: if chg sets 
PYTHONCOERCECLOCALE=0, hg won't have LC_CTYPE in the environment, and it WILL 
have PYTHONCOERCECLOCALE in the environment. When it starts external tools 
(like merge tools), this may change behavior in some observable fashion, and if 
the user stops using chg and uses just plain hg, it will have LC_CTYPE in the 
environment.
  
  Yeah, that could happen. I checked the CPython code, but there's no easy way
  to disable PYTHONCOERCECLOCALE at all without writing a C wrapper or 
rebuilding
  Python itself with --without-c-locale-coercion.
  
  I don't care much about the pollution of subprocess environments since Python
  does pollute LC_CTYPE by default, which is IMHO worse, but I agree it isn't
  nice to introduce behavior change between pure hg and chg. So we'll have to
  take this patch, sigh.
  
  Queued, thanks.

REPOSITORY
  rHG Mercurial

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

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

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


D7550: chg: fix chg to work with py3.7+ "coercing" the locale

2019-12-12 Thread spectral (Kyle Lippincott)
Closed by commit rHG5e0f6451e2d2: chg: fix chg to work with py3.7+ 
"coercing" the locale (authored by spectral).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7550?vs=18475&id=18631#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7550?vs=18475&id=18631

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

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

AFFECTED FILES
  mercurial/chgserver.py
  tests/test-chg.t

CHANGE DETAILS

diff --git a/tests/test-chg.t b/tests/test-chg.t
--- a/tests/test-chg.t
+++ b/tests/test-chg.t
@@ -331,3 +331,25 @@
   /MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached2 (in  
...s)
   /MM/DD HH:MM:SS (PID)> log -R cached
   /MM/DD HH:MM:SS (PID)> loaded repo into cache: $TESTTMP/cached (in  ...s)
+
+Test that chg works even when python "coerces" the locale (py3.7+, which is 
done
+by default if none of LC_ALL, LC_CTYPE, or LANG are set in the environment)
+
+  $ cat > $TESTTMP/debugenv.py < from mercurial import encoding
+  > from mercurial import registrar
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command(b'debugenv', [], b'', norepo=True)
+  > def debugenv(ui):
+  > for k in [b'LC_ALL', b'LC_CTYPE', b'LANG']:
+  > v = encoding.environ.get(k)
+  > if v is not None:
+  > ui.write(b'%s=%s\n' % (k, encoding.environ[k]))
+  > EOF
+  $ LANG= LC_ALL= LC_CTYPE= chg \
+  >--config extensions.debugenv=$TESTTMP/debugenv.py debugenv
+  LC_ALL=
+  LC_CTYPE=C.UTF-8 (py37 !)
+  LC_CTYPE= (no-py37 !)
+  LANG=
diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -549,6 +549,41 @@
 except ValueError:
 raise ValueError(b'unexpected value in setenv request')
 self.ui.log(b'chgserver', b'setenv: %r\n', sorted(newenv.keys()))
+
+# Python3 has some logic to "coerce" the C locale to a UTF-8 capable
+# one, and it sets LC_CTYPE in the environment to C.UTF-8 if none of
+# 'LC_CTYPE', 'LC_ALL' or 'LANG' are set (to any value). This can be
+# disabled with PYTHONCOERCECLOCALE=0 in the environment.
+#
+# When fromui is called via _inithashstate, python has already set
+# this, so that's in the environment right when we start up the hg
+# process. Then chg will call us and tell us to set the environment to
+# the one it has; this might NOT have LC_CTYPE, so we'll need to
+# carry-forward the LC_CTYPE that was coerced in these situations.
+#
+# If this is not handled, we will fail config+env validation and fail
+# to start chg. If this is just ignored instead of carried forward, we
+# may have different behavior between chg and non-chg.
+if pycompat.ispy3:
+# Rename for wordwrapping purposes
+oldenv = encoding.environ
+if not any(
+e.get(b'PYTHONCOERCECLOCALE') == b'0' for e in [oldenv, newenv]
+):
+keys = [b'LC_CTYPE', b'LC_ALL', b'LANG']
+old_keys = [k for k, v in oldenv.items() if k in keys and v]
+new_keys = [k for k, v in newenv.items() if k in keys and v]
+# If the user's environment (from chg) doesn't have ANY of the
+# keys that python looks for, and the environment (from
+# initialization) has ONLY LC_CTYPE and it's set to C.UTF-8,
+# carry it forward.
+if (
+not new_keys
+and old_keys == [b'LC_CTYPE']
+and oldenv[b'LC_CTYPE'] == b'C.UTF-8'
+):
+newenv[b'LC_CTYPE'] = oldenv[b'LC_CTYPE']
+
 encoding.environ.clear()
 encoding.environ.update(newenv)
 



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


D7522: rust-dirs: handle forgotten `Result`s

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7522#111970 , @Alphare wrote:
  
  > @martinvonz I was scratching my head trying to find this changeset to 
update/rebase it, here's `hg obslog -r 5a1ff3d75f35 --hidden`:
  >
  >   x  5a1ff3d75f35 (46379) rust-dirs: handle forgotten `Result`s
  >   |rewritten as 80c3e3d4ddea by Martin von Zweigbergk 
 (Wed Dec 11 10:51:38 2019 -0800)
  >   |
  >   x  2c62ed1a015a (46378) rust-dirs: handle forgotten `Result`s
  >rewritten(description) as 5a1ff3d75f35 using phabsend by Raphaël 
Gomès  (Wed Nov 27 14:30:10 2019 +0100)
  >
  > I don't have `80c3e3d4ddea` in my local repository. I could just revive 
`2c62ed1a015a` and edit from here, but I'm worried that might complicate things 
further.
  
  I think I had just pruned my local version of it. I assume you got the prune 
marker too, so I'm surprised that doesn't show up in obslog. Anyway, it should 
be the right thing to just revive your version. Sorry about the trouble. We 
need to fix this workflow some day.

REPOSITORY
  rHG Mercurial

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

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

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


D7492: localrepo: also fastpath access to working copy parents when possible

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7492#111988 , @marmoute 
wrote:
  
  > In D7492#111595 , @martinvonz 
wrote:
  >
  >> Hmm, I thought this entire series had been queued. I'd like to queue it. 
Can you include perf numbers?
  >
  > Now that we have a reference filtered repository, I am planning to use the 
benchmark suite to gather timing (probably next week). We already track status 
and diff. addign `hg export` is easy. However I am not sure what's your 
criteria for annotate ? Can you clarify them and offer a file to test for each 
for the reference repositories ?
  
  Try the one I used as an example in my patch. I don't think I thought very 
hard about finding a particularly good example. You just want one that's fast 
to annotate so the time to load obsmarkers is a significant part of the total 
time.

REPOSITORY
  rHG Mercurial

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

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

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


D7609: rust-dirs: handle forgotten `Result`s

2019-12-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In 1fe2e574616e 
 I 
introduced a temporary bugfix to align Rust code with a new
  behavior from C/Python and forgot about a few `Result`s (cargo's compiler 
cache
  does not re-emit warnings on cached modules). This fixes it.
  
  For the record, I am still unsure that this behavior change is a good idea.
  
  Note: I was already quite unhappy with the setters and getters for the
  `DirstateMap` and, indirectly, `Dirs`, and this only further reinforces my
  feelings. I hope we can one day fix that situation at the type level; Georges
  Racinet and I were just talking about devising a POC for using the builder
  pattern in the context of FFI with Python, we'll see what comes out of it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -199,6 +199,9 @@
 let d = d.extract::(py)?;
 Ok(self.inner_shared(py).borrow_mut()?
 .has_tracked_dir(HgPath::new(d.data(py)))
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 .to_py_object(py))
 }
 
@@ -206,6 +209,9 @@
 let d = d.extract::(py)?;
 Ok(self.inner_shared(py).borrow_mut()?
 .has_dir(HgPath::new(d.data(py)))
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 .to_py_object(py))
 }
 
@@ -329,24 +335,35 @@
 
 def getdirs(&self) -> PyResult {
 // TODO don't copy, share the reference
-self.inner_shared(py).borrow_mut()?.set_dirs();
+self.inner_shared(py).borrow_mut()?.set_dirs()
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?;
 Dirs::from_inner(
 py,
 DirsMultiset::from_dirstate(
 &self.inner_shared(py).borrow(),
 Some(EntryState::Removed),
-),
+)
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?,
 )
 }
 def getalldirs(&self) -> PyResult {
 // TODO don't copy, share the reference
-self.inner_shared(py).borrow_mut()?.set_all_dirs();
+self.inner_shared(py).borrow_mut()?.set_all_dirs()
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?;
 Dirs::from_inner(
 py,
 DirsMultiset::from_dirstate(
 &self.inner_shared(py).borrow(),
 None,
-),
+).map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?,
 )
 }
 
diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -47,6 +47,9 @@
 let inner = if let Ok(map) = map.cast_as::(py) {
 let dirstate = extract_dirstate(py, &map)?;
 DirsMultiset::from_dirstate(&dirstate, skip_state)
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 } else {
 let map: Result, PyErr> = map
 .iter(py)?
@@ -57,6 +60,9 @@
 })
 .collect();
 DirsMultiset::from_manifest(&map?)
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 };
 
 Self::create_instance(
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -125,7 +125,7 @@
 }
 if old_state == EntryState::Unknown {
 if let Some(ref mut all_dirs) = self.all_dirs {
-all_dirs.add_path(filename);
+all_dirs.add_path(filename)?;
 }
 }
 
@@ -226,30 +226,32 @@
 /// emulate a Python lazy property, but it is ugly and unidiomatic.
 /// TODO One day, rewriting this struct using the typestate might be a
 /// good idea.
-pub fn set_all_dirs(&mut self) {
+pub fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> {
 if self.all_dirs.is_none() {
 self.all_dirs =
-Some(DirsMultiset::fr

D7522: rust-dirs: handle forgotten `Result`s

2019-12-12 Thread Raphaël Gomès
Alphare added a comment.
Alphare abandoned this revision.


  Abandoned in favor of D7609 

REPOSITORY
  rHG Mercurial

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

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

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


D7609: rust-dirs: handle forgotten `Result`s

2019-12-12 Thread Raphaël Gomès
Alphare updated this revision to Diff 18633.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7609?vs=18632&id=18633

BRANCH
  default

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

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

AFFECTED FILES
  rust/hg-core/src/dirstate/dirs_multiset.rs
  rust/hg-core/src/dirstate/dirstate_map.rs
  rust/hg-core/src/matchers.rs
  rust/hg-cpython/src/dirstate/dirs_multiset.rs
  rust/hg-cpython/src/dirstate/dirstate_map.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/dirstate_map.rs 
b/rust/hg-cpython/src/dirstate/dirstate_map.rs
--- a/rust/hg-cpython/src/dirstate/dirstate_map.rs
+++ b/rust/hg-cpython/src/dirstate/dirstate_map.rs
@@ -200,6 +200,9 @@
 let d = d.extract::(py)?;
 Ok(self.inner_shared(py).borrow_mut()?
 .has_tracked_dir(HgPath::new(d.data(py)))
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 .to_py_object(py))
 }
 
@@ -207,6 +210,9 @@
 let d = d.extract::(py)?;
 Ok(self.inner_shared(py).borrow_mut()?
 .has_dir(HgPath::new(d.data(py)))
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 .to_py_object(py))
 }
 
@@ -330,24 +336,35 @@
 
 def getdirs(&self) -> PyResult {
 // TODO don't copy, share the reference
-self.inner_shared(py).borrow_mut()?.set_dirs();
+self.inner_shared(py).borrow_mut()?.set_dirs()
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?;
 Dirs::from_inner(
 py,
 DirsMultiset::from_dirstate(
 &self.inner_shared(py).borrow(),
 Some(EntryState::Removed),
-),
+)
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?,
 )
 }
 def getalldirs(&self) -> PyResult {
 // TODO don't copy, share the reference
-self.inner_shared(py).borrow_mut()?.set_all_dirs();
+self.inner_shared(py).borrow_mut()?.set_all_dirs()
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?;
 Dirs::from_inner(
 py,
 DirsMultiset::from_dirstate(
 &self.inner_shared(py).borrow(),
 None,
-),
+).map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?,
 )
 }
 
diff --git a/rust/hg-cpython/src/dirstate/dirs_multiset.rs 
b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
--- a/rust/hg-cpython/src/dirstate/dirs_multiset.rs
+++ b/rust/hg-cpython/src/dirstate/dirs_multiset.rs
@@ -47,6 +47,9 @@
 let inner = if let Ok(map) = map.cast_as::(py) {
 let dirstate = extract_dirstate(py, &map)?;
 DirsMultiset::from_dirstate(&dirstate, skip_state)
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 } else {
 let map: Result, PyErr> = map
 .iter(py)?
@@ -57,6 +60,9 @@
 })
 .collect();
 DirsMultiset::from_manifest(&map?)
+.map_err(|e| {
+PyErr::new::(py, e.to_string())
+})?
 };
 
 Self::create_instance(
diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs
--- a/rust/hg-core/src/matchers.rs
+++ b/rust/hg-core/src/matchers.rs
@@ -7,7 +7,7 @@
 
 //! Structs and types for matching files and directories.
 
-use crate::utils::hg_path::{HgPath, HgPathBuf};
+use crate::utils::hg_path::HgPath;
 use std::collections::HashSet;
 
 pub enum VisitChildrenSet<'a> {
diff --git a/rust/hg-core/src/dirstate/dirstate_map.rs 
b/rust/hg-core/src/dirstate/dirstate_map.rs
--- a/rust/hg-core/src/dirstate/dirstate_map.rs
+++ b/rust/hg-core/src/dirstate/dirstate_map.rs
@@ -126,7 +126,7 @@
 }
 if old_state == EntryState::Unknown {
 if let Some(ref mut all_dirs) = self.all_dirs {
-all_dirs.add_path(filename);
+all_dirs.add_path(filename)?;
 }
 }
 
@@ -227,30 +227,38 @@
 /// emulate a Python lazy property, but it is ugly and unidiomatic.
 /// TODO One day, rewriting this struct using the typestate might be a
 /// good idea.
-pub fn set_all_dirs(&mut self) {
+pub fn set_all_dirs(&mut self) -> Result<(), DirstateMapError> {
 if self.all_dirs.is_none() {
 self.all_dirs =
-Some(DirsMultiset::from_dirstate(&self.state_map, None));
+Some(DirsMultiset::from_dirstate(&self.state_map, None)?);
 }
+Ok(())
 }
 
-pub fn set_dirs(&mut self) {
+pub fn set_dirs(&mut self) -> Result<(), DirstateMapError> {
 if self.dirs.is_none() {
 self.dirs = Some(DirsM

D7609: rust-dirs: handle forgotten `Result`s

2019-12-12 Thread Raphaël Gomès
Alphare added a comment.
Alphare added a subscriber: martinvonz.


  @martinvonz This should be ok.

REPOSITORY
  rHG Mercurial

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

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

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


D7528: rust-matchers: add `FileMatcher` implementation

2019-12-12 Thread Raphaël Gomès
Alphare edited the summary of this revision.
Alphare updated this revision to Diff 18634.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7528?vs=18418&id=18634

BRANCH
  default

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

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

AFFECTED FILES
  rust/hg-core/src/matchers.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/matchers.rs b/rust/hg-core/src/matchers.rs
--- a/rust/hg-core/src/matchers.rs
+++ b/rust/hg-core/src/matchers.rs
@@ -7,8 +7,9 @@
 
 //! Structs and types for matching files and directories.
 
-use crate::utils::hg_path::HgPath;
+use crate::{utils::hg_path::HgPath, DirsMultiset, DirstateMapError};
 use std::collections::HashSet;
+use std::iter::FromIterator;
 
 pub enum VisitChildrenSet<'a> {
 /// Don't visit anything
@@ -83,10 +84,10 @@
 ///
 /// let matcher = AlwaysMatcher;
 ///
-/// assert_eq!(true, matcher.matches(HgPath::new(b"whatever")));
-/// assert_eq!(true, matcher.matches(HgPath::new(b"b.txt")));
-/// assert_eq!(true, matcher.matches(HgPath::new(b"main.c")));
-/// assert_eq!(true, matcher.matches(HgPath::new(br"re:.*\.c$")));
+/// assert_eq!(matcher.matches(HgPath::new(b"whatever")), true);
+/// assert_eq!(matcher.matches(HgPath::new(b"b.txt")), true);
+/// assert_eq!(matcher.matches(HgPath::new(b"main.c")), true);
+/// assert_eq!(matcher.matches(HgPath::new(br"re:.*\.c$")), true);
 /// ```
 #[derive(Debug)]
 pub struct AlwaysMatcher;
@@ -114,3 +115,64 @@
 false
 }
 }
+
+/// Matches the input files exactly. They are interpreted as paths, not
+/// patterns.
+///
+///```
+/// use hg::{ matchers::{Matcher, FileMatcher}, utils::hg_path::HgPath };
+///
+/// let files = [HgPath::new(b"a.txt"), HgPath::new(br"re:.*\.c$")];
+/// let matcher = FileMatcher::new(&files).unwrap();
+///
+/// assert_eq!(matcher.matches(HgPath::new(b"a.txt")), true);
+/// assert_eq!(matcher.matches(HgPath::new(b"b.txt")), false);
+/// assert_eq!(matcher.matches(HgPath::new(b"main.c")), false);
+/// assert_eq!(matcher.matches(HgPath::new(br"re:.*\.c$")), true);
+/// ```
+#[derive(Debug)]
+pub struct FileMatcher<'a> {
+files: HashSet<&'a HgPath>,
+dirs: DirsMultiset,
+}
+
+impl<'a> FileMatcher<'a> {
+pub fn new(
+files: &'a [impl AsRef],
+) -> Result {
+Ok(Self {
+files: HashSet::from_iter(files.iter().map(|f| f.as_ref())),
+dirs: DirsMultiset::from_manifest(files)?,
+})
+}
+fn inner_matches(&self, filename: impl AsRef) -> bool {
+self.files.contains(filename.as_ref())
+}
+}
+
+impl<'a> Matcher for FileMatcher<'a> {
+fn file_set(&self) -> Option<&HashSet<&HgPath>> {
+Some(&self.files)
+}
+fn exact_match(&self, filename: impl AsRef) -> bool {
+self.inner_matches(filename)
+}
+fn matches(&self, filename: impl AsRef) -> bool {
+self.inner_matches(filename)
+}
+fn visit_children_set(
+&self,
+_directory: impl AsRef,
+) -> VisitChildrenSet {
+// TODO implement once we have `status.traverse`
+// This is useless until unknown files are taken into account
+// Which will not need to happen before the `IncludeMatcher`.
+unimplemented!()
+}
+fn matches_everything(&self) -> bool {
+false
+}
+fn is_exact(&self) -> bool {
+true
+}
+}



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


D7529: rust-dirstate-status: add `walk_explicit` implementation, use `Matcher` trait

2019-12-12 Thread Raphaël Gomès
Alphare updated this revision to Diff 18635.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7529?vs=18423&id=18635

BRANCH
  default

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

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

AFFECTED FILES
  rust/hg-core/src/dirstate/status.rs
  rust/hg-cpython/src/dirstate/status.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/status.rs 
b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -17,6 +17,7 @@
 };
 use hg::utils::files::get_path_from_bytes;
 
+use hg::matchers::AlwaysMatcher;
 use hg::status;
 use hg::utils::hg_path::HgPath;
 
@@ -53,9 +54,19 @@
 let dmap: DirstateMap = dmap.to_py_object(py);
 let dmap = dmap.get_inner(py);
 
-let (lookup, status_res) =
-status(&dmap, &root_dir, list_clean, last_normal_time, check_exec)
-.map_err(|e| PyErr::new::(py, e.to_string()))?;
+// TODO removed in the next patch to get the code to compile. This patch
+// is part of a series and does not make real sense on its own.
+let matcher = AlwaysMatcher;
+
+let (lookup, status_res) = status(
+&dmap,
+&matcher,
+&root_dir,
+list_clean,
+last_normal_time,
+check_exec,
+)
+.map_err(|e| PyErr::new::(py, e.to_string()))?;
 
 let modified = collect_pybytes_list(py, status_res.modified.as_ref());
 let added = collect_pybytes_list(py, status_res.added.as_ref());
diff --git a/rust/hg-core/src/dirstate/status.rs 
b/rust/hg-core/src/dirstate/status.rs
--- a/rust/hg-core/src/dirstate/status.rs
+++ b/rust/hg-core/src/dirstate/status.rs
@@ -11,6 +11,7 @@
 
 use crate::{
 dirstate::SIZE_FROM_OTHER_PARENT,
+matchers::Matcher,
 utils::{
 files::HgMetadata,
 hg_path::{hg_path_to_path_buf, HgPath},
@@ -18,6 +19,7 @@
 CopyMap, DirstateEntry, DirstateMap, EntryState,
 };
 use rayon::prelude::*;
+use std::collections::HashSet;
 use std::path::Path;
 
 /// Marker enum used to dispatch new status entries into the right collections.
@@ -33,6 +35,8 @@
 Unknown,
 }
 
+type IoResult = std::io::Result;
+
 /// Dates and times that are outside the 31-bit signed range are compared
 /// modulo 2^31. This should prevent hg from behaving badly with very large
 /// files or corrupt dates while still having a high probability of detecting
@@ -116,6 +120,63 @@
 }
 }
 
+/// Get stat data about the files explicitly specified by match.
+/// TODO subrepos
+fn walk_explicit<'a>(
+files: &'a HashSet<&HgPath>,
+dmap: &'a DirstateMap,
+root_dir: impl AsRef + Sync + Send,
+check_exec: bool,
+list_clean: bool,
+last_normal_time: i64,
+) -> impl ParallelIterator> {
+files.par_iter().filter_map(move |filename| {
+// TODO normalization
+let normalized = filename.as_ref();
+
+let buf = match hg_path_to_path_buf(normalized) {
+Ok(x) => x,
+Err(e) => return Some(Err(e.into())),
+};
+let target = root_dir.as_ref().join(buf);
+let st = target.symlink_metadata();
+match st {
+Ok(meta) => {
+let file_type = meta.file_type();
+if file_type.is_file() || file_type.is_symlink() {
+if let Some(entry) = dmap.get(normalized) {
+return Some(Ok((
+normalized,
+dispatch_found(
+&normalized,
+*entry,
+HgMetadata::from_metadata(meta),
+&dmap.copy_map,
+check_exec,
+list_clean,
+last_normal_time,
+),
+)));
+}
+} else {
+if dmap.contains_key(normalized) {
+return Some(Ok((normalized, Dispatch::Removed)));
+}
+}
+}
+Err(_) => {
+if let Some(entry) = dmap.get(normalized) {
+return Some(Ok((
+normalized,
+dispatch_missing(entry.state),
+)));
+}
+}
+};
+None
+})
+}
+
 /// Stat all entries in the `DirstateMap` and mark them for dispatch into
 /// the relevant collections.
 fn stat_dmap_entries(
@@ -124,7 +185,7 @@
 check_exec: bool,
 list_clean: bool,
 last_normal_time: i64,
-) -> impl ParallelIterator> {
+) -> impl ParallelIterator> {
 dmap.par_iter().map(move |(filename, entry)| {
 let filename: &HgPath = filename;
 let filename_as_path = hg_path_to_path_buf(filename)?;
@@ -174,9 +235,9 @@
  * TOD

D7531: rust-matchers: add support for `exactmatcher` in `dirstate.status`

2019-12-12 Thread Raphaël Gomès
Alphare edited the summary of this revision.
Alphare retitled this revision from "rust-matchers: add support for 
`explicitmatcher` in `dirstate.status`" to "rust-matchers: add support for 
`exactmatcher` in `dirstate.status`".
Alphare updated this revision to Diff 18637.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7531?vs=18407&id=18637

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1092,11 +1092,14 @@
 dmap.preload()
 
 use_rust = True
+
+allowed_matchers = (matchmod.alwaysmatcher, matchmod.exactmatcher)
+
 if rustmod is None:
 use_rust = False
 elif subrepos:
 use_rust = False
-if bool(listunknown):
+elif bool(listunknown):
 # Pathauditor does not exist yet in Rust, unknown files
 # can't be trusted.
 use_rust = False
@@ -1104,7 +1107,7 @@
 # Rust has no ignore mechanism yet, so don't use Rust for
 # commands that need ignore.
 use_rust = False
-elif not match.always():
+elif not isinstance(match, allowed_matchers):
 # Matchers have yet to be implemented
 use_rust = False
 
@@ -1132,6 +1135,7 @@
 clean,
 ) = rustmod.status(
 dmap._rustmap,
+match,
 self._rootdir,
 bool(listclean),
 self._lastnormaltime,



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


D7530: rust-dirstate-status: update bridge for new rust version of `dirstate.status`

2019-12-12 Thread Raphaël Gomès
Alphare updated this revision to Diff 18636.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7530?vs=18567&id=18636

BRANCH
  default

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

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

AFFECTED FILES
  rust/hg-core/src/lib.rs
  rust/hg-cpython/src/dirstate.rs
  rust/hg-cpython/src/dirstate/status.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/dirstate/status.rs 
b/rust/hg-cpython/src/dirstate/status.rs
--- a/rust/hg-cpython/src/dirstate/status.rs
+++ b/rust/hg-cpython/src/dirstate/status.rs
@@ -12,14 +12,17 @@
 use crate::dirstate::DirstateMap;
 use cpython::exc::ValueError;
 use cpython::{
-PyBytes, PyErr, PyList, PyObject, PyResult, Python, PythonObject,
-ToPyObject,
+ObjectProtocol, PyBytes, PyErr, PyList, PyObject, PyResult, PyTuple,
+Python, PythonObject, ToPyObject,
 };
-use hg::utils::files::get_path_from_bytes;
-
-use hg::matchers::AlwaysMatcher;
-use hg::status;
-use hg::utils::hg_path::HgPath;
+use hg::utils::hg_path::HgPathBuf;
+use hg::{
+matchers::{AlwaysMatcher, FileMatcher},
+status,
+utils::{files::get_path_from_bytes, hg_path::HgPath},
+StatusResult,
+};
+use std::borrow::Borrow;
 
 /// This will be useless once trait impls for collection are added to `PyBytes`
 /// upstream.
@@ -43,6 +46,7 @@
 pub fn status_wrapper(
 py: Python,
 dmap: DirstateMap,
+matcher: PyObject,
 root_dir: PyObject,
 list_clean: bool,
 last_normal_time: i64,
@@ -54,20 +58,65 @@
 let dmap: DirstateMap = dmap.to_py_object(py);
 let dmap = dmap.get_inner(py);
 
-// TODO removed in the next patch to get the code to compile. This patch
-// is part of a series and does not make real sense on its own.
-let matcher = AlwaysMatcher;
+match matcher.get_type(py).name(py).borrow() {
+"alwaysmatcher" => {
+let matcher = AlwaysMatcher;
+let (lookup, status_res) = status(
+&dmap,
+&matcher,
+&root_dir,
+list_clean,
+last_normal_time,
+check_exec,
+)
+.map_err(|e| PyErr::new::(py, e.to_string()))?;
+build_response(lookup, status_res, py)
+}
+"exactmatcher" => {
+let files = matcher.call_method(
+py,
+"files",
+PyTuple::new(py, &[]),
+None,
+)?;
+let files: PyList = files.cast_into(py)?;
+let files: PyResult> = files
+.iter(py)
+.map(|f| {
+Ok(HgPathBuf::from_bytes(
+f.extract::(py)?.data(py),
+))
+})
+.collect();
 
-let (lookup, status_res) = status(
-&dmap,
-&matcher,
-&root_dir,
-list_clean,
-last_normal_time,
-check_exec,
-)
-.map_err(|e| PyErr::new::(py, e.to_string()))?;
+let files = files?;
+let matcher = FileMatcher::new(&files)
+.map_err(|e| PyErr::new::(py, e.to_string()))?;
+let (lookup, status_res) = status(
+&dmap,
+&matcher,
+&root_dir,
+list_clean,
+last_normal_time,
+check_exec,
+)
+.map_err(|e| PyErr::new::(py, e.to_string()))?;
+build_response(lookup, status_res, py)
+}
+e => {
+return Err(PyErr::new::(
+py,
+format!("Unsupported matcher {}", e),
+));
+}
+}
+}
 
+fn build_response(
+lookup: Vec<&HgPath>,
+status_res: StatusResult,
+py: Python,
+) -> PyResult<(PyList, PyList, PyList, PyList, PyList, PyList, PyList)> {
 let modified = collect_pybytes_list(py, status_res.modified.as_ref());
 let added = collect_pybytes_list(py, status_res.added.as_ref());
 let removed = collect_pybytes_list(py, status_res.removed.as_ref());
diff --git a/rust/hg-cpython/src/dirstate.rs b/rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs
+++ b/rust/hg-cpython/src/dirstate.rs
@@ -116,6 +116,7 @@
 status_wrapper(
 dmap: DirstateMap,
 root_dir: PyObject,
+matcher: PyObject,
 list_clean: bool,
 last_normal_time: i64,
 check_exec: bool
diff --git a/rust/hg-core/src/lib.rs b/rust/hg-core/src/lib.rs
--- a/rust/hg-core/src/lib.rs
+++ b/rust/hg-core/src/lib.rs
@@ -12,7 +12,7 @@
 dirs_multiset::{DirsMultiset, DirsMultisetIter},
 dirstate_map::DirstateMap,
 parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE},
-status::status,
+status::{status, StatusResult},
 CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState,
 StateMap, 

D7570: match: resolve filesets against the passed `cwd`, not the current one

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7570#111903 , @martinvonz 
wrote:
  
  > In D7570#111892 , @durin42 
wrote:
  >
  >> I'm happy with this, but didn't spend time figuring out if all concerns 
have been addressed (I'm mostly doing a fast triage path).
  >
  > I *think* they're addressed, but we there's no rush to get this in so let's 
give Yuya a chance to comment, because I'm not sure if the issue with subrepos 
is an existing or new issue.
  
  @yuja, what do you think?

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


[PATCH 1 of 2] crecord: rewrite help string to avoid mentioning "crecord"

2019-12-12 Thread Jordi Gutiérrez Hermoso
# HG changeset patch
# User Jordi Gutiérrez Hermoso 
# Date 1576168650 18000
#  Thu Dec 12 11:37:30 2019 -0500
# Node ID faab1971e30741d00b3d0a44548086e6203beca3
# Parent  49fa0b31ee1d84c44eab951f36fb7386e3fced22
crecord: rewrite help string to avoid mentioning "crecord"

Despite its heritage, "crecord" is now mostly Mercurial-internal
jargon. I find it better to call it "the curses hunk selector".

Also slightly rewrote the part about which commands can use it. While
I do believe that commit, shelve, and revert are the only commands in
core that can use it, Evolve also adds at least amend and uncommit to
the list.

diff --git a/mercurial/crecord.py b/mercurial/crecord.py
--- a/mercurial/crecord.py
+++ b/mercurial/crecord.py
@@ -1615,12 +1615,13 @@ class curseschunkselector(object):
 helptext = _(
 """[press any key to return to the patch-display]
 
-crecord allows you to interactively choose among the changes you have made,
-and confirm only those changes you select for further processing by the command
-you are running (commit/shelve/revert), after confirming the selected
-changes, the unselected changes are still present in your working copy, so you
-can use crecord multiple times to split large changes into smaller changesets.
-the following are valid keystrokes:
+The curses hunk selector allows you to interactively choose among the
+changes you have made, and confirm only those changes you select for
+further processing by the command you are running (such as commit,
+shelve, or revert). After confirming the selected changes, the
+unselected changes are still present in your working copy, so you can
+use the hunk selector multiple times to split large changes into
+smaller changesets. the following are valid keystrokes:
 
   x [space] : (un-)select item ([~]/[x] = partly/fully applied)
 [enter] : (un-)select item and go to next item of same type
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] hgweb: fix error in docstring

2019-12-12 Thread Jordi Gutiérrez Hermoso
# HG changeset patch
# User Jordi Gutiérrez Hermoso 
# Date 157616 18000
#  Thu Dec 12 11:41:28 2019 -0500
# Node ID e89a23f05828dc81d5f9f51994544d89fe7a7c4f
# Parent  faab1971e30741d00b3d0a44548086e6203beca3
hgweb: fix error in docstring

Despite the subtle semantic difference, this sentence really meant to
say "overridden", not "overwritten".

diff --git a/mercurial/helptext/hgweb.txt b/mercurial/helptext/hgweb.txt
--- a/mercurial/helptext/hgweb.txt
+++ b/mercurial/helptext/hgweb.txt
@@ -61,7 +61,7 @@ The web server has a default style assoc
 a collection of named templates. Each template is used to render a
 specific piece of data, such as a changeset or diff.
 
-The style for the current request can be overwritten two ways. First,
+The style for the current request can be overridden two ways. First,
 if ``{command}`` contains a hyphen (``-``), the text before the hyphen
 defines the style. For example, ``/atom-log`` will render the ``log``
 command handler with the ``atom`` style. The second way to set the
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7118: rust-dirstatemap: remove additional lookups in traverse

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7118#111784 , @Alphare wrote:
  
  > In D7118#111735 , @martinvonz 
wrote:
  >
  >> What's the state of this patch? The description makes it sound like it's a 
Rust patch, but it only modifies Python code.
  >
  > It only impacts the rust module policy, I figured the name was not a bad 
idea. Maybe I'm wrong?
  > I also did not find Yuya's suggestion to work, but I may have understood it 
wrong.
  
  I think Yuya's suggestion was to make the diff be this:
  
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -909,7 +909,7 @@ class dirstate(object):
 matchfn = match.matchfn
 matchalways = match.always()
 matchtdir = match.traversedir
-dmap = self._map
+dmap = self._map._map
 listdir = util.listdir
 lstat = os.lstat
 dirkind = stat.S_IFDIR
  
  Obviously, you'd need to make some adjustments to allow that, at least 
renaming `_rustmap` to `_map`. The commit message should also change then.
  
  I don't remember what the point of the nested `_map`s was (perhaps to make it 
possible to replace the inner `_map`?). Hopefully we're not breaking that by 
directly accessing the inner `_map`.

REPOSITORY
  rHG Mercurial

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

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

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


D7603: cext-revlog: fixed __delitem__ for uninitialized nodetree

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  This broke `./run-tests.py --pure test-parseindex2.py`

REPOSITORY
  rHG Mercurial

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

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

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


[PATCH 2 of 5 STABLE] py3: pass bytes to `configint` and `configbool`

2019-12-12 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1574094884 -3600
#  Mon Nov 18 17:34:44 2019 +0100
# Branch stable
# Node ID 697e5119ce5d2ae8c7ef048a8a18e2b15c7af17a
# Parent  36425b06e091f8e6336358dba278ef3804e183fb
py3: pass bytes to `configint` and `configbool`

Both functions require bytes, even in Python 3.

Differential Revision: https://phab.mercurial-scm.org/D7453

diff -r 36425b06e091 -r 697e5119ce5d mercurial/dirstate.py
--- a/mercurial/dirstate.py Sun Nov 10 07:30:14 2019 -0800
+++ b/mercurial/dirstate.py Mon Nov 18 17:34:44 2019 +0100
@@ -1119,11 +1119,11 @@
 # Force Rayon (Rust parallelism library) to respect the number of
 # workers. This is a temporary workaround until Rust code knows
 # how to read the config file.
-numcpus = self._ui.configint("worker", "numcpus")
+numcpus = self._ui.configint(b"worker", b"numcpus")
 if numcpus is not None:
 encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % 
numcpus)
 
-workers_enabled = self._ui.configbool("worker", "enabled", True)
+workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
 if not workers_enabled:
 encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 5 STABLE] py3: send bytes from Rust-created warning patterns

2019-12-12 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1574095079 -3600
#  Mon Nov 18 17:37:59 2019 +0100
# Branch stable
# Node ID 2f084275a6435092058eaf9cb1a46cc6d7b0821a
# Parent  697e5119ce5d2ae8c7ef048a8a18e2b15c7af17a
py3: send bytes from Rust-created warning patterns

Python code expects bytes in both Python 2 and Python 3, so we should send
bytes.

Differential Revision: https://phab.mercurial-scm.org/D7454

diff -r 697e5119ce5d -r 2f084275a643 rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs   Mon Nov 18 17:34:44 2019 +0100
+++ b/rust/hg-cpython/src/filepatterns.rs   Mon Nov 18 17:37:59 2019 +0100
@@ -13,8 +13,7 @@
 //!
 use crate::exceptions::{PatternError, PatternFileError};
 use cpython::{
-PyBytes, PyDict, PyModule, PyObject, PyResult, PyString, PyTuple, Python,
-ToPyObject,
+PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
 use hg::{
 build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
@@ -66,12 +65,12 @@
 fn warnings_to_py_bytes(
 py: Python,
 warnings: &[(PathBuf, Vec)],
-) -> Vec<(PyString, PyBytes)> {
+) -> Vec<(PyBytes, PyBytes)> {
 warnings
 .iter()
 .map(|(path, syn)| {
 (
-PyString::new(py, &path.to_string_lossy()),
+PyBytes::new(py, &path.to_string_lossy().as_bytes()),
 PyBytes::new(py, syn),
 )
 })
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 5 STABLE] rust-cpython: import utils::files::* function at module level

2019-12-12 Thread Raphaël Gomès
# HG changeset patch
# User Yuya Nishihara 
# Date 1574172976 -32400
#  Tue Nov 19 23:16:16 2019 +0900
# Branch stable
# Node ID c549f8598cdf726b2e4239db5728ceebec448c23
# Parent  2f084275a6435092058eaf9cb1a46cc6d7b0821a
rust-cpython: import utils::files::* function at module level

IIRC, it's common in Rust to call functions with the module prefix.

diff -r 2f084275a643 -r c549f8598cdf rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs   Mon Nov 18 17:37:59 2019 +0100
+++ b/rust/hg-cpython/src/filepatterns.rs   Tue Nov 19 23:16:16 2019 +0900
@@ -15,10 +15,8 @@
 use cpython::{
 PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
-use hg::{
-build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
-LineNumber, PatternTuple,
-};
+use hg::utils::files;
+use hg::{build_single_regex, read_pattern_file, LineNumber, PatternTuple};
 use std::path::PathBuf;
 
 /// Rust does not like functions with different return signatures.
@@ -38,7 +36,7 @@
 source_info: bool,
 ) -> PyResult {
 let bytes = file_path.extract::(py)?;
-let path = get_path_from_bytes(bytes.data(py));
+let path = files::get_path_from_bytes(bytes.data(py));
 match read_pattern_file(path, warn) {
 Ok((patterns, warnings)) => {
 if source_info {
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 5 STABLE] rust-cpython: do not convert warning pattern to utf-8 bytes

2019-12-12 Thread Raphaël Gomès
# HG changeset patch
# User Yuya Nishihara 
# Date 1574173197 -32400
#  Tue Nov 19 23:19:57 2019 +0900
# Branch stable
# Node ID e0da98d4b03fbe274fe4c736ace28bc588c41ddf
# Parent  c549f8598cdf726b2e4239db5728ceebec448c23
rust-cpython: do not convert warning pattern to utf-8 bytes

On Unix, both Rust Path and Mercurial expect a locale-dependent bytes,
and we don't support Windows yet.

diff -r c549f8598cdf -r e0da98d4b03f rust/hg-core/src/utils/files.rs
--- a/rust/hg-core/src/utils/files.rs   Tue Nov 19 23:16:16 2019 +0900
+++ b/rust/hg-core/src/utils/files.rs   Tue Nov 19 23:19:57 2019 +0900
@@ -29,6 +29,14 @@
 Path::new(os_str)
 }
 
+// TODO: need to convert from WTF8 to MBCS bytes on Windows.
+// that's why Vec is returned.
+#[cfg(unix)]
+pub fn get_bytes_from_path(path: impl AsRef) -> Vec {
+use std::os::unix::ffi::OsStrExt;
+path.as_ref().as_os_str().as_bytes().to_vec()
+}
+
 /// An iterator over repository path yielding itself and its ancestors.
 #[derive(Copy, Clone, Debug)]
 pub struct Ancestors<'a> {
diff -r c549f8598cdf -r e0da98d4b03f rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs   Tue Nov 19 23:16:16 2019 +0900
+++ b/rust/hg-cpython/src/filepatterns.rs   Tue Nov 19 23:19:57 2019 +0900
@@ -68,7 +68,7 @@
 .iter()
 .map(|(path, syn)| {
 (
-PyBytes::new(py, &path.to_string_lossy().as_bytes()),
+PyBytes::new(py, &files::get_bytes_from_path(path)),
 PyBytes::new(py, syn),
 )
 })
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 5 STABLE] rust-threads: force Rayon to respect the worker count in config

2019-12-12 Thread Raphaël Gomès
# HG changeset patch
# User Raphaël Gomès 
# Date 1573399814 28800
#  Sun Nov 10 07:30:14 2019 -0800
# Branch stable
# Node ID 36425b06e091f8e6336358dba278ef3804e183fb
# Parent  612b4b63fb2267320f18655c0fa8a675f8fe3939
rust-threads: force Rayon to respect the worker count in config

As per the inline comment, this is a workaround because Rust code does not yet
know how to read config files.

Differential Revision: https://phab.mercurial-scm.org/D7310

diff -r 612b4b63fb22 -r 36425b06e091 mercurial/dirstate.py
--- a/mercurial/dirstate.py Mon Dec 09 12:29:46 2019 +0100
+++ b/mercurial/dirstate.py Sun Nov 10 07:30:14 2019 -0800
@@ -1116,6 +1116,17 @@
 use_rust = False
 
 if use_rust:
+# Force Rayon (Rust parallelism library) to respect the number of
+# workers. This is a temporary workaround until Rust code knows
+# how to read the config file.
+numcpus = self._ui.configint("worker", "numcpus")
+if numcpus is not None:
+encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % 
numcpus)
+
+workers_enabled = self._ui.configbool("worker", "enabled", True)
+if not workers_enabled:
+encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
+
 (
 lookup,
 modified,
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 5 STABLE] py3: send bytes from Rust-created warning patterns

2019-12-12 Thread Martin von Zweigbergk via Mercurial-devel
On Thu, Dec 12, 2019 at 9:14 AM Raphaël Gomès 
wrote:

> # HG changeset patch
> # User Raphaël Gomès 
> # Date 1574095079 -3600
> #  Mon Nov 18 17:37:59 2019 +0100
> # Branch stable
> # Node ID 2f084275a6435092058eaf9cb1a46cc6d7b0821a
> # Parent  697e5119ce5d2ae8c7ef048a8a18e2b15c7af17a
> py3: send bytes from Rust-created warning patterns
>
> Python code expects bytes in both Python 2 and Python 3, so we should send
> bytes.
>
> Differential Revision: https://phab.mercurial-scm.org/D7454


delete?


>
>
> diff -r 697e5119ce5d -r 2f084275a643 rust/hg-cpython/src/filepatterns.rs
> --- a/rust/hg-cpython/src/filepatterns.rs   Mon Nov 18 17:34:44 2019
> +0100
> +++ b/rust/hg-cpython/src/filepatterns.rs   Mon Nov 18 17:37:59 2019
> +0100
> @@ -13,8 +13,7 @@
>  //!
>  use crate::exceptions::{PatternError, PatternFileError};
>  use cpython::{
> -PyBytes, PyDict, PyModule, PyObject, PyResult, PyString, PyTuple,
> Python,
> -ToPyObject,
> +PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python,
> ToPyObject,
>  };
>  use hg::{
>  build_single_regex, read_pattern_file,
> utils::files::get_path_from_bytes,
> @@ -66,12 +65,12 @@
>  fn warnings_to_py_bytes(
>  py: Python,
>  warnings: &[(PathBuf, Vec)],
> -) -> Vec<(PyString, PyBytes)> {
> +) -> Vec<(PyBytes, PyBytes)> {
>  warnings
>  .iter()
>  .map(|(path, syn)| {
>  (
> -PyString::new(py, &path.to_string_lossy()),
> +PyBytes::new(py, &path.to_string_lossy().as_bytes()),
>  PyBytes::new(py, syn),
>  )
>  })
> ___
> 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


D7595: status: outputting structured unfinished-operation information

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio updated this revision to Diff 18638.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7595?vs=18625&id=18638

BRANCH
  default

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,13 +63,20 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
}
   ]
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -793,6 +793,10 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
+fm.startitem()
+fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg)
+
 statemsg = (
 _(b'The repository is in an unfinished *%s* state.')
 % self.unfinishedop



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


D7603: cext-revlog: fixed __delitem__ for uninitialized nodetree

2019-12-12 Thread gracinet (Georges Racinet)
gracinet added a comment.


  oops, sorry, had no idea the exact same test was running for the pure imp 
(although it makes sense). I'll check into it, it's not obvious at first sight 
why it should not work.

REPOSITORY
  rHG Mercurial

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

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

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


D7595: status: outputting structured unfinished-operation information

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7595#111986 , @pulkit wrote:
  
  > Applying this on top of D7605  
failed. So unfortunately you have to rebase again and resend. Also, I think you 
are `pip install black` away from preventing such conflicts.
  
  I'll queue this based on Pulkit's approval.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7610: rust-threads: force Rayon to respect the worker count in config

2019-12-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  As per the inline comment, this is a workaround because Rust code does not yet
  know how to read config files.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1116,6 +1116,17 @@
 use_rust = False
 
 if use_rust:
+# Force Rayon (Rust parallelism library) to respect the number of
+# workers. This is a temporary workaround until Rust code knows
+# how to read the config file.
+numcpus = self._ui.configint("worker", "numcpus")
+if numcpus is not None:
+encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % 
numcpus)
+
+workers_enabled = self._ui.configbool("worker", "enabled", True)
+if not workers_enabled:
+encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
+
 (
 lookup,
 modified,



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


D7611: py3: pass bytes to `configint` and `configbool`

2019-12-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Both functions require bytes, even in Python 3.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -1119,11 +1119,11 @@
 # Force Rayon (Rust parallelism library) to respect the number of
 # workers. This is a temporary workaround until Rust code knows
 # how to read the config file.
-numcpus = self._ui.configint("worker", "numcpus")
+numcpus = self._ui.configint(b"worker", b"numcpus")
 if numcpus is not None:
 encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % 
numcpus)
 
-workers_enabled = self._ui.configbool("worker", "enabled", True)
+workers_enabled = self._ui.configbool(b"worker", b"enabled", True)
 if not workers_enabled:
 encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
 



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


D7612: py3: send bytes from Rust-created warning patterns

2019-12-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Python code expects bytes in both Python 2 and Python 3, so we should send
  bytes.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-cpython/src/filepatterns.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/filepatterns.rs 
b/rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs
+++ b/rust/hg-cpython/src/filepatterns.rs
@@ -13,8 +13,7 @@
 //!
 use crate::exceptions::{PatternError, PatternFileError};
 use cpython::{
-PyBytes, PyDict, PyModule, PyObject, PyResult, PyString, PyTuple, Python,
-ToPyObject,
+PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
 use hg::{
 build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
@@ -66,12 +65,12 @@
 fn warnings_to_py_bytes(
 py: Python,
 warnings: &[(PathBuf, Vec)],
-) -> Vec<(PyString, PyBytes)> {
+) -> Vec<(PyBytes, PyBytes)> {
 warnings
 .iter()
 .map(|(path, syn)| {
 (
-PyString::new(py, &path.to_string_lossy()),
+PyBytes::new(py, &path.to_string_lossy().as_bytes()),
 PyBytes::new(py, syn),
 )
 })



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


D7613: rust-cpython: import utils::files::* function at module level

2019-12-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  IIRC, it's common in Rust to call functions with the module prefix.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-cpython/src/filepatterns.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/filepatterns.rs 
b/rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs
+++ b/rust/hg-cpython/src/filepatterns.rs
@@ -15,10 +15,8 @@
 use cpython::{
 PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject,
 };
-use hg::{
-build_single_regex, read_pattern_file, utils::files::get_path_from_bytes,
-LineNumber, PatternTuple,
-};
+use hg::utils::files;
+use hg::{build_single_regex, read_pattern_file, LineNumber, PatternTuple};
 use std::path::PathBuf;
 
 /// Rust does not like functions with different return signatures.
@@ -38,7 +36,7 @@
 source_info: bool,
 ) -> PyResult {
 let bytes = file_path.extract::(py)?;
-let path = get_path_from_bytes(bytes.data(py));
+let path = files::get_path_from_bytes(bytes.data(py));
 match read_pattern_file(path, warn) {
 Ok((patterns, warnings)) => {
 if source_info {



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


D7615: procutil: try and avoid angering CoreFoundation on macOS

2019-12-12 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We've seen failures like this:
  
objc[57662]: +[__NSCFConstantString initialize] may have been in progress 
in another thread when fork() was called.
objc[57662]: +[__NSCFConstantString initialize] may have been in progress 
in another thread when fork() was called. We cannot safely call it or ignore it 
in the fork() child process. Crashing instead. Set a breakpoint on 
objc_initializeAfterForkError to debug.
  
  I think this is due to forking off some background processes during
  `hg update` or similar. I don't have any conclusive proof this is the
  fork() call that's to blame, but it's the most likely one since the
  regular `hg update` codepath uses the other fork() invocation (via
  workers) and we don't get this report from non-Google macOS users.
  
  Ugh.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/utils/procutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -423,7 +423,10 @@
 return rc
 
 
-def gui():
+_is_gui = None
+
+
+def _gui():
 '''Are we running in a GUI?'''
 if pycompat.isdarwin:
 if b'SSH_CONNECTION' in encoding.environ:
@@ -439,6 +442,13 @@
 return pycompat.iswindows or encoding.environ.get(b"DISPLAY")
 
 
+def gui():
+global _is_gui
+if _is_gui is None:
+_is_gui = _gui()
+return _is_gui
+
+
 def hgcmd():
 """Return the command used to execute current hg
 
@@ -562,6 +572,11 @@
 cmd, env, shell=False, stdout=None, stderr=None, ensurestart=True
 ):
 '''Spawn a command without waiting for it to finish.'''
+if pycompat.isdarwin:
+# avoid crash in CoreFoundation in case another thread
+# calls gui() while we're calling fork().
+gui()
+
 # double-fork to completely detach from the parent process
 # based on http://code.activestate.com/recipes/278731
 pid = os.fork()



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


D7614: rust-cpython: do not convert warning pattern to utf-8 bytes

2019-12-12 Thread Raphaël Gomès
Alphare created this revision.
Herald added subscribers: mercurial-devel, kevincox, durin42.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  On Unix, both Rust Path and Mercurial expect a locale-dependent bytes,
  and we don't support Windows yet.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  rust/hg-core/src/utils/files.rs
  rust/hg-cpython/src/filepatterns.rs

CHANGE DETAILS

diff --git a/rust/hg-cpython/src/filepatterns.rs 
b/rust/hg-cpython/src/filepatterns.rs
--- a/rust/hg-cpython/src/filepatterns.rs
+++ b/rust/hg-cpython/src/filepatterns.rs
@@ -68,7 +68,7 @@
 .iter()
 .map(|(path, syn)| {
 (
-PyBytes::new(py, &path.to_string_lossy().as_bytes()),
+PyBytes::new(py, &files::get_bytes_from_path(path)),
 PyBytes::new(py, syn),
 )
 })
diff --git a/rust/hg-core/src/utils/files.rs b/rust/hg-core/src/utils/files.rs
--- a/rust/hg-core/src/utils/files.rs
+++ b/rust/hg-core/src/utils/files.rs
@@ -29,6 +29,14 @@
 Path::new(os_str)
 }
 
+// TODO: need to convert from WTF8 to MBCS bytes on Windows.
+// that's why Vec is returned.
+#[cfg(unix)]
+pub fn get_bytes_from_path(path: impl AsRef) -> Vec {
+use std::os::unix::ffi::OsStrExt;
+path.as_ref().as_os_str().as_bytes().to_vec()
+}
+
 /// An iterator over repository path yielding itself and its ancestors.
 #[derive(Copy, Clone, Debug)]
 pub struct Ancestors<'a> {



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


D7603: cext-revlog: fixed __delitem__ for uninitialized nodetree

2019-12-12 Thread gracinet (Georges Racinet)
gracinet added a comment.


  Here's a quickfix that works for me for both pure and C
  
-- a/tests/test-parseindex2.py Thu Dec 05 20:41:23 2019 +0100
+++ b/tests/test-parseindex2.py Thu Dec 12 18:34:28 2019 +0100
@@ -18,6 +18,7 @@
 node as nodemod,
 policy,
 pycompat,
+util,
 )
 
 parsers = policy.importmod('parsers')
@@ -267,11 +268,12 @@
 appendrev(6)
 self.assertEqual(len(index), 7)
 
-del index[1:7]
+del index[1:-1]
 
 # assertions that failed before correction
 self.assertEqual(len(index), 1)  # was 4
-self.assertEqual(index.headrevs(), [0])  # gave ValueError
+if util.safehasattr(index, 'headrevs'):  # not implemented in pure
+self.assertEqual(index.headrevs(), [0])  # gave ValueError
  
  Explanation: the C version would allow either -1 or actual length, the pure 
version just allows -1. The pure version does not have algorithms such as 
`headrevs`, they are implemented in revlog.py
  
  I can redo that cleanly, just tell me the expected way.

REPOSITORY
  rHG Mercurial

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

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

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


D7595: status: outputting structured unfinished-operation information

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
Closed by commit rHGaac921f54554: status: outputting structured 
unfinished-operation information (authored by rdamazio).
This revision was automatically updated to reflect the committed changes.

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D7595?vs=18638&id=18639#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7595?vs=18638&id=18639

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

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  tests/test-conflict.t
  tests/test-status.t

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -254,35 +254,43 @@
   $ hg status -A -Tjson
   [
{
+"itemtype": "file",
 "path": "added",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "copied",
 "source": "modified",
 "status": "A"
},
{
+"itemtype": "file",
 "path": "removed",
 "status": "R"
},
{
+"itemtype": "file",
 "path": "deleted",
 "status": "!"
},
{
+"itemtype": "file",
 "path": "unknown",
 "status": "?"
},
{
+"itemtype": "file",
 "path": "ignored",
 "status": "I"
},
{
+"itemtype": "file",
 "path": ".hgignore",
 "status": "C"
},
{
+"itemtype": "file",
 "path": "modified",
 "status": "C"
}
@@ -558,6 +566,7 @@
   $ hg status --config ui.formatdebug=True --rev 1 1
   status = [
   {
+  'itemtype': 'file',
   'path': '1/2/3/4/5/b.txt',
   'status': 'R'
   },
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -63,13 +63,20 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
+   },
+   {
+"itemtype": "morestatus",
+"unfinished": "merge",
+"unfinishedmsg": "To continue:hg commit\nTo abort:   hg merge 
--abort"
}
   ]
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6884,7 +6884,7 @@
 for f in files:
 fm.startitem()
 fm.context(ctx=ctx2)
-fm.data(path=f)
+fm.data(itemtype=b'file', path=f)
 fm.condwrite(showchar, b'status', b'%s ', char, label=label)
 fm.plain(fmt % uipathfn(f), label=label)
 if f in copy:
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -793,6 +793,13 @@
 fm.data(unresolved=True)
 
 def formatfooter(self, fm):
+fm.startitem()
+fm.data(
+itemtype=b'morestatus',
+unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg,
+)
+
 statemsg = (
 _(b'The repository is in an unfinished *%s* state.')
 % self.unfinishedop



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


D7610: rust-threads: force Rayon to respect the worker count in config

2019-12-12 Thread Raphaël Gomès
Alphare added a comment.


  This entire series is a graft of existing changesets onto stable, to fix the 
current CI for the Rust module policy.

REPOSITORY
  rHG Mercurial

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

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

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


Re: [PATCH 1 of 5 STABLE] rust-threads: force Rayon to respect the worker count in config

2019-12-12 Thread Raphaël Gomès
I'm abandoning this mail series because it was confusing, as the old 
Phabricator revisions are still there. I will re-send through Phabricator.


On 12/12/19 5:46 PM, Raphaël Gomès wrote:

# HG changeset patch
# User Raphaël Gomès 
# Date 1573399814 28800
#  Sun Nov 10 07:30:14 2019 -0800
# Branch stable
# Node ID 36425b06e091f8e6336358dba278ef3804e183fb
# Parent  612b4b63fb2267320f18655c0fa8a675f8fe3939
rust-threads: force Rayon to respect the worker count in config

As per the inline comment, this is a workaround because Rust code does not yet
know how to read config files.

Differential Revision: https://phab.mercurial-scm.org/D7310

diff -r 612b4b63fb22 -r 36425b06e091 mercurial/dirstate.py
--- a/mercurial/dirstate.py Mon Dec 09 12:29:46 2019 +0100
+++ b/mercurial/dirstate.py Sun Nov 10 07:30:14 2019 -0800
@@ -1116,6 +1116,17 @@
  use_rust = False
  
  if use_rust:

+# Force Rayon (Rust parallelism library) to respect the number of
+# workers. This is a temporary workaround until Rust code knows
+# how to read the config file.
+numcpus = self._ui.configint("worker", "numcpus")
+if numcpus is not None:
+encoding.environ.setdefault(b'RAYON_NUM_THREADS', b'%d' % 
numcpus)
+
+workers_enabled = self._ui.configbool("worker", "enabled", True)
+if not workers_enabled:
+encoding.environ[b"RAYON_NUM_THREADS"] = b"1"
+
  (
  lookup,
  modified,
___
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


D7603: cext-revlog: fixed __delitem__ for uninitialized nodetree

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7603#112088 , @gracinet 
wrote:
  
  > Here's a quickfix that works for me for both pure and C
  >
  >   -- a/tests/test-parseindex2.py Thu Dec 05 20:41:23 2019 +0100
  >   +++ b/tests/test-parseindex2.py Thu Dec 12 18:34:28 2019 +0100
  >   @@ -18,6 +18,7 @@
  >node as nodemod,
  >policy,
  >pycompat,
  >   +util,
  >)
  >parsers = policy.importmod('parsers')
  >   @@ -267,11 +268,12 @@
  >appendrev(6)
  >self.assertEqual(len(index), 7)
  >   -del index[1:7]
  >   +del index[1:-1]
  ># assertions that failed before correction
  >self.assertEqual(len(index), 1)  # was 4
  >   -self.assertEqual(index.headrevs(), [0])  # gave ValueError
  >   +if util.safehasattr(index, 'headrevs'):  # not implemented in 
pure
  >   +self.assertEqual(index.headrevs(), [0])  # gave ValueError
  >
  > Explanation: the C version would allow either -1 or actual length, the pure 
version just allows -1. The pure version does not have algorithms such as 
`headrevs`, they are implemented in revlog.py
  > I can redo that cleanly, just tell me the expected way.
  
  Seems fine to just send that as a regular patch. It's too late to amend this 
one now. Thanks.

REPOSITORY
  rHG Mercurial

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

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

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


D7506: phabricator: add a "phabstatus" show view

2019-12-12 Thread spectral (Kyle Lippincott)
spectral added a comment.


  In D7506#111966 , @dlax wrote:
  
  > In D7506#111947 , @spectral 
wrote:
  >
  >> I don't think `from . import show` works generally.
  >
  > I did that because `test-check-module-imports.t` complained otherwise when 
using `from hgext import show`:
  >
  >   hgext/phabricator.py:89: import should be relative: hgext
  >
  > Also, there's already a similar `from . import rebase` in `hgext/split.py` 
so I thought that relative import was fine.
  > I'm happy to change if there's a solution, though.
  
  The normal solution is to just load the extension (I think that's what evolve 
does, since it has a hard dependency on rebase functionality), or to configure 
an `extensions.afterloaded()` (which won't be called if the extension isn't 
loaded, or is loaded with a non-standard name), but I think this probably isn't 
a huge deal... I'm only importing via weird syntax because the phabricator 
extension didn't previously get installed on my machine, but now it is part of 
the installation so I can just use the normal syntax. It's also a 
developer/advanced feature, so I don't think this will cause many problems.
  
  The only thing I'm concerned about is cargo culting... this is more evidence 
that this is an acceptable practice, but that's probably already too late 
(there's stuff in mercurial/configitems.py that says that things like shelve 
might already be doing something similar (also to the rebase extension), and as 
you said, split is already doing this).
  
  Sorry for not realizing that my method of importing the extension was 
outdated/unnecessary/odd before my message implying you needed to make a change 
here - hopefully you didn't spend too much time on it.

REPOSITORY
  rHG Mercurial

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

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

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


D7616: exchange: ensure all outgoing subrepo references are present before pushing

2019-12-12 Thread mharbison72 (Matt Harbison)
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We've run into occasional problems with people committing a repo, and then
  amending or rebasing in the subrepo.  That makes it so that the revision in 
the
  parent can't be checked out, and the problem gets propagated on push.  
Mercurial
  already tries to defend against this sort of dangling reference by pushing 
*all*
  subrepo revisions first.  This reuses the checks that trigger warnings in
  `hg verify` to bail on the push unless using `--force`.
  
  I thought about putting this on the server side, but at that point, all of the
  data has been transferred, only to bail out.  Additionally, SCM Manager hosts
  subrepos in a location that isn't nested in the parent, so normal subrepo code
  would complain that the subrepo is missing when run on the server.
  
  Because the push command pushes subrepos before calling this exchange code, a
  subrepo will be pushed before the parent is verified.  Not great, but no
  dangling references are exchanged, so it solves the problem.  This code isn't 
in
  the loop that pushes the subrepos because:
  
  1. the list of outgoing revisions is needed to limit the scope of the check
  2. the loop only accesses the current revision, and therefore can miss 
subrepos that were dropped in previous commits
  3. this code is called when pushing a subrepo, so the protection is recursive
  
  I'm not sure if there's a cheap check for the list of files in the outgoing
  bundle.  If there is, that would provide a fast path to bypass this check for
  people not using subrepos (or if no subrepo changes were made).  There's
  probably also room for verifying other references like tags.  But since that
  doesn't break checkouts, it's much less of a problem.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/subrepo.py
  tests/test-amend-subrepo.t

CHANGE DETAILS

diff --git a/tests/test-amend-subrepo.t b/tests/test-amend-subrepo.t
--- a/tests/test-amend-subrepo.t
+++ b/tests/test-amend-subrepo.t
@@ -164,4 +164,35 @@
   R .hgsub
   R .hgsubstate
 
+broken repositories will refuse to push
+
+#if obsstore-off
+  $ hg up -q -C 2
+#else
+  $ hg up -q -C 6
+#endif
+  $ echo c >> t/b
+  $ hg amend -q -R t
+
+  $ hg init ../dest
+  $ hg init ../dest/t
+  $ hg init ../dest/s
+  $ hg push -q ../dest
+  abort: subrepo 't' is hidden in revision 04aa62396ec6 (obsstore-on !)
+  abort: subrepo 't' not found in revision 04aa62396ec6 (obsstore-off !)
+  [255]
+
+... unless forced
+
+  $ hg push --force -q ../dest
+  $ hg verify -R ../dest
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  checked 5 changesets with 12 changes to 4 files
+  checking subrepo links
+  subrepo 't' not found in revision 04aa62396ec6
+  subrepo 't' not found in revision 6bce99600681
+
   $ cd ..
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -429,10 +429,12 @@
 convert this repository from shared to normal storage.
 '''
 
-def verify(self):
-'''verify the integrity of the repository.  Return 0 on success or
-warning, 1 on any error.
-'''
+def verify(self, onpush=False):
+"""verify the revision of this repository that is held in `_state` is
+present and not hidden.  Return 0 on success or warning, 1 on any
+error.  In the case of ``onpush``, warnings or errors will raise an
+exception if the result of pushing would be a broken remote repository.
+"""
 return 0
 
 @propertycache
@@ -1013,26 +1015,35 @@
 
 hg.unshare(self.ui, self._repo)
 
-def verify(self):
+def verify(self, onpush=False):
 try:
 rev = self._state[1]
 ctx = self._repo.unfiltered()[rev]
 if ctx.hidden():
 # Since hidden revisions aren't pushed/pulled, it seems worth 
an
 # explicit warning.
-ui = self._repo.ui
-ui.warn(
-_(b"subrepo '%s' is hidden in revision %s\n")
-% (self._relpath, node.short(self._ctx.node()))
+msg = _(b"subrepo '%s' is hidden in revision %s") % (
+self._relpath,
+node.short(self._ctx.node()),
 )
+
+if onpush:
+raise error.Abort(msg)
+else:
+self._repo.ui.warn(b'%s\n' % msg)
 return 0
 except error.RepoLookupError:
 # A missing subrepo revision may be a case of needing to pull it, 
so
-# don't treat this as an error.
-self._repo.ui.warn(
-_(b"subrepo '%s' not found in revision %s\n")
-% (self._relpa

D7576: hg-core: add configparser to library

2019-12-12 Thread Raphaël Gomès
Alphare added inline comments.

INLINE COMMENTS

> Alphare wrote in Cargo.toml:14
> I wonder about this dependency. It uses 4 `usize` for every slice of bytes, 
> and adds some overhead, albeit minimal, that I am trying to justify.
> Are we looking at reaping the benefits down the line? The crate itself is 
> good quality, maintained by the Tokio people, so I'm not *too* worried about 
> it being pre-1.0, but do we need this?

I know it doesn't matter at all, but the timing of this issue is just too funny 
not to share: https://github.com/tokio-rs/bytes/issues/340

REPOSITORY
  rHG Mercurial

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

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

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


D7570: match: resolve filesets against the passed `cwd`, not the current one

2019-12-12 Thread hooper (Danny Hooper)
hooper added inline comments.

INLINE COMMENTS

> martinvonz wrote in test-fix.t:1336-1342
> > `.::` doesn't include fixing wdir()
> 
> Yes, that's how revsets work (as you noted)
> 
> > `.` isn't updated unless `-w` is specified
> 
> Yes, because otherwise the working directory would appear to undo the 
> formatting changes. I don't remember why we don't just always format the 
> working directory when we format the parent of the working directory. I'm 
> sure @hooper remembers the reasoning better.
> 
> > `-w` doesn't alter `wdir()` content unless there are dirty files (makes 
> > sense), but will update `.` if starting with a clean `wdir()`
> 
> Do you mean with *just* `-w`? That shouldn't change any commits, so it seems 
> very weird if it checks out a different commit. If you meant something like 
> `-w -r .`, then that *would* format the working copy too, but it may not seem 
> like it if the working copy was clean before and after the command (but it 
> was formatted to match the parent commit).

Martin and I talked about this, and I think it would make sense to:

1. Update/fix the wdir when the parent is fixed without -w, unless the wdir has 
uncommitted changes. We want to avoid triggering any merges, or clobbering 
uncommitted changes unless asked to. "Eating uncommitted data" is a very easy 
mistake to make when writing a config for hg fix, or when the formatter has a 
bug, etc.
2. Add a --source/-s flag to hg fix, where "-s foo" means "-r (foo)::" or "-r 
(foo):: -w" depending on whether "." is contained in "(foo)::". Similar to 
rebase.
3. Maybe remove the -r flag since it's a bit of a footgun.
4. Alternatively, keep the -r flag and make merges smart enough that "hg 
evolve" can apply formatters when that makes sense as a cleanup for "foo~-1" 
after "hg fix -r foo".

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7617: fix: make example fix hgrc work in subdirs

2019-12-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Filesets are relative to the current working directory by default, so we use
  rootglob: to change this behavior.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/examples/fix.hgrc

CHANGE DETAILS

diff --git a/contrib/examples/fix.hgrc b/contrib/examples/fix.hgrc
--- a/contrib/examples/fix.hgrc
+++ b/contrib/examples/fix.hgrc
@@ -1,9 +1,8 @@
 [fix]
-clang-format:command = clang-format --style file -i
-clang-format:pattern = (**.c or **.cc or **.h) and not 
"listfile:contrib/clang-format-ignorelist"
+clang-format:pattern = (rootglob:**.c or rootglob:**.cc or rootglob:**.h) and 
not "listfile:contrib/clang-format-ignorelist"
 
 rustfmt:command = rustfmt
-rustfmt:pattern = set:**.rs
+rustfmt:pattern = set:rootglob:**.rs
 
 black:command = black --config=black.toml -
-black:pattern = set:**.py - mercurial/thirdparty/** - 
"contrib/python-zstandard/**"
+black:pattern = set:rootglob:**.py - rootglob:mercurial/thirdparty/** - 
"rootglob:contrib/python-zstandard/**"



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


D7619: fix: convert clang-format-ignorelist to use wildcards

2019-12-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It's very brittle to specify the exact filenames for these vendored/thirdparty
  libraries; when there's an upgrade, it's likely not going to be updated.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/clang-format-ignorelist

CHANGE DETAILS

diff --git a/contrib/clang-format-ignorelist b/contrib/clang-format-ignorelist
--- a/contrib/clang-format-ignorelist
+++ b/contrib/clang-format-ignorelist
@@ -3,100 +3,9 @@
 mercurial/cext/manifest.c
 mercurial/cext/osutil.c
 # Vendored code that we should never format:
-contrib/python-zstandard/c-ext/bufferutil.c
-contrib/python-zstandard/c-ext/compressionchunker.c
-contrib/python-zstandard/c-ext/compressiondict.c
-contrib/python-zstandard/c-ext/compressionparams.c
-contrib/python-zstandard/c-ext/compressionreader.c
-contrib/python-zstandard/c-ext/compressionwriter.c
-contrib/python-zstandard/c-ext/compressobj.c
-contrib/python-zstandard/c-ext/compressor.c
-contrib/python-zstandard/c-ext/compressoriterator.c
-contrib/python-zstandard/c-ext/constants.c
-contrib/python-zstandard/c-ext/decompressionreader.c
-contrib/python-zstandard/c-ext/decompressionwriter.c
-contrib/python-zstandard/c-ext/decompressobj.c
-contrib/python-zstandard/c-ext/decompressor.c
-contrib/python-zstandard/c-ext/decompressoriterator.c
-contrib/python-zstandard/c-ext/frameparams.c
-contrib/python-zstandard/c-ext/python-zstandard.h
-contrib/python-zstandard/zstd.c
-contrib/python-zstandard/zstd/common/bitstream.h
-contrib/python-zstandard/zstd/common/compiler.h
-contrib/python-zstandard/zstd/common/cpu.h
-contrib/python-zstandard/zstd/common/debug.c
-contrib/python-zstandard/zstd/common/debug.h
-contrib/python-zstandard/zstd/common/entropy_common.c
-contrib/python-zstandard/zstd/common/error_private.c
-contrib/python-zstandard/zstd/common/error_private.h
-contrib/python-zstandard/zstd/common/fse_decompress.c
-contrib/python-zstandard/zstd/common/fse.h
-contrib/python-zstandard/zstd/common/huf.h
-contrib/python-zstandard/zstd/common/mem.h
-contrib/python-zstandard/zstd/common/pool.c
-contrib/python-zstandard/zstd/common/pool.h
-contrib/python-zstandard/zstd/common/threading.c
-contrib/python-zstandard/zstd/common/threading.h
-contrib/python-zstandard/zstd/common/xxhash.c
-contrib/python-zstandard/zstd/common/xxhash.h
-contrib/python-zstandard/zstd/common/zstd_common.c
-contrib/python-zstandard/zstd/common/zstd_errors.h
-contrib/python-zstandard/zstd/common/zstd_internal.h
-contrib/python-zstandard/zstd/compress/fse_compress.c
-contrib/python-zstandard/zstd/compress/hist.c
-contrib/python-zstandard/zstd/compress/hist.h
-contrib/python-zstandard/zstd/compress/huf_compress.c
-contrib/python-zstandard/zstd/compress/zstd_compress.c
-contrib/python-zstandard/zstd/compress/zstd_compress_internal.h
-contrib/python-zstandard/zstd/compress/zstd_compress_literals.c
-contrib/python-zstandard/zstd/compress/zstd_compress_literals.h
-contrib/python-zstandard/zstd/compress/zstd_compress_sequences.c
-contrib/python-zstandard/zstd/compress/zstd_compress_sequences.h
-contrib/python-zstandard/zstd/compress/zstd_double_fast.c
-contrib/python-zstandard/zstd/compress/zstd_double_fast.h
-contrib/python-zstandard/zstd/compress/zstd_fast.c
-contrib/python-zstandard/zstd/compress/zstd_fast.h
-contrib/python-zstandard/zstd/compress/zstd_lazy.c
-contrib/python-zstandard/zstd/compress/zstd_lazy.h
-contrib/python-zstandard/zstd/compress/zstd_ldm.c
-contrib/python-zstandard/zstd/compress/zstd_ldm.h
-contrib/python-zstandard/zstd/compress/zstdmt_compress.c
-contrib/python-zstandard/zstd/compress/zstdmt_compress.h
-contrib/python-zstandard/zstd/compress/zstd_opt.c
-contrib/python-zstandard/zstd/compress/zstd_opt.h
-contrib/python-zstandard/zstd/decompress/huf_decompress.c
-contrib/python-zstandard/zstd/decompress/zstd_ddict.c
-contrib/python-zstandard/zstd/decompress/zstd_ddict.h
-contrib/python-zstandard/zstd/decompress/zstd_decompress_block.c
-contrib/python-zstandard/zstd/decompress/zstd_decompress_block.h
-contrib/python-zstandard/zstd/decompress/zstd_decompress_internal.h
-contrib/python-zstandard/zstd/decompress/zstd_decompress.c
-contrib/python-zstandard/zstd/deprecated/zbuff_common.c
-contrib/python-zstandard/zstd/deprecated/zbuff_compress.c
-contrib/python-zstandard/zstd/deprecated/zbuff_decompress.c
-contrib/python-zstandard/zstd/deprecated/zbuff.h
-contrib/python-zstandard/zstd/dictBuilder/cover.c
-contrib/python-zstandard/zstd/dictBuilder/cover.h
-contrib/python-zstandard/zstd/dictBuilder/divsufsort.c
-contrib/python-zstandard/zstd/dictBuilder/divsufsort.h
-contrib/python-zstandard/zstd/dictBuilder/fastcover.c
-contrib/python-zstandard/zstd/dictBuilder/zdict.c
-contrib/python-zstandard/zstd/dictBuilder/zdict.h
-contrib/python-zstandard/zstd/zstd.h
-hgext/fsmonitor/pywatchman/bser.c
-mercurial/thirdpar

D7618: fix: correct the clang-format example hgrc so that it actually works

2019-12-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  There are three changes here:
  
  - Remove -i from `command`, it causes fix to eat your file and empty it out
  - Add `set:` to pattern, otherwise this is interpreted as just a glob
  - Switch `listfile:` to `include:`; `listfile:` is relative to the current 
working directory, while `include:` is relative to the repo root. This makes it 
so that you don't receive errors when running outside of the repo root about 
being unable to find the file.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  contrib/examples/fix.hgrc

CHANGE DETAILS

diff --git a/contrib/examples/fix.hgrc b/contrib/examples/fix.hgrc
--- a/contrib/examples/fix.hgrc
+++ b/contrib/examples/fix.hgrc
@@ -1,5 +1,6 @@
 [fix]
-clang-format:pattern = (rootglob:**.c or rootglob:**.cc or rootglob:**.h) and 
not "listfile:contrib/clang-format-ignorelist"
+clang-format:command = clang-format --style file
+clang-format:pattern = set:(rootglob:**.c or rootglob:**.cc or rootglob:**.h) 
and not "include:contrib/clang-format-ignorelist"
 
 rustfmt:command = rustfmt
 rustfmt:pattern = set:rootglob:**.rs



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


D7620: merge: add commands.merge.require-rev to require an argument to hg merge

2019-12-12 Thread spectral (Kyle Lippincott)
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is related to commands.rebase.requiredest, commands.update.requiredest, 
and
  commands.push.require-revs. Since it isn't really a "destination", I went with
  require-rev to be similar to push's require-revs.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  tests/test-merge-default.t
  tests/test-merge-tools.t

CHANGE DETAILS

diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -4,6 +4,8 @@
   $ cat >> $HGRCPATH << EOF
   > [ui]
   > merge=
+  > [commands]
+  > merge.require-rev=True
   > EOF
   $ hg init repo
   $ cd repo
@@ -1908,6 +1910,7 @@
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to 
abandon
   [1]
+(Testing that commands.merge.require-rev doesn't break --abort)
   $ hg merge --abort -q
 
 (for ui.merge, ignored unintentionally)
diff --git a/tests/test-merge-default.t b/tests/test-merge-default.t
--- a/tests/test-merge-default.t
+++ b/tests/test-merge-default.t
@@ -44,9 +44,10 @@
   (run 'hg heads .' to see heads, specify rev with -r)
   [255]
 
-Should succeed:
+Should succeed (we're specifying commands.merge.require-rev=True just to test
+that it allows merge to succeed if we specify a revision):
 
-  $ hg merge 2
+  $ hg merge 2 --config commands.merge.require-rev=True
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ hg id -Tjson
@@ -63,6 +64,13 @@
   ]
   $ hg commit -mm1
 
+Should fail because we didn't specify a revision (even though it would have
+succeeded without this):
+
+  $ hg merge --config commands.merge.require-rev=True
+  abort: configuration requires specifying revision to merge with
+  [255]
+
 Should succeed - 2 heads:
 
   $ hg merge -P
@@ -88,6 +96,13 @@
}
   ]
 
+Should fail because we didn't specify a revision (even though it would have
+failed without this due to being on tip, but this check comes first):
+
+  $ hg merge --config commands.merge.require-rev=True
+  abort: configuration requires specifying revision to merge with
+  [255]
+
 Should fail because at tip:
 
   $ hg merge
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -228,6 +228,9 @@
 b'commands', b'grep.all-files', default=False, experimental=True,
 )
 coreconfigitem(
+b'commands', b'merge.require-rev', default=False,
+)
+coreconfigitem(
 b'commands', b'push.require-revs', default=False,
 )
 coreconfigitem(
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4888,6 +4888,13 @@
 node = scmutil.revsingle(repo, node).node()
 
 if not node and not abort:
+if ui.configbool(b'commands', b'merge.require-rev'):
+raise error.Abort(
+_(
+b'configuration requires specifying revision to merge '
+b'with'
+)
+)
 node = repo[destutil.destmerge(repo)].node()
 
 if opts.get(b'preview'):



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


D7617: fix: make example fix hgrc work in subdirs

2019-12-12 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  See D7065  and D7570 
.  I didn't realize you could stack 
`set:` and the other patterns like this.

REPOSITORY
  rHG Mercurial

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

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

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


D7621: pycompat: allow pycompat.sysbytes() even if input already is bytes

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  pycompat.sysstr() on py3 accepts an input that's already str
  (i.e. unicode). This patch makes it so pycompat.sysbytes() on py3
  accepts an input that's already bytes. Allowing that makes it possible
  to do pycompat.sysbytes(fp.name) where fp.name is either bytes or
  unicode, as we'll get when fp can come from either open() or
  resources.open_binary().

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/pycompat.py

CHANGE DETAILS

diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -253,6 +253,8 @@
 This never raises UnicodeEncodeError, but only ASCII characters
 can be round-trip by sysstr(sysbytes(s)).
 """
+if isinstance(s, bytes):
+return s
 return s.encode('utf-8')
 
 def sysstr(s):



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


D7623: tests: make test-config-env.py a little less hacky

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Overriding os.path.isdir to always returns False is very
  confusing. Let's make it more explicit by specifically not returning
  any defaultrc/ configs.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  tests/test-config-env.py

CHANGE DETAILS

diff --git a/tests/test-config-env.py b/tests/test-config-env.py
--- a/tests/test-config-env.py
+++ b/tests/test-config-env.py
@@ -6,6 +6,7 @@
 
 from mercurial import (
 encoding,
+extensions,
 rcutil,
 ui as uimod,
 util,
@@ -35,9 +36,10 @@
 return [join(b'userrc')]
 
 
+extensions.wrapfunction(rcutil, 'defaultrcpath', lambda orig: [])
+
 rcutil.systemrcpath = systemrcpath
 rcutil.userrcpath = userrcpath
-os.path.isdir = lambda x: False  # hack: do not load default.d/*.rc
 
 # utility to print configs
 def printconfigs(env):



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


D7624: rcutil: don't check if defaultrc/ is a directory -- we know it is

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rcutil.py

CHANGE DETAILS

diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -63,11 +63,8 @@
 
 def defaultrcpath():
 '''return rc paths in defaultrc'''
-path = []
 defaultpath = os.path.join(resourceutil.datapath, b'defaultrc')
-if os.path.isdir(defaultpath):
-path = _expandrcpath(defaultpath)
-return path
+return _expandrcpath(defaultpath)
 
 
 def rccomponents():



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


D7622: help: get helptext/ data from `resources` module if available

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  For PyOxidizer, we need to read configs using the `resources`
  module. This patch makes it so we use that if available (i.e. Python
  
  > 3.7). It does that by adding a new `open_resource()` function to
  > 
  
  our `resourceutil` module.
  
  Tested by running `$PYTHON ./hg help pager` for each $PYTHON in
  {python2, python3.6, python3.7}.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/defaultrc/__init__.py
  mercurial/help.py
  mercurial/utils/resourceutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py
--- a/mercurial/utils/resourceutil.py
+++ b/mercurial/utils/resourceutil.py
@@ -35,3 +35,25 @@
 datapath = os.path.dirname(pycompat.sysexecutable)
 else:
 datapath = os.path.dirname(os.path.dirname(pycompat.fsencode(__file__)))
+
+try:
+import importlib
+
+# Force loading of the resources module
+importlib.resources.open_binary
+
+def open_resouce(package, name):
+package = b'mercurial.' + package
+return importlib.resources.open_binary(
+pycompat.sysstr(package), pycompat.sysstr(name)
+)
+
+
+except AttributeError:
+
+def _package_path(package):
+return os.path.join(datapath, *package.split(b'.'))
+
+def open_resouce(package, name):
+path = os.path.join(_package_path(package), name)
+return open(path, 'rb')
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -8,7 +8,6 @@
 from __future__ import absolute_import
 
 import itertools
-import os
 import re
 import textwrap
 
@@ -314,11 +313,11 @@
 """Return a delayed loader for help/topic.txt."""
 
 def loader(ui):
-docdir = os.path.join(resourceutil.datapath, b'helptext')
+package = b'helptext'
 if subdir:
-docdir = os.path.join(docdir, subdir)
-path = os.path.join(docdir, topic + b".txt")
-doc = gettext(util.readfile(path))
+package = b'helptext' + b'.' + subdir
+with resourceutil.open_resouce(package, topic + b'.txt') as fp:
+doc = gettext(fp.read())
 for rewriter in helphooks.get(topic, []):
 doc = rewriter(ui, topic, doc)
 return doc
diff --git a/mercurial/defaultrc/__init__.py b/mercurial/defaultrc/__init__.py
new file mode 100644



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


D7628: config: move reading of defaultrc/ files from ui to rcutil

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  For PyOxidizer, we'll need to read the default configs using the
  `resources` module. This prepares for putting that call in rcutil.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rcutil.py

CHANGE DETAILS

diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -10,6 +10,7 @@
 import os
 
 from . import (
+config,
 encoding,
 pycompat,
 util,
@@ -90,10 +91,20 @@
 continue
 _rccomponents.extend((b'path', p) for p in _expandrcpath(p))
 else:
+default_entries = []
+for path in defaultrcpath():
+cfg = config.config()
+cfg.read(path)
+for section in cfg:
+for name, value in cfg.items(section):
+source = cfg.source(section, name)
+default_entries.append((section, name, value, source))
+_rccomponents = [(b'items', default_entries)]
+
 normpaths = lambda paths: [
 (b'path', os.path.normpath(p)) for p in paths
 ]
-_rccomponents = normpaths(defaultrcpath() + systemrcpath())
+_rccomponents.extend(normpaths(systemrcpath()))
 _rccomponents.append(envrc)
 _rccomponents.extend(normpaths(userrcpath()))
 return _rccomponents



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


D7629: config: read defaultrc/ using `resources` module if available

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Similar to the an earlier patch for `hg help`. Here we also needed a
  way of listing resources/files in a package/directory, so I added that
  to the resourceutil module.
  
  Tested by running `$PYTHON ./hg config --debug` for each $PYTHON in
  {python2, python3.6, python3.7}.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/rcutil.py
  mercurial/utils/resourceutil.py
  tests/test-config-env.py

CHANGE DETAILS

diff --git a/tests/test-config-env.py b/tests/test-config-env.py
--- a/tests/test-config-env.py
+++ b/tests/test-config-env.py
@@ -13,6 +13,7 @@
 )
 
 from mercurial.utils import procutil
+from mercurial.utils import resourceutil
 
 testtmp = encoding.environ[b'TESTTMP']
 
@@ -36,7 +37,13 @@
 return [join(b'userrc')]
 
 
-extensions.wrapfunction(rcutil, 'defaultrcpath', lambda orig: [])
+def list_resources(orig, package):
+if package != b'defaultrc':
+for name in orig(package):
+yield name
+
+
+extensions.wrapfunction(resourceutil, 'list_resources', list_resources)
 
 rcutil.systemrcpath = systemrcpath
 rcutil.userrcpath = userrcpath
diff --git a/mercurial/utils/resourceutil.py b/mercurial/utils/resourceutil.py
--- a/mercurial/utils/resourceutil.py
+++ b/mercurial/utils/resourceutil.py
@@ -11,9 +11,15 @@
 
 import imp
 import os
+import stat as statmod
 import sys
 
-from .. import pycompat
+from .. import (
+policy,
+pycompat,
+)
+
+osutil = policy.importmod('osutil')
 
 
 def mainfrozen():
@@ -48,6 +54,12 @@
 pycompat.sysstr(package), pycompat.sysstr(name)
 )
 
+def list_resources(package):
+package = b'mercurial.' + package
+for name in importlib.resources.contents(pycompat.sysstr(package)):
+if importlib.resources.is_resource(pycompat.sysstr(package), name):
+yield pycompat.sysbytes(name)
+
 
 except AttributeError:
 
@@ -57,3 +69,8 @@
 def open_resouce(package, name):
 path = os.path.join(_package_path(package), name)
 return open(path, 'rb')
+
+def list_resources(package):
+for name, kind in osutil.listdir(_package_path(package)):
+if kind == statmod.S_IFREG:
+yield name
diff --git a/mercurial/rcutil.py b/mercurial/rcutil.py
--- a/mercurial/rcutil.py
+++ b/mercurial/rcutil.py
@@ -62,12 +62,6 @@
 return result
 
 
-def defaultrcpath():
-'''return rc paths in defaultrc'''
-defaultpath = os.path.join(resourceutil.datapath, b'defaultrc')
-return _expandrcpath(defaultpath)
-
-
 def rccomponents():
 '''return an ordered [(type, obj)] about where to load configs.
 
@@ -92,13 +86,16 @@
 _rccomponents.extend((b'path', p) for p in _expandrcpath(p))
 else:
 default_entries = []
-for path in defaultrcpath():
-cfg = config.config()
-cfg.read(path)
-for section in cfg:
-for name, value in cfg.items(section):
-source = cfg.source(section, name)
-default_entries.append((section, name, value, source))
+for name in resourceutil.list_resources(b'defaultrc'):
+if not name.endswith(b'.rc'):
+continue
+with resourceutil.open_resouce(b'defaultrc', name) as fp:
+cfg = config.config()
+cfg.read(pycompat.sysbytes(fp.name), fp=fp)
+for section in cfg:
+for name, value in cfg.items(section):
+source = cfg.source(section, name)
+default_entries.append((section, name, value, source))
 _rccomponents = [(b'items', default_entries)]
 
 normpaths = lambda paths: [



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


D7626: config: close file even if we fail to read it

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If we get an exception from cfg.read(), we would not close the file
  before this patch. This patch uses a context manager to make sure we
  close it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -434,16 +434,16 @@
 return
 raise
 
-cfg = config.config()
-trusted = sections or trust or self._trusted(fp, filename)
+with fp:
+cfg = config.config()
+trusted = sections or trust or self._trusted(fp, filename)
 
-try:
-cfg.read(filename, fp, sections=sections, remap=remap)
-fp.close()
-except error.ParseError as inst:
-if trusted:
-raise
-self.warn(_(b"ignored: %s\n") % stringutil.forcebytestr(inst))
+try:
+cfg.read(filename, fp, sections=sections, remap=remap)
+except error.ParseError as inst:
+if trusted:
+raise
+self.warn(_(b'ignored: %s\n') % stringutil.forcebytestr(inst))
 
 if self.plain():
 for k in (



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


D7625: config: catch intended exception when failing to parse config

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When a new config parser was introduced in fca54469480e 
 
(ui: introduce
  new config parser, 2009-04-23), the reading side would raise a
  ConfigError which was then caught in the ui code. Then, in
  2123aad24d56 
 
(error: add new ParseError for various parsing errors,
  2010-06-04), a ParseError was raised instead, but the call site was
  not updated. Let's start catching that ParseError. We still don't
  print it in a friendly way, but that's not worse than before.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/ui.py
  tests/test-trusted.py.out

CHANGE DETAILS

diff --git a/tests/test-trusted.py.out b/tests/test-trusted.py.out
--- a/tests/test-trusted.py.out
+++ b/tests/test-trusted.py.out
@@ -174,7 +174,7 @@
 # parse error
 # different user, different group
 not trusting file .hg/hgrc from untrusted user abc, group def
-ParseError('foo', '.hg/hgrc:1')
+ignored: ('foo', '.hg/hgrc:1')
 # same user, same group
 ParseError('foo', '.hg/hgrc:1')
 
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -440,7 +440,7 @@
 try:
 cfg.read(filename, fp, sections=sections, remap=remap)
 fp.close()
-except error.ConfigError as inst:
+except error.ParseError as inst:
 if trusted:
 raise
 self.warn(_(b"ignored: %s\n") % stringutil.forcebytestr(inst))



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


D7627: config: drop debug messages saying where config was read from

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  `hg config --debug` includes lines like this:
  
read config from: /etc/mercurial/hgrc.d/hgkpath.rc
set config by: $EDITOR
  
  but also lines like this:
  
/etc/mercurial/hgrc.d/hgkpath.rc:2: hgk.path=/usr/share/mercurial/hgk
$EDITOR: ui.editor=emacs -nw
  
  The first type of output doesn't seem to provide much additional
  information over what we get from the second type. I could imagine
  wanting to see which values got overriden by a later entry, but that
  information is already not present. So let's just remove the first
  type of output. My next patch would otherwise amplify the redundant
  output.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

CHANGE DETAILS

diff --git a/tests/test-hgrc.t b/tests/test-hgrc.t
--- a/tests/test-hgrc.t
+++ b/tests/test-hgrc.t
@@ -170,7 +170,6 @@
 customized hgrc
 
   $ hg showconfig
-  read config from: $TESTTMP/hgrc
   $TESTTMP/hgrc:13: alias.log=log -g
   repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:11: defaults.identify=-n
@@ -187,7 +186,6 @@
 
   $ HGPLAIN=; export HGPLAIN
   $ hg showconfig --config ui.traceback=True --debug
-  read config from: $TESTTMP/hgrc
   repo: bundle.mainreporoot=$TESTTMP
   --config: ui.traceback=True
   --verbose: ui.verbose=False
@@ -197,10 +195,6 @@
 with environment variables
 
   $ PAGER=p1 EDITOR=e1 VISUAL=e2 hg showconfig --debug
-  set config by: $EDITOR
-  set config by: $VISUAL
-  set config by: $PAGER
-  read config from: $TESTTMP/hgrc
   repo: bundle.mainreporoot=$TESTTMP
   $PAGER: pager.pager=p1
   $VISUAL: ui.editor=e2
@@ -223,7 +217,6 @@
   $ HGPLAINEXCEPT=; export HGPLAINEXCEPT
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
-  read config from: $TESTTMP/hgrc
   repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
   --config: ui.traceback=True
@@ -233,7 +226,6 @@
   $ unset HGPLAIN
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
-  read config from: $TESTTMP/hgrc
   repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
   --config: ui.traceback=True
@@ -243,7 +235,6 @@
   $ HGPLAINEXCEPT=i18n; export HGPLAINEXCEPT
   $ hg showconfig --config ui.traceback=True --debug
   plain: True
-  read config from: $TESTTMP/hgrc
   repo: bundle.mainreporoot=$TESTTMP
   $TESTTMP/hgrc:15: extensions.plain=./plain.py
   --config: ui.traceback=True
@@ -259,5 +250,4 @@
   > EOF
   $ hg showconfig --debug paths
   plain: True
-  read config from: $TESTTMP/hgrc
   $TESTTMP/hgrc:17: paths.foo=$TESTTMP/bar
diff --git a/tests/test-config.t b/tests/test-config.t
--- a/tests/test-config.t
+++ b/tests/test-config.t
@@ -266,7 +266,6 @@
   > EOF
 
   $ hg config --debug empty.source
-  read config from: * (glob)
   none: value
   $ hg config empty.source -Tjson
   [
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2228,14 +2228,6 @@
 return
 ui.pager(b'config')
 fm = ui.formatter(b'config', opts)
-for t, f in rcutil.rccomponents():
-if t == b'path':
-ui.debug(b'read config from: %s\n' % f)
-elif t == b'items':
-for section, name, value, source in f:
-ui.debug(b'set config by: %s\n' % source)
-else:
-raise error.ProgrammingError(b'unknown rctype: %s' % t)
 untrusted = bool(opts.get(b'untrusted'))
 
 selsections = selentries = []



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


Re: D7570: match: resolve filesets against the passed `cwd`, not the current one

2019-12-12 Thread Yuya Nishihara
>   > In D7570#111892 , @durin42 
> wrote:
>   >
>   >> I'm happy with this, but didn't spend time figuring out if all concerns 
> have been addressed (I'm mostly doing a fast triage path).
>   >
>   > I *think* they're addressed, but we there's no rush to get this in so 
> let's give Yuya a chance to comment, because I'm not sure if the issue with 
> subrepos is an existing or new issue.
>   
>   @yuja, what do you think?

I'm okay with this, but I would add "# TODO:" comment to subrepo handling
so future readers can see the problem. And one more nit: since `cwd=b''` is
a valid path, we have to test `cwd is None` explicitly.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D7570: match: resolve filesets against the passed `cwd`, not the current one

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


  >   > In D7570#111892 , @durin42 
wrote:
  >   >
  >   >> I'm happy with this, but didn't spend time figuring out if all 
concerns have been addressed (I'm mostly doing a fast triage path).
  >   >
  >   > I *think* they're addressed, but we there's no rush to get this in so 
let's give Yuya a chance to comment, because I'm not sure if the issue with 
subrepos is an existing or new issue.
  >   @yuja, what do you think?
  
  I'm okay with this, but I would add "# TODO:" comment to subrepo handling
  so future readers can see the problem. And one more nit: since `cwd=b''` is
  a valid path, we have to test `cwd is None` explicitly.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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

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


D7617: fix: make example fix hgrc work in subdirs

2019-12-12 Thread spectral (Kyle Lippincott)
spectral added a comment.
spectral planned changes to this revision.


  In D7617#112130 , @mharbison72 
wrote:
  
  > See D7065  and D7570 
.  I didn't realize you could stack 
`set:` and the other patterns like this.
  
  As far as I know, set: isn't a pattern itself, it's a "hey, everything that 
comes after this is a fileset, not a glob".
  
  I'm OK waiting for D7570 , it's the 
main reason I split this out from the other two in this stack, but if we want 
to accept it before D7570  makes it in 
(unsure if it's currently blocked), I'm also OK with that.
  
  I think that the later commits are still useful, though: I don't think D7570 
 deals with `listfile`, and the 
configuration for clang-format is broken in other ways. I'll reorder them so 
this is tip instead of root.

INLINE COMMENTS

> fix.hgrc:2
>  [fix]
> -clang-format:command = clang-format --style file -i
> -clang-format:pattern = (**.c or **.cc or **.h) and not 
> "listfile:contrib/clang-format-ignorelist"

Oops, split failure, this line should remain, I'll send an update.

REPOSITORY
  rHG Mercurial

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

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

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


D7618: fix: correct the clang-format example hgrc so that it actually works

2019-12-12 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 18660.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7618?vs=18648&id=18660

BRANCH
  default

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

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

AFFECTED FILES
  contrib/examples/fix.hgrc

CHANGE DETAILS

diff --git a/contrib/examples/fix.hgrc b/contrib/examples/fix.hgrc
--- a/contrib/examples/fix.hgrc
+++ b/contrib/examples/fix.hgrc
@@ -1,6 +1,6 @@
 [fix]
-clang-format:command = clang-format --style file -i
-clang-format:pattern = (**.c or **.cc or **.h) and not 
"listfile:contrib/clang-format-ignorelist"
+clang-format:command = clang-format --style file
+clang-format:pattern = set:(**.c or **.cc or **.h) and not 
"include:contrib/clang-format-ignorelist"
 
 rustfmt:command = rustfmt
 rustfmt:pattern = set:**.rs



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


D7617: fix: make example fix hgrc work in subdirs

2019-12-12 Thread spectral (Kyle Lippincott)
spectral updated this revision to Diff 18663.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7617?vs=18647&id=18663

BRANCH
  default

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

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

AFFECTED FILES
  contrib/examples/fix.hgrc

CHANGE DETAILS

diff --git a/contrib/examples/fix.hgrc b/contrib/examples/fix.hgrc
--- a/contrib/examples/fix.hgrc
+++ b/contrib/examples/fix.hgrc
@@ -1,9 +1,9 @@
 [fix]
 clang-format:command = clang-format --style file
-clang-format:pattern = set:(**.c or **.cc or **.h) and not 
"include:contrib/clang-format-ignorelist"
+clang-format:pattern = set:(rootglob:**.c or rootglob:**.cc or rootglob:**.h) 
and not "include:contrib/clang-format-ignorelist"
 
 rustfmt:command = rustfmt
-rustfmt:pattern = set:**.rs
+rustfmt:pattern = set:rootglob:**.rs
 
 black:command = black --config=black.toml -
-black:pattern = set:**.py - mercurial/thirdparty/** - 
"contrib/python-zstandard/**"
+black:pattern = set:rootglob:**.py - rootglob:mercurial/thirdparty/** - 
"rootglob:contrib/python-zstandard/**"



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


D7570: match: resolve filesets against the passed `cwd`, not the current one

2019-12-12 Thread mharbison72 (Matt Harbison)
mharbison72 updated this revision to Diff 18664.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7570?vs=18596&id=18664

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

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

AFFECTED FILES
  hgext/highlight/__init__.py
  mercurial/context.py
  mercurial/debugcommands.py
  mercurial/fileset.py
  mercurial/match.py
  mercurial/subrepo.py
  tests/test-fix.t

CHANGE DETAILS

diff --git a/tests/test-fix.t b/tests/test-fix.t
--- a/tests/test-fix.t
+++ b/tests/test-fix.t
@@ -1333,24 +1333,20 @@
 Apparently fixing p1() and its descendants doesn't include wdir() unless
 explicitly stated.
 
-BROKEN: fileset matches aren't relative to repo.root for commits
-
   $ hg fix -r '.::'
   $ hg cat -r . ../quux
   quux
   $ hg cat -r tip ../quux
-  quux
+  fs: $TESTTMP/subprocesscwd
   $ cat ../quux
   quux
 
 Clean files are not fixed unless explicitly named
   $ echo 'dirty' > ../quux
 
-BROKEN: fileset matches aren't relative to repo.root for wdir
-
   $ hg fix --working-dir
   $ cat ../quux
-  dirty
+  fs: $TESTTMP/subprocesscwd
 
   $ cd ../..
 
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -355,7 +355,7 @@
 """return file flags"""
 return b''
 
-def matchfileset(self, expr, badfn=None):
+def matchfileset(self, cwd, expr, badfn=None):
 """Resolve the fileset expression for this repo"""
 return matchmod.never(badfn=badfn)
 
@@ -894,20 +894,20 @@
 return cmdutil.files(ui, ctx, m, uipathfn, fm, fmt, subrepos)
 
 @annotatesubrepoerror
-def matchfileset(self, expr, badfn=None):
+def matchfileset(self, cwd, expr, badfn=None):
 if self._ctx.rev() is None:
 ctx = self._repo[None]
 else:
 rev = self._state[1]
 ctx = self._repo[rev]
 
-matchers = [ctx.matchfileset(expr, badfn=badfn)]
+matchers = [ctx.matchfileset(cwd, expr, badfn=badfn)]
 
 for subpath in ctx.substate:
 sub = ctx.sub(subpath)
 
 try:
-sm = sub.matchfileset(expr, badfn=badfn)
+sm = sub.matchfileset(cwd, expr, badfn=badfn)
 pm = matchmod.prefixdirmatcher(subpath, sm, badfn=badfn)
 matchers.append(pm)
 except error.LookupError:
diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -57,7 +57,7 @@
 return m.match
 
 
-def _expandsets(kindpats, ctx=None, listsubrepos=False, badfn=None):
+def _expandsets(cwd, kindpats, ctx=None, listsubrepos=False, badfn=None):
 '''Returns the kindpats list with the 'set' patterns expanded to 
matchers'''
 matchers = []
 other = []
@@ -68,11 +68,13 @@
 raise error.ProgrammingError(
 b"fileset expression with no context"
 )
-matchers.append(ctx.matchfileset(pat, badfn=badfn))
+matchers.append(ctx.matchfileset(cwd, pat, badfn=badfn))
 
 if listsubrepos:
 for subpath in ctx.substate:
-sm = ctx.sub(subpath).matchfileset(pat, badfn=badfn)
+# TODO: cwd may be relative to the parent's repo.root, and
+#   need to be adjusted.
+sm = ctx.sub(subpath).matchfileset(cwd, pat, badfn=badfn)
 pm = prefixdirmatcher(subpath, sm, badfn=badfn)
 matchers.append(pm)
 
@@ -117,11 +119,11 @@
 
 
 def _buildkindpatsmatcher(
-matchercls, root, kindpats, ctx=None, listsubrepos=False, badfn=None
+matchercls, root, cwd, kindpats, ctx=None, listsubrepos=False, badfn=None,
 ):
 matchers = []
 fms, kindpats = _expandsets(
-kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=badfn
+cwd, kindpats, ctx=ctx, listsubrepos=listsubrepos, badfn=badfn,
 )
 if kindpats:
 m = matchercls(root, kindpats, badfn=badfn)
@@ -256,6 +258,7 @@
 m = _buildkindpatsmatcher(
 patternmatcher,
 root,
+cwd,
 kindpats,
 ctx=ctx,
 listsubrepos=listsubrepos,
@@ -271,6 +274,7 @@
 im = _buildkindpatsmatcher(
 includematcher,
 root,
+cwd,
 kindpats,
 ctx=ctx,
 listsubrepos=listsubrepos,
@@ -282,6 +286,7 @@
 em = _buildkindpatsmatcher(
 includematcher,
 root,
+cwd,
 kindpats,
 ctx=ctx,
 listsubrepos=listsubrepos,
diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -520,29 +520,30 @@
 
 
 class matchctx(object):
-def __init__(self, basectx, ctx, badfn=None):
+def __init__(self, basectx, ctx, cwd, badfn=None):

D7570: match: resolve filesets against the passed `cwd`, not the current one

2019-12-12 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  In D7570#112206 , @yuja wrote:
  
  >>   @yuja, what do you think?
  >
  > I'm okay with this, but I would add "# TODO:" comment to subrepo handling
  > so future readers can see the problem. And one more nit: since `cwd=b''` is
  > a valid path, we have to test `cwd is None` explicitly.
  
  Good catch.  I don't see the meaning of b'' in this context defined anywhere. 
 But since `subinclude:` uses it to define the matcher, I'm assuming that's all 
of the adjustment we need?

REPOSITORY
  rHG Mercurial

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

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

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


D7627: config: drop debug messages saying where config was read from

2019-12-12 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  On Windows, you can set a registry key to one or more *.ini files or 
directories that get read in, so it seems slightly handy to know the order in 
which files are processed.  I know I've used that mechanism on various systems 
to find directories in which to stash things too.
  
  That said, I don't think I feel strongly about keeping it if it makes the 
next patch messy.  (I did a quick skim of it, but didn't see why that would be.)

REPOSITORY
  rHG Mercurial

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

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

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


D7622: help: get helptext/ data from `resources` module if available

2019-12-12 Thread mharbison72 (Matt Harbison)
mharbison72 added inline comments.

INLINE COMMENTS

> resourceutil.py:45
> +
> +def open_resouce(package, name):
> +package = b'mercurial.' + package

s/open_resouce/open_resource/

REPOSITORY
  rHG Mercurial

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

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

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


D7627: config: drop debug messages saying where config was read from

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7627#112220 , @mharbison72 
wrote:
  
  > On Windows, you can set a registry key to one or more *.ini files or 
directories that get read in, so it seems slightly handy to know the order in 
which files are processed.  I know I've used that mechanism on various systems 
to find directories in which to stash things too.
  > That said, I don't think I feel strongly about keeping it if it makes the 
next patch messy.  (I did a quick skim of it, but didn't see why that would be.)
  
  It means that every line in merge-tools.rc would get two lines in this output 
(one line saying "set value from ..." or something like that).

REPOSITORY
  rHG Mercurial

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

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

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


D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When a committed changeset is absorbed, this will make it so it's not used for
  computing the absorption, but is still recreated at the destination.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t

CHANGE DETAILS

diff --git a/tests/test-absorb-rev.t b/tests/test-absorb-rev.t
--- a/tests/test-absorb-rev.t
+++ b/tests/test-absorb-rev.t
@@ -65,26 +65,18 @@
 Run absorb:
 
   $ hg absorb --apply-changes -r .
-  1 new orphan changesets
   2 of 2 chunk(s) applied
 
 Check that the pending wdir change was left alone:
+TODO: The absorbed commit should have disappeared when it became empty.
 
   $ grep 6 a
   6
-  $ hg update -Cq .
-
-Rebase the absorbed revision on top of the destination (as evolve would):
-TODO: the evolve-type operation should happen automatically for the changeset
-being absorbed, and even through that the pending wdir change should be left
-alone.
-
-  $ hg rebase -d tip -r .
-  rebasing 5:1631091f9648 "commit to absorb"
-  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
-  @  2f7ba78d6abc commit 5
+  @  9a0ec5cae1a1 commit to absorb
+  |
+  o  2f7ba78d6abc commit 5
   |
   o  04c8ba6df782 commit 4
   |
@@ -94,12 +86,15 @@
   |
   o  241ace8326d0 commit 1
   
-  $ hg annotate -c a
-  241ace8326d0: 1a
-  9b19176bb127: 2b
-  484c6ac0cea3: 3
-  04c8ba6df782: 4d
-  2f7ba78d6abc: 5e
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  9b19176bb127 : 2b
+  484c6ac0cea3 : 3
+  04c8ba6df782 : 4d
+  2f7ba78d6abc : 5e
+  9a0ec5cae1a1+: 6
+
+  $ hg diff -c .
 
 Do it again, but this time with an unrelated commit checked out (plus working
 directory changes on top):
@@ -130,7 +125,6 @@
   2 changesets affected
   2f7ba78 commit 5
   04c8ba6 commit 4
-  1 new orphan changesets
   1 of 1 chunk(s) applied
 
   $ hg annotate -c a -r 'wdir()'
@@ -138,19 +132,16 @@
   dbce69d9fe03 : committed unrelated
   dbce69d9fe03+: pending wdir change
 
-
-  $ hg update -Cq .
-
-  $ hg rebase -d tip -r ${TOABSORB}
-  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
-  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+  $ hg update -Cq tip
 
   $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  59655ff113fb commit to absorb 2
+  |
   o  789b01face13 commit 5
   |
   o  9c83c60f49f2 commit 4
   |
-  | @  dbce69d9fe03 unrelated commit
+  | o  dbce69d9fe03 unrelated commit
   | |
   o |  484c6ac0cea3 commit 3
   | |
@@ -159,7 +150,7 @@
   o  241ace8326d0 commit 1
   
 
-  $ hg annotate -c a -r tip
+  $ hg annotate -c a
   241ace8326d0: 1a
   9b19176bb127: 2b
   484c6ac0cea3: 3
diff --git a/hgext/absorb.py b/hgext/absorb.py
--- a/hgext/absorb.py
+++ b/hgext/absorb.py
@@ -34,6 +34,7 @@
 from __future__ import absolute_import
 
 import collections
+import itertools
 
 from mercurial.i18n import _
 from mercurial import (
@@ -661,16 +662,19 @@
 4. call commit, to commit changes to hg database
 """
 
-def __init__(self, stack, ui=None, opts=None):
+def __init__(self, stack, fixuptargets=[], ui=None, opts=None):
 """([ctx], ui or None) -> None
 
 stack: should be linear, and sorted by topo order - oldest first.
+fixuptargets: changeset contexts that need to be fixed up, but are not
+used for fixup computation.
 all commits in stack are considered mutable.
 """
 assert stack
 self.ui = ui or nullui()
 self.opts = opts or {}
 self.stack = stack
+self.fixuptargets = fixuptargets
 self.repo = stack[-1].repo().unfiltered()
 
 # following fields will be filled later
@@ -776,7 +780,7 @@
 # p1 which overrides the parent of the next commit, "None" means use
 # the original parent unchanged
 nextp1 = None
-for ctx in self.stack:
+for ctx in itertools.chain(self.stack, self.fixuptargets):
 memworkingcopy = self._getnewfilecontents(ctx)
 if not memworkingcopy and not lastcommitted:
 # nothing changed, nothing commited
@@ -1008,7 +1012,10 @@
 pats = ()
 if opts is None:
 opts = {}
-state = fixupstate(stack, ui=ui, opts=opts)
+fixuptargets = []
+if targetctx.rev() is not None:
+fixuptargets.append(targetctx)
+state = fixupstate(stack, fixuptargets=fixuptargets, ui=ui, opts=opts)
 matcher = scmutil.match(targetctx, pats, opts)
 if opts.get(b'interactive'):
 diff = patch.diff(repo, stack[-1].node(), targetctx.node(), matcher)



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-deve

D7631: RFC: absorb: allowing committed changes to be absorbed into their ancestors

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This can also be combined with --interactive to absorb just part of a
  commit into its parents.
  
  This initial implementation has the shortcoming that it does not do anything
  with the absorbed commit:
  
  - With obsmarkers, this means the user still needs to evolve/rebase manually
  - Without obsmarkers, the old commits would not be stripped at all because 
their child was not replaced

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  hgext/absorb.py
  tests/test-absorb-rev.t
  tests/test-absorb.t

CHANGE DETAILS

diff --git a/tests/test-absorb.t b/tests/test-absorb.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb.t
@@ -143,7 +143,7 @@
   nothing applied
   [1]
 
-Insertaions:
+Insertions:
 
   $ cat > a << EOF
   > insert before 2b
diff --git a/tests/test-absorb.t b/tests/test-absorb-rev.t
copy from tests/test-absorb.t
copy to tests/test-absorb-rev.t
--- a/tests/test-absorb.t
+++ b/tests/test-absorb-rev.t
@@ -1,26 +1,14 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > absorb=
+  > rebase=
+  > [experimental]
+  > evolution=createmarkers
   > EOF
 
-  $ sedi() { # workaround check-code
-  > pattern="$1"
-  > shift
-  > for i in "$@"; do
-  > sed "$pattern" "$i" > "$i".tmp
-  > mv "$i".tmp "$i"
-  > done
-  > }
-
   $ hg init repo1
   $ cd repo1
 
-Do not crash with empty repo:
-
-  $ hg absorb
-  abort: no mutable changeset to change
-  [255]
-
 Make some commits:
 
   $ for i in 1 2 3 4 5; do
@@ -45,9 +33,13 @@
   > 5e
   > EOF
 
+Commit that, too.
+
+  $ hg commit -qm "commit to absorb"
+
 Preview absorb changes:
 
-  $ hg absorb --print-changes --dry-run
+  $ hg absorb --print-changes --dry-run -r .
   showing changes for a
   @@ -0,2 +0,2 @@
   4ec16f8 -1
@@ -66,462 +58,111 @@
   5c5f952 commit 2
   4ec16f8 commit 1
 
+Add an uncommitted working directory change:
+
+  $ echo 6 >> a
+
 Run absorb:
 
-  $ hg absorb --apply-changes
-  saved backup bundle to * (glob)
+  $ hg absorb --apply-changes -r .
+  1 new orphan changesets
   2 of 2 chunk(s) applied
-  $ hg annotate a
-  0: 1a
-  1: 2b
-  2: 3
-  3: 4d
-  4: 5e
+
+Check that the pending wdir change was left alone:
+
+  $ grep 6 a
+  6
+  $ hg update -Cq .
+
+Rebase the absorbed revision on top of the destination (as evolve would):
+TODO: the evolve-type operation should happen automatically for the changeset
+being absorbed, and even through that the pending wdir change should be left
+alone.
+
+  $ hg rebase -d tip -r .
+  rebasing 5:1631091f9648 "commit to absorb"
+  note: not rebasing 5:1631091f9648 "commit to absorb", its destination 
already has all its changes
 
-Delete a few lines and related commits will be removed if they will be empty:
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  @  2f7ba78d6abc commit 5
+  |
+  o  04c8ba6df782 commit 4
+  |
+  o  484c6ac0cea3 commit 3
+  |
+  o  9b19176bb127 commit 2
+  |
+  o  241ace8326d0 commit 1
+  
+  $ hg annotate -c a
+  241ace8326d0: 1a
+  9b19176bb127: 2b
+  484c6ac0cea3: 3
+  04c8ba6df782: 4d
+  2f7ba78d6abc: 5e
+
+Do it again, but this time with an unrelated commit checked out (plus working
+directory changes on top):
 
   $ cat > a < 1a
   > 2b
-  > 4d
+  > 3
+  > 4f
+  > 5g
   > EOF
-  $ echo y | hg absorb --config ui.interactive=1
+  $ hg commit -qm "commit to absorb 2"
+  $ TOABSORB=$(hg id -i)
+
+  $ hg update -q 241ace8326d0
+  $ echo committed unrelated >> a
+  $ hg commit -qm "unrelated commit"
+  $ echo pending wdir change >> a
+
+  $ hg absorb --apply-changes --print-changes -r ${TOABSORB}
   showing changes for a
-  @@ -0,1 +0,0 @@
-  f548282 -1a
-  @@ -2,1 +1,0 @@
-  ff5d556 -3
-  @@ -4,1 +2,0 @@
-  84e5416 -5e
+  @@ -3,2 +3,2 @@
+  04c8ba6 -4d
+  2f7ba78 -5e
+  04c8ba6 +4f
+  2f7ba78 +5g
   
-  3 changesets affected
-  84e5416 commit 5
-  ff5d556 commit 3
-  f548282 commit 1
-  apply changes (yn)?  y
-  saved backup bundle to * (glob)
-  3 of 3 chunk(s) applied
-  $ hg annotate a
-  1: 2b
-  2: 4d
-  $ hg log -T '{rev} {desc}\n' -Gp
-  @  2 commit 4
-  |  diff -r 1cae118c7ed8 -r 58a62bade1c6 a
-  |  --- a/a   Thu Jan 01 00:00:00 1970 +
-  |  +++ b/a   Thu Jan 01 00:00:00 1970 +
-  |  @@ -1,1 +1,2 @@
-  |   2b
-  |  +4d
+  2 changesets affected
+  2f7ba78 commit 5
+  04c8ba6 commit 4
+  1 new orphan changesets
+  1 of 1 chunk(s) applied
+
+  $ hg annotate -c a -r 'wdir()'
+  241ace8326d0 : 1a
+  dbce69d9fe03 : committed unrelated
+  dbce69d9fe03+: pending wdir change
+
+
+  $ hg update -Cq .
+
+  $ hg rebase -d tip -r ${TOABSORB}
+  rebasing \d+:[0-9a-f]+ "commit to absorb 2" (re)
+  note: not rebasing \d+:[0-9a-f]+ "commit to absorb 2", its destination 
already has all its changes (re)
+
+  $ hg log -G -T '{node|short} {desc} {instabilities}'
+  o  789b01face13 commit 5
   |
-  o  1 commit 2
-  | 

D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> test-absorb-rev.t:67
>  
>$ hg absorb --apply-changes -r .
>2 of 2 chunk(s) applied

`hg absorb` has a `-r` flag? Did you forgot to upload some ancestors of this 
commit?

REPOSITORY
  rHG Mercurial

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

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

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


D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> martinvonz wrote in test-absorb-rev.t:67
> `hg absorb` has a `-r` flag? Did you forgot to upload some ancestors of this 
> commit?

Oh, it's added in D7631 , which is marked 
as a *child* of this review. How did that happen? `hg phabsend` should set the 
relationships automatically. How did you run that command? Just `hg phabsend 
.^::.` or  similar? Or did you manually mark D7631 
 as a child?

REPOSITORY
  rHG Mercurial

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

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

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


D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio added a comment.


  (on mobile) I think it was `hg phabsend -r .+.^`
  
  - F454947: smime.p7s 

REPOSITORY
  rHG Mercurial

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

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

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


D7630: RFC: absorb: make the absorbed changeset be automatically "evolved"

2019-12-12 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In D7630#112243 , @rdamazio 
wrote:
  
  > (on mobile) I think it was `hg phabsend -r .+.^`
  
  Ohh, that makes some sense that phabsend might do it backwards if you pass 
the revisions backwards, but that's still clearly a bug. I'll report it in 
bugzilla if it's not already there. I'll manually update the parent/child 
relationship on these reviews for now.

REPOSITORY
  rHG Mercurial

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

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

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


[Bug 6241] New: `hg phabsend -r . -r .^` creates backwards parent/child pointers

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

Bug ID: 6241
   Summary: `hg phabsend -r . -r .^` creates backwards
parent/child pointers
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: martinv...@google.com
CC: mercurial-devel@mercurial-scm.org
Python Version: ---

It seems phabsend creates the parent/child pointers in reverse order if the
revisions are given in reverse order. I think phabsend should always respect
the topology.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel