D7147: diff: use unfiltered repo if we're diffing the working copy

2019-12-09 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.
martinvonz abandoned this revision.


  Abandoning in favor of D7492 

REPOSITORY
  rHG Mercurial

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

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

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


D7144: status: use unfiltered repo if we're getting status of working copy

2019-12-09 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.
martinvonz abandoned this revision.


  I'll abandon this in favor of D7492 

REPOSITORY
  rHG Mercurial

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

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

To: martinvonz, #hg-reviewers, durin42
Cc: mharbison72, pulkit, marmoute, 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-09 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  Hmm, I thought this entire series had been queued. I'd like to queue it. Can 
you include perf numbers?

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


D7595: status: outputting structured unfinished-operation information

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

REVISION SUMMARY
  This adds a new item in the json/template output for morestatus. For backwards
  compatibility, I put this behind a config option (but I'd be happy to remove
  that if nobody thinks it's a concern), and added item types to all entries.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py
  mercurial/configitems.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,16 +63,38 @@
   $ hg status -Tjson
   [
{
+"itemtype": "file",
 "path": "a",
 "status": "M",
 "unresolved": true
},
{
+"itemtype": "file",
 "path": "a.orig",
 "status": "?"
}
   ]
 
+  $ hg status -Tjson --config commands.status.morestatus-item=1
+  [
+   {
+"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"
+   }
+  ]
+
   $ cat a
   Small Mathematical Series.
   1
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -244,6 +244,9 @@
 b'commands', b'show.aliasprefix', default=list,
 )
 coreconfigitem(
+b'commands', b'status.morestatus-item', default=False,
+)
+coreconfigitem(
 b'commands', b'status.relative', default=False,
 )
 coreconfigitem(
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
@@ -786,6 +786,7 @@
 unfinishedmsg = attr.ib()
 inmergestate = attr.ib()
 unresolvedpaths = attr.ib()
+adddataitem = attr.ib()
 _label = b'status.morestatus'
 
 def formatfile(self, path, fm):
@@ -797,6 +798,11 @@
  ) % self.unfinishedop
 fm.plain(b'%s\n' % _commentlines(statemsg), label=self._label)
 
+if self.adddataitem:
+fm.startitem()
+fm.data(itemtype=b'morestatus', unfinished=self.unfinishedop,
+unfinishedmsg=self.unfinishedmsg)
+
 self._formatconflicts(fm)
 if self.unfinishedmsg:
 fm.plain(b'%s\n' % _commentlines(self.unfinishedmsg),
@@ -841,8 +847,9 @@
 unresolved = None
 if mergestate.active():
 unresolved = sorted(mergestate.unresolved())
+dataitem = repo.ui.config(b'commands', b'status.morestatus-item')
 return morestatus(repo.root, unfinishedop, unfinishedmsg,
-  unresolved is not None, unresolved)
+  unresolved is not None, unresolved, dataitem)
 
 
 def findpossible(cmd, table, strict=False):



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


D7594: status: add template/json data about whether a file has unresolved conflicts

2019-12-09 Thread rdamazio (Rodrigo Damazio Bovendorp)
rdamazio 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/D7594

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

CHANGE DETAILS

diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -64,7 +64,8 @@
   [
{
 "path": "a",
-"status": "M"
+"status": "M",
+"unresolved": true
},
{
 "path": "a.orig",
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6893,6 +6893,8 @@
 (b'  %s' + end) % uipathfn(copy[f]),
 label=b'status.copied',
 )
+if morestatus:
+morestatus.formatfile(f, fm)
 
 if morestatus:
 morestatus.formatfooter(fm)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -788,6 +788,10 @@
 unresolvedpaths = attr.ib()
 _label = b'status.morestatus'
 
+def formatfile(self, path, fm):
+if self.inmergestate and path in self.unresolvedpaths:
+fm.data(unresolved=True)
+
 def formatfooter(self, fm):
 statemsg = _(b'The repository is in an unfinished *%s* state.'
  ) % self.unfinishedop



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


D7593: status: split morestatus data loading from display

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

REVISION SUMMARY
  This is a small refactoring in preparation for adding more morestatus
  functionality (notably for templated/JSON output) - the goal is to
  use the data inside the status display loop, as well as output the
  overall state in a templatable/structured way.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -6867,6 +6867,12 @@
 ) and not opts.get(b'no_status'):
 copy = copies.pathcopies(ctx1, ctx2, m)
 
+morestatus = None
+if (
+ui.verbose or ui.configbool(b'commands', b'status.verbose')
+) and not ui.plain():
+morestatus = cmdutil.readmorestatus(repo)
+
 ui.pager(b'status')
 fm = ui.formatter(b'status', opts)
 fmt = b'%s' + end
@@ -6888,10 +6894,8 @@
 label=b'status.copied',
 )
 
-if (
-ui.verbose or ui.configbool(b'commands', b'status.verbose')
-) and not ui.plain():
-cmdutil.morestatus(repo, fm)
+if morestatus:
+morestatus.formatfooter(fm)
 fm.end()
 
 
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -24,6 +24,7 @@
 open,
 setattr,
 )
+from .thirdparty import attr
 
 from . import (
 bookmarks,
@@ -778,48 +779,66 @@
 return b'\n'.join(commentedlines) + b'\n'
 
 
-def _conflictsmsg(repo):
-mergestate = mergemod.mergestate.read(repo)
-if not mergestate.active():
-return
-
-m = scmutil.match(repo[None])
-unresolvedlist = [f for f in mergestate.unresolved() if m(f)]
-if unresolvedlist:
-mergeliststr = b'\n'.join(
-[
-b'%s' % util.pathto(repo.root, encoding.getcwd(), path)
-for path in sorted(unresolvedlist)
-]
-)
-msg = (
-_(
-'''Unresolved merge conflicts:
+@attr.s(frozen=True)
+class morestatus(object):
+reporoot = attr.ib()
+unfinishedop = attr.ib()
+unfinishedmsg = attr.ib()
+inmergestate = attr.ib()
+unresolvedpaths = attr.ib()
+_label = b'status.morestatus'
+
+def formatfooter(self, fm):
+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)
+
+def _formatconflicts(self, fm):
+if not self.inmergestate:
+return
+
+if self.unresolvedpaths:
+mergeliststr = b'\n'.join(
+[
+b'%s' % util.pathto(self.reporoot, encoding.getcwd(),
+path)
+for path in self.unresolvedpaths
+]
+)
+msg = (
+_(
+'''Unresolved merge conflicts:
 
 %s
 
 To mark files as resolved:  hg resolve --mark FILE'''
+)
+% mergeliststr
 )
-% mergeliststr
-)
-else:
-msg = _(b'No unresolved merge conflicts.')
-
-return _commentlines(msg)
-
-
-def morestatus(repo, fm):
+else:
+msg = _(b'No unresolved merge conflicts.')
+
+fm.plain(b'%s\n' % _commentlines(msg), label=self._label)
+
+
+def readmorestatus(repo):
+"""Returns a morestatus object if the repo has unfinished state."""
 statetuple = statemod.getrepostate(repo)
-label = b'status.morestatus'
-if statetuple:
-state, helpfulmsg = statetuple
-statemsg = _(b'The repository is in an unfinished *%s* state.') % state
-fm.plain(b'%s\n' % _commentlines(statemsg), label=label)
-conmsg = _conflictsmsg(repo)
-if conmsg:
-fm.plain(b'%s\n' % conmsg, label=label)
-if helpfulmsg:
-fm.plain(b'%s\n' % _commentlines(helpfulmsg), label=label)
+if not statetuple:
+return None
+
+unfinishedop, unfinishedmsg = statetuple
+mergestate = mergemod.mergestate.read(repo)
+unresolved = None
+if mergestate.active():
+unresolved = sorted(mergestate.unresolved())
+return morestatus(repo.root, unfinishedop, unfinishedmsg,
+  unresolved is not None, unresolved)
 
 
 def findpossible(cmd, table, strict=False):



To: rdamazio, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org

D7591: status: remove pointless filtering by alwaysmatcher in morestatus

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


  In D7591#111571 , @rdamazio 
wrote:
  
  > In D7591#111570 , @martinvonz 
wrote:
  >
  >> In D7591#111569 , @rdamazio 
wrote:
  >>
  >>> FYI I'm going to send a chain that rewrites a lot of this
  >>
  >> To be clear, are you telling reviewers not to queue this one because you 
will be rewriting the *patch* or you're saying that you will later be sending 
patches on top of this one?
  >
  > I'm writing a larger change which includes this change, I don't mind 
merging the conflict if you want to go ahead and queue this.
  
  Okay, I think it makes sense to queue this one if it's just a subset of you 
changes.

REPOSITORY
  rHG Mercurial

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

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

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


D7591: status: remove pointless filtering by alwaysmatcher in morestatus

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


  In D7591#111570 , @martinvonz 
wrote:
  
  > In D7591#111569 , @rdamazio 
wrote:
  >
  >> FYI I'm going to send a chain that rewrites a lot of this
  >
  > To be clear, are you telling reviewers not to queue this one because you 
will be rewriting the *patch* or you're saying that you will later be sending 
patches on top of this one?
  
  I'm writing a larger change which includes this change, I don't mind merging 
the conflict if you want to go ahead and queue this.

REPOSITORY
  rHG Mercurial

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

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

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


D7591: status: remove pointless filtering by alwaysmatcher in morestatus

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


  In D7591#111569 , @rdamazio 
wrote:
  
  > FYI I'm going to send a chain that rewrites a lot of this
  
  To be clear, are you telling reviewers not to queue this one because you will 
be rewriting the *patch* or you're saying that you will later be sending 
patches on top of this one?

REPOSITORY
  rHG Mercurial

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

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

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


D7591: status: remove pointless filtering by alwaysmatcher in morestatus

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


  FYI I'm going to send a chain that rewrites a lot of this

REPOSITORY
  rHG Mercurial

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

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

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


mercurial@43806: 2 new changesets

2019-12-09 Thread Mercurial Commits
2 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/ad84fc97d120
changeset:   43805:ad84fc97d120
user:Pierre-Yves David 
date:Fri Nov 29 15:36:45 2019 +0100
summary: upgrade-repo: colorize some of the output

https://www.mercurial-scm.org/repo/hg/rev/acbb55b8e9dc
changeset:   43806:acbb55b8e9dc
bookmark:@
tag: tip
user:Pierre-Yves David 
date:Sun Sep 29 16:00:32 2019 +0200
summary: upgraderepo: add a config option for parallel computation

-- 
Repository URL: https://www.mercurial-scm.org/repo/hg
___
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-09 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Note: please review the embedded Python segments carefully, as it's a little 
fidgety to get right and verify I didn't do something Really Dumb.

REPOSITORY
  rHG Mercurial

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

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

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


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

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

REVISION SUMMARY
  This was more of a hairball than I hoped, but it appears to work. The hg-py3
  branch of my oss-fuzz fork on github has the remaining changes to switch us to
  Python 3, but we may as well retain Python 2 fuzzing support for at least a
  little while.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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 

[Bug 6238] New: Windows: time.clock removed from python 3.8 - prevents building/running from source.

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

Bug ID: 6238
   Summary: Windows: time.clock removed from python 3.8 - prevents
building/running from source.
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: tom_hin...@sil.org
CC: mercurial-devel@mercurial-scm.org
Python Version: ---

Emits 'Unable to find a working hg binary to extract the version from the
repository tags'

Patched by checking for perf_counter (introduced in python 3.3) first:

diff -r 76d32a0edbc6 mercurial/util.py
--- a/mercurial/util.py Fri Dec 06 15:30:06 2019 +0100
+++ b/mercurial/util.py Mon Dec 09 14:48:29 2019 -0700
@@ -2040,15 +2040,17 @@
 )


+timer = None;
+if safehasattr(time, "perf_counter"):
+timer = time.perf_counter
 if pycompat.iswindows:
 checkosfilename = checkwinfilename
-timer = time.clock
+if not timer:
+timer = time.clock
 else:
 checkosfilename = platform.checkosfilename
-timer = time.time
-
-if safehasattr(time, "perf_counter"):
-timer = time.perf_counter
+if not timer:
+timer = time.time


 def makelock(info, pathname):

-- 
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


D7591: status: remove pointless filtering by alwaysmatcher in morestatus

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

REVISION SUMMARY
  The code has been like this since it was imported from FB's
  hg-experimental repo. It has been like that even since it was added in
  that repo. So I don't know why it looks that way. Perhaps the idea was
  to one day filter the unresolved paths by any patterns provided by the
  user. We can add a matcher back if we ever decide to do that.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -783,13 +783,12 @@
 if not mergestate.active():
 return
 
-m = scmutil.match(repo[None])
-unresolvedlist = [f for f in mergestate.unresolved() if m(f)]
+unresolvedlist = sorted(mergestate.unresolved())
 if unresolvedlist:
 mergeliststr = b'\n'.join(
 [
 b'%s' % util.pathto(repo.root, encoding.getcwd(), path)
-for path in sorted(unresolvedlist)
+for path in unresolvedlist
 ]
 )
 msg = (



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


D7590: remotefilelog: remove the `ensurestart` usage

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute updated this revision to Diff 18557.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7590?vs=18555=18557

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

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/repack.py
  hgext/remotefilelog/shallowrepo.py
  tests/test-remotefilelog-bgprefetch.t
  tests/test-remotefilelog-repack-fast.t
  tests/test-remotefilelog-repack.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-repack.t 
b/tests/test-remotefilelog-repack.t
--- a/tests/test-remotefilelog-repack.t
+++ b/tests/test-remotefilelog-repack.t
@@ -1,11 +1,8 @@
 #require no-windows
 
   $ . "$TESTDIR/remotefilelog-library.sh"
-# devel.remotefilelog.ensurestart: reduce race condition with
-# waiton{repack/prefetch}
   $ cat >> $HGRCPATH < [devel]
-  > remotefilelog.ensurestart=True
   > remotefilelog.bg-wait=True
   > EOF
 
diff --git a/tests/test-remotefilelog-repack-fast.t 
b/tests/test-remotefilelog-repack-fast.t
--- a/tests/test-remotefilelog-repack-fast.t
+++ b/tests/test-remotefilelog-repack-fast.t
@@ -1,13 +1,11 @@
 #require no-windows
 
   $ . "$TESTDIR/remotefilelog-library.sh"
-# devel.remotefilelog.ensurestart: reduce race condition with
-# waiton{repack/prefetch}
+
   $ cat >> $HGRCPATH < [remotefilelog]
   > fastdatapack=True
   > [devel]
-  > remotefilelog.ensurestart=True
   > remotefilelog.bg-wait=True
   > EOF
 
diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -1,11 +1,8 @@
 #require no-windows
 
   $ . "$TESTDIR/remotefilelog-library.sh"
-# devel.remotefilelog.ensurestart: reduce race condition with
-# waiton{repack/prefetch}
   $ cat >> $HGRCPATH < [devel]
-  > remotefilelog.ensurestart=True
   > remotefilelog.bg-wait=True
   > EOF
 
diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -215,13 +215,7 @@
 )
 
 def backgroundprefetch(
-self,
-revs,
-base=None,
-repack=False,
-pats=None,
-opts=None,
-ensurestart=False,
+self, revs, base=None, repack=False, pats=None, opts=None
 ):
 """Runs prefetch in background with optional repack
 """
@@ -237,7 +231,7 @@
 kwargs['record_wait'] = repo.ui.atexit
 
 procutil.runbgcommand(
-cmd, encoding.environ, ensurestart=ensurestart, **kwargs
+cmd, encoding.environ, ensurestart=False, **kwargs
 )
 
 def prefetch(self, revs, base=None, pats=None, opts=None):
diff --git a/hgext/remotefilelog/repack.py b/hgext/remotefilelog/repack.py
--- a/hgext/remotefilelog/repack.py
+++ b/hgext/remotefilelog/repack.py
@@ -36,9 +36,7 @@
 pass
 
 
-def backgroundrepack(
-repo, incremental=True, packsonly=False, ensurestart=False
-):
+def backgroundrepack(repo, incremental=True, packsonly=False):
 cmd = [procutil.hgexecutable(), b'-R', repo.origroot, b'repack']
 msg = _(b"(running background repack)\n")
 if incremental:
@@ -52,9 +50,7 @@
 if repo.ui.configbool(b'devel', b'remotefilelog.bg-wait'):
 kwargs['record_wait'] = repo.ui.atexit
 
-procutil.runbgcommand(
-cmd, encoding.environ, ensurestart=ensurestart, **kwargs
-)
+procutil.runbgcommand(cmd, encoding.environ, ensurestart=False, **kwargs)
 
 
 def fullrepack(repo, options=None):
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -229,7 +229,6 @@
 configitem(b'packs', b'maxpacksize', default=0)
 configitem(b'packs', b'maxchainlen', default=1000)
 
-configitem(b'devel', b'remotefilelog.ensurestart', default=False)
 configitem(b'devel', b'remotefilelog.bg-wait', default=False)
 
 #  default TTL limit is 30 days
@@ -1085,26 +1084,19 @@
 prefetchrevset = ui.config(b'remotefilelog', b'pullprefetch')
 bgrepack = repo.ui.configbool(b'remotefilelog', b'backgroundrepack')
 bgprefetch = repo.ui.configbool(b'remotefilelog', 
b'backgroundprefetch')
-ensurestart = repo.ui.configbool(b'devel', 
b'remotefilelog.ensurestart')
 
 if prefetchrevset:
 ui.status(_(b"prefetching file contents\n"))
 revs = scmutil.revrange(repo, [prefetchrevset])
 base = repo[b'.'].rev()
 if bgprefetch:
-repo.backgroundprefetch(
-prefetchrevset, repack=bgrepack, ensurestart=ensurestart
-)
+repo.backgroundprefetch(prefetchrevset, repack=bgrepack)
 else:
 repo.prefetch(revs, base=base)
 if 

D7584: procutil: add a option to not fully detach background process

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute updated this revision to Diff 18556.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7584?vs=18549=18556

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

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

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
@@ -548,12 +548,18 @@
 _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
 def runbgcommand(
-script, env, shell=False, stdout=None, stderr=None, ensurestart=True
+script,
+env,
+shell=False,
+stdout=None,
+stderr=None,
+ensurestart=True,
+record_wait=None,
 ):
 '''Spawn a command without waiting for it to finish.'''
 # we can't use close_fds *and* redirect stdin. I'm not sure that we
 # need to because the detached process has no console connection.
-subprocess.Popen(
+p = subprocess.Popen(
 tonativestr(script),
 shell=shell,
 env=tonativeenv(env),
@@ -562,46 +568,64 @@
 stdout=stdout,
 stderr=stderr,
 )
+if record_wait is not None:
+record_wait(p.wait)
 
 
 else:
 
 def runbgcommand(
-cmd, env, shell=False, stdout=None, stderr=None, ensurestart=True
+cmd,
+env,
+shell=False,
+stdout=None,
+stderr=None,
+ensurestart=True,
+record_wait=None,
 ):
-'''Spawn a command without waiting for it to finish.'''
+'''Spawn a command without waiting for it to finish.
+
+
+When `record_wait` is not None, the spawned process will not be fully
+detached and the `record_wait` argument will be called with a the
+`Subprocess.wait` function for the spawned process.  This is mostly
+useful for developers that need to make sure the spawned process
+finished before a certain point. (eg: writing test)'''
 # double-fork to completely detach from the parent process
 # based on http://code.activestate.com/recipes/278731
-pid = os.fork()
-if pid:
-if not ensurestart:
+if record_wait is None:
+pid = os.fork()
+if pid:
+if not ensurestart:
+return
+# Parent process
+(_pid, status) = os.waitpid(pid, 0)
+if os.WIFEXITED(status):
+returncode = os.WEXITSTATUS(status)
+else:
+returncode = -(os.WTERMSIG(status))
+if returncode != 0:
+# The child process's return code is 0 on success, an errno
+# value on failure, or 255 if we don't have a valid errno
+# value.
+#
+# (It would be slightly nicer to return the full exception 
info
+# over a pipe as the subprocess module does.  For now it
+# doesn't seem worth adding that complexity here, though.)
+if returncode == 255:
+returncode = errno.EINVAL
+raise OSError(
+returncode,
+b'error running %r: %s'
+% (cmd, os.strerror(returncode)),
+)
 return
-# Parent process
-(_pid, status) = os.waitpid(pid, 0)
-if os.WIFEXITED(status):
-returncode = os.WEXITSTATUS(status)
-else:
-returncode = -(os.WTERMSIG(status))
-if returncode != 0:
-# The child process's return code is 0 on success, an errno
-# value on failure, or 255 if we don't have a valid errno
-# value.
-#
-# (It would be slightly nicer to return the full exception info
-# over a pipe as the subprocess module does.  For now it
-# doesn't seem worth adding that complexity here, though.)
-if returncode == 255:
-returncode = errno.EINVAL
-raise OSError(
-returncode,
-b'error running %r: %s' % (cmd, os.strerror(returncode)),
-)
-return
 
 returncode = 255
 try:
-# Start a new session
-os.setsid()
+if record_wait is None:
+# Start a new session
+os.setsid()
 
 stdin = open(os.devnull, b'r')
 if stdout is None:
@@ -611,7 +635,7 @@
 
 # connect stdin to devnull to make sure the subprocess can't
 # muck up that stream for mercurial.
-

D7590: remotefilelog: remove the `ensurestart` usage

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


  good spot. I'll update that last patch.

REPOSITORY
  rHG Mercurial

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

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

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


D7584: procutil: add a option to not fully detach background process

2019-12-09 Thread durin42 (Augie Fackler)
This revision now requires changes to proceed.
durin42 added inline comments.
durin42 requested changes to this revision.

INLINE COMMENTS

> procutil.py:589
> +
> +When `register_wait` is not None, the spawned process will not be 
> fully
> +detached and the `record_wait` argument will be called with a the

s/register_wait/record_wait/?

> procutil.py:592
> +`Subprocess.wait` function for the spawned process.  This is mostly
> +useful for developper that need to make sure the spawned process
> +finished before a certain point. (eg: writing test)'''

s/developper/developers/

REPOSITORY
  rHG Mercurial

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

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

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


D7585: remotefilelog: add a developer option to wait for background processes

2019-12-09 Thread durin42 (Augie Fackler)
durin42 added inline comments.

INLINE COMMENTS

> shallowrepo.py:237
> +if repo.ui.configbool(b'devel', b'remotefilelog.bg-wait'):
> +kwargs['record_wait'] = repo.ui.atexit
> +

It took me some very careful reasoning to figure this out. Could you amend the 
log message to include something like the following?

> In order to block on the subprocess exiting, we ensure the repo's ui object 
> will call the subprocess.wait() method to ensure the top-level hg process 
> doesn't exit until all background processes have also done so.

Maybe it's just I didn't have tea this morning, but this cost me a pretty 
decent chunk of review time.

REPOSITORY
  rHG Mercurial

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

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

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


D7590: remotefilelog: remove the `ensurestart` usage

2019-12-09 Thread durin42 (Augie Fackler)
durin42 added a comment.


  This is wrong, because now remotefilelog will do ensurestart=True (the 
default) which is a significant performance hit for remotefilelog users.

REPOSITORY
  rHG Mercurial

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

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

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


D7590: remotefilelog: remove the `ensurestart` usage

2019-12-09 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Wait, I just saw the chain. Thanks for weird emails phabricator!

REPOSITORY
  rHG Mercurial

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

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

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


D7590: remotefilelog: remove the `ensurestart` usage

2019-12-09 Thread durin42 (Augie Fackler)
durin42 added a comment.


  This doesn't apply to stable. I also checked default, and it doesn't apply 
there either.

REPOSITORY
  rHG Mercurial

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

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

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


D7579: tests: add test for Rust formatting

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


  While I am not a huge fan of the use of a nightly toolchain, I like the fact 
that we get the latest features and behavior as `rustfmt` is still pre-1.0 and 
subject to change. So far, it has been nice to us and has not broken anything I 
can recall, I vote for keeping it that way until it reaches 1.0.

REPOSITORY
  rHG Mercurial

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

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

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


D7590: remotefilelog: remove the `ensurestart` usage

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  The option does not seems to do what we want since it does not wait on the 
background
  process actually starting (eg: taking the lock). And the race have been dealt
  with another way anyway.
  
  This effectively back out changeset 2c74337e6483 
.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/repack.py
  hgext/remotefilelog/shallowrepo.py
  tests/test-remotefilelog-bgprefetch.t
  tests/test-remotefilelog-repack-fast.t
  tests/test-remotefilelog-repack.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-repack.t 
b/tests/test-remotefilelog-repack.t
--- a/tests/test-remotefilelog-repack.t
+++ b/tests/test-remotefilelog-repack.t
@@ -1,11 +1,8 @@
 #require no-windows
 
   $ . "$TESTDIR/remotefilelog-library.sh"
-# devel.remotefilelog.ensurestart: reduce race condition with
-# waiton{repack/prefetch}
   $ cat >> $HGRCPATH < [devel]
-  > remotefilelog.ensurestart=True
   > remotefilelog.bg-wait=True
   > EOF
 
diff --git a/tests/test-remotefilelog-repack-fast.t 
b/tests/test-remotefilelog-repack-fast.t
--- a/tests/test-remotefilelog-repack-fast.t
+++ b/tests/test-remotefilelog-repack-fast.t
@@ -1,13 +1,11 @@
 #require no-windows
 
   $ . "$TESTDIR/remotefilelog-library.sh"
-# devel.remotefilelog.ensurestart: reduce race condition with
-# waiton{repack/prefetch}
+
   $ cat >> $HGRCPATH < [remotefilelog]
   > fastdatapack=True
   > [devel]
-  > remotefilelog.ensurestart=True
   > remotefilelog.bg-wait=True
   > EOF
 
diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -1,11 +1,8 @@
 #require no-windows
 
   $ . "$TESTDIR/remotefilelog-library.sh"
-# devel.remotefilelog.ensurestart: reduce race condition with
-# waiton{repack/prefetch}
   $ cat >> $HGRCPATH < [devel]
-  > remotefilelog.ensurestart=True
   > remotefilelog.bg-wait=True
   > EOF
 
diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -215,13 +215,7 @@
 )
 
 def backgroundprefetch(
-self,
-revs,
-base=None,
-repack=False,
-pats=None,
-opts=None,
-ensurestart=False,
+self, revs, base=None, repack=False, pats=None, opts=None,
 ):
 """Runs prefetch in background with optional repack
 """
@@ -236,9 +230,7 @@
 if repo.ui.configbool(b'devel', b'remotefilelog.bg-wait'):
 kwargs['record_wait'] = repo.ui.atexit
 
-procutil.runbgcommand(
-cmd, encoding.environ, ensurestart=ensurestart, **kwargs
-)
+procutil.runbgcommand(cmd, encoding.environ, **kwargs)
 
 def prefetch(self, revs, base=None, pats=None, opts=None):
 """Prefetches all the necessary file revisions for the given revs
diff --git a/hgext/remotefilelog/repack.py b/hgext/remotefilelog/repack.py
--- a/hgext/remotefilelog/repack.py
+++ b/hgext/remotefilelog/repack.py
@@ -36,9 +36,7 @@
 pass
 
 
-def backgroundrepack(
-repo, incremental=True, packsonly=False, ensurestart=False
-):
+def backgroundrepack(repo, incremental=True, packsonly=False):
 cmd = [procutil.hgexecutable(), b'-R', repo.origroot, b'repack']
 msg = _(b"(running background repack)\n")
 if incremental:
@@ -52,9 +50,7 @@
 if repo.ui.configbool(b'devel', b'remotefilelog.bg-wait'):
 kwargs['record_wait'] = repo.ui.atexit
 
-procutil.runbgcommand(
-cmd, encoding.environ, ensurestart=ensurestart, **kwargs
-)
+procutil.runbgcommand(cmd, encoding.environ, **kwargs)
 
 
 def fullrepack(repo, options=None):
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -229,7 +229,6 @@
 configitem(b'packs', b'maxpacksize', default=0)
 configitem(b'packs', b'maxchainlen', default=1000)
 
-configitem(b'devel', b'remotefilelog.ensurestart', default=False)
 configitem(b'devel', b'remotefilelog.bg-wait', default=False)
 
 #  default TTL limit is 30 days
@@ -1085,26 +1084,19 @@
 prefetchrevset = ui.config(b'remotefilelog', b'pullprefetch')
 bgrepack = repo.ui.configbool(b'remotefilelog', b'backgroundrepack')
 bgprefetch = repo.ui.configbool(b'remotefilelog', 
b'backgroundprefetch')
-ensurestart = repo.ui.configbool(b'devel', 
b'remotefilelog.ensurestart')
 
 if prefetchrevset:
 

D7589: remotefilelog: remove most of the debugwait* command in the tests

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  Since we use a dedicated developer config, we do not need them anymore.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-remotefilelog-bgprefetch.t
  tests/test-remotefilelog-gcrepack.t
  tests/test-remotefilelog-repack-fast.t
  tests/test-remotefilelog-repack.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-repack.t 
b/tests/test-remotefilelog-repack.t
--- a/tests/test-remotefilelog-repack.t
+++ b/tests/test-remotefilelog-repack.t
@@ -153,7 +153,6 @@
 
   $ hg repack --background
   (running background repack)
-  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.dataidx
   
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.datapack
@@ -371,7 +370,6 @@
   searching for changes
   no changes found
   (running background incremental repack)
-  $ hg debugwaitonrepack >/dev/null 2>&1
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
   -r--r--r-- 303 156a6c1c83aeb69422d7936e0a46ba9bc06a71c0.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
diff --git a/tests/test-remotefilelog-repack-fast.t 
b/tests/test-remotefilelog-repack-fast.t
--- a/tests/test-remotefilelog-repack-fast.t
+++ b/tests/test-remotefilelog-repack-fast.t
@@ -143,7 +143,6 @@
 
   $ hg repack --background
   (running background repack)
-  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.dataidx
   
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.datapack
@@ -342,7 +341,6 @@
   searching for changes
   no changes found
   (running background incremental repack)
-  $ hg debugwaitonrepack >/dev/null 2>&1
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
   -r--r--r-- 303 156a6c1c83aeb69422d7936e0a46ba9bc06a71c0.datapack
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack
diff --git a/tests/test-remotefilelog-gcrepack.t 
b/tests/test-remotefilelog-gcrepack.t
--- a/tests/test-remotefilelog-gcrepack.t
+++ b/tests/test-remotefilelog-gcrepack.t
@@ -40,7 +40,6 @@
   $ hg prefetch
   2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
   $ hg repack
-  $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
   
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
@@ -72,7 +71,6 @@
   > EOF
 
   $ hg repack
-  $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
   
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
@@ -99,7 +97,6 @@
   $ hg prefetch
   2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
   $ hg repack
-  $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
   
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
@@ -132,7 +129,6 @@
   > EOF
 
   $ hg repack
-  $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
   
$TESTTMP/hgcache/master/packs/7bcd2d90b99395ca43172a0dd24e18860b2902f9.histpack
diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -79,7 +79,6 @@
   new changesets 6b4b6f66ef8c
   (run 'hg update' to get a working copy)
   prefetching file contents
-  $ hg debugwaitonprefetch >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/ef95c5376f34698742fe34f315fd82136f8f68c0
   
$TESTTMP/hgcache/master/95/cb0bfd2977c761298d9624e4b4d4c72a39974a/076f5e2225b3ff0400b98c92aa6cdf403ee24cca
@@ -107,8 +106,6 @@
   new changesets 6b4b6f66ef8c
   (run 'hg update' to get a working copy)
   prefetching file contents
-  $ hg debugwaitonprefetch >/dev/null 2>&1
-  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histidx
   
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histpack
@@ -140,8 +137,6 @@
   $ hg up -r 0
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   * files fetched over * fetches - (* misses, 0.00% hit ratio) over *s (glob)
-  $ hg debugwaitonprefetch >/dev/null 2>&1
-  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
@@ -189,8 +184,6 @@
   $ hg commit -qAm b
  

D7587: remotefilelog: remove most sleep in tests

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  Now that we removed most of the races, we can remove the infamous sleeps.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-remotefilelog-bgprefetch.t
  tests/test-remotefilelog-gcrepack.t
  tests/test-remotefilelog-repack-fast.t
  tests/test-remotefilelog-repack.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-repack.t 
b/tests/test-remotefilelog-repack.t
--- a/tests/test-remotefilelog-repack.t
+++ b/tests/test-remotefilelog-repack.t
@@ -153,7 +153,6 @@
 
   $ hg repack --background
   (running background repack)
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.dataidx
@@ -372,7 +371,6 @@
   searching for changes
   no changes found
   (running background incremental repack)
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
   -r--r--r-- 303 156a6c1c83aeb69422d7936e0a46ba9bc06a71c0.datapack
diff --git a/tests/test-remotefilelog-repack-fast.t 
b/tests/test-remotefilelog-repack-fast.t
--- a/tests/test-remotefilelog-repack-fast.t
+++ b/tests/test-remotefilelog-repack-fast.t
@@ -143,7 +143,6 @@
 
   $ hg repack --background
   (running background repack)
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/39443fa1064182e93d968b5cba292eb5283260d0.dataidx
@@ -343,7 +342,6 @@
   searching for changes
   no changes found
   (running background incremental repack)
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>&1
   $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack
   -r--r--r-- 303 156a6c1c83aeb69422d7936e0a46ba9bc06a71c0.datapack
diff --git a/tests/test-remotefilelog-gcrepack.t 
b/tests/test-remotefilelog-gcrepack.t
--- a/tests/test-remotefilelog-gcrepack.t
+++ b/tests/test-remotefilelog-gcrepack.t
@@ -40,7 +40,6 @@
   $ hg prefetch
   2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
   $ hg repack
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
@@ -73,7 +72,6 @@
   > EOF
 
   $ hg repack
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
@@ -101,7 +99,6 @@
   $ hg prefetch
   2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
   $ hg repack
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
@@ -135,7 +132,6 @@
   > EOF
 
   $ hg repack
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>%1
 
   $ find $CACHEDIR | sort | egrep ".datapack|.histpack"
diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -79,7 +79,6 @@
   new changesets 6b4b6f66ef8c
   (run 'hg update' to get a working copy)
   prefetching file contents
-  $ sleep 0.5
   $ hg debugwaitonprefetch >/dev/null 2>%1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/ef95c5376f34698742fe34f315fd82136f8f68c0
@@ -108,11 +107,8 @@
   new changesets 6b4b6f66ef8c
   (run 'hg update' to get a working copy)
   prefetching file contents
-  $ sleep 0.5
   $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ sleep 0.5
   $ hg debugwaitonrepack >/dev/null 2>%1
-  $ sleep 0.5
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histidx
   
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histpack
@@ -144,11 +140,8 @@
   $ hg up -r 0
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   * files fetched over * fetches - (* misses, 0.00% hit ratio) over *s (glob)
-  $ sleep 1
   $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ sleep 1
   $ hg debugwaitonrepack >/dev/null 2>%1
-  $ sleep 1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
@@ -196,11 +189,8 @@
   $ hg commit -qAm b
   * files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob)
   $ hg bookmark temporary
-  $ sleep 1
   $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ sleep 1
   $ hg debugwaitonrepack >/dev/null 2>%1
-  $ sleep 1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
@@ -246,11 +236,8 @@
   rebasing 3:58147a5b5242 "b" (temporary tip)
   

D7588: remotefilelog: use the correct redirection in tests

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  The test were using '2>%1' which just redirect stderr in the "%1" file. The
  intend was '2>&1' which redirect stderr on stdin.
  
  This impact tests because some commit were picking up this '%1' files.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-remotefilelog-bgprefetch.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -79,7 +79,7 @@
   new changesets 6b4b6f66ef8c
   (run 'hg update' to get a working copy)
   prefetching file contents
-  $ hg debugwaitonprefetch >/dev/null 2>%1
+  $ hg debugwaitonprefetch >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/ef95c5376f34698742fe34f315fd82136f8f68c0
   
$TESTTMP/hgcache/master/95/cb0bfd2977c761298d9624e4b4d4c72a39974a/076f5e2225b3ff0400b98c92aa6cdf403ee24cca
@@ -107,8 +107,8 @@
   new changesets 6b4b6f66ef8c
   (run 'hg update' to get a working copy)
   prefetching file contents
-  $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ hg debugwaitonrepack >/dev/null 2>%1
+  $ hg debugwaitonprefetch >/dev/null 2>&1
+  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histidx
   
$TESTTMP/hgcache/master/packs/6e8633deba6e544e5f8edbd7b996d6e31a2c42ae.histpack
@@ -140,8 +140,8 @@
   $ hg up -r 0
   1 files updated, 0 files merged, 1 files removed, 0 files unresolved
   * files fetched over * fetches - (* misses, 0.00% hit ratio) over *s (glob)
-  $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ hg debugwaitonrepack >/dev/null 2>%1
+  $ hg debugwaitonprefetch >/dev/null 2>&1
+  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
@@ -189,8 +189,8 @@
   $ hg commit -qAm b
   * files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob)
   $ hg bookmark temporary
-  $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ hg debugwaitonrepack >/dev/null 2>%1
+  $ hg debugwaitonprefetch >/dev/null 2>&1
+  $ hg debugwaitonrepack >/dev/null 2>&1
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histpack
@@ -228,16 +228,16 @@
 # background prefetch with repack on rebase when wcprevset configured
 
   $ hg up -r 2
-  3 files updated, 0 files merged, 3 files removed, 0 files unresolved
+  3 files updated, 0 files merged, 2 files removed, 0 files unresolved
   (leaving bookmark temporary)
   $ clearcache
   $ find $CACHEDIR -type f | sort
   $ hg rebase -s temporary -d foo
-  rebasing 3:58147a5b5242 "b" (temporary tip)
-  saved backup bundle to 
$TESTTMP/shallow/.hg/strip-backup/58147a5b5242-c3678817-rebase.hg
+  rebasing 3:d9cf06e3b5b6 "b" (temporary tip)
+  saved backup bundle to 
$TESTTMP/shallow/.hg/strip-backup/d9cf06e3b5b6-e5c3dc63-rebase.hg
   3 files fetched over 1 fetches - (3 misses, 0.00% hit ratio) over *s (glob)
-  $ hg debugwaitonprefetch >/dev/null 2>%1
-  $ hg debugwaitonrepack >/dev/null 2>%1
+  $ hg debugwaitonprefetch >/dev/null 2>&1
+  $ hg debugwaitonrepack >/dev/null 2>&1
 
 # Ensure that file 'y' was prefetched - it was not part of the rebase 
operation and therefore
 # could only be downloaded by the background prefetch
@@ -269,7 +269,7 @@
 # Check that foregound prefetch with no arguments blocks until background 
prefetches finish
 
   $ hg up -r 3
-  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ clearcache
   $ hg prefetch --repack
   waiting for lock on prefetching in $TESTTMP/shallow held by process * on 
host * (glob) (?)
@@ -277,7 +277,7 @@
   (running background incremental repack)
   * files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob) 
(?)
 
-  $ hg debugwaitonrepack >/dev/null 2>%1
+  $ hg debugwaitonrepack >/dev/null 2>&1
 
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx
@@ -319,7 +319,7 @@
   got lock after * seconds (glob) (?)
   (running background incremental repack)
   * files fetched over 1 fetches - (* misses, 0.00% hit ratio) over *s (glob) 
(?)
-  $ hg debugwaitonrepack >/dev/null 2>%1
+  $ hg debugwaitonrepack >/dev/null 2>&1
 
   $ find $CACHEDIR -type f | sort
   
$TESTTMP/hgcache/master/packs/8f1443d44e57fec96f72fb2412e01d2818767ef2.histidx




D7586: remotefilelog: have command wait for background task in the tests

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  We leverage the feature introduced in the two previous commit to have the main
  command wait for the background task to be finished before returning.
  
  All test still pass and instability seems to have gone away.
  
  Most of the sleep and explicit wait are now useless and will be cleaned up in
  later changesets.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-remotefilelog-bgprefetch.t
  tests/test-remotefilelog-repack-fast.t
  tests/test-remotefilelog-repack.t

CHANGE DETAILS

diff --git a/tests/test-remotefilelog-repack.t 
b/tests/test-remotefilelog-repack.t
--- a/tests/test-remotefilelog-repack.t
+++ b/tests/test-remotefilelog-repack.t
@@ -6,6 +6,7 @@
   $ cat >> $HGRCPATH < [devel]
   > remotefilelog.ensurestart=True
+  > remotefilelog.bg-wait=True
   > EOF
 
   $ hg init master
diff --git a/tests/test-remotefilelog-repack-fast.t 
b/tests/test-remotefilelog-repack-fast.t
--- a/tests/test-remotefilelog-repack-fast.t
+++ b/tests/test-remotefilelog-repack-fast.t
@@ -8,6 +8,7 @@
   > fastdatapack=True
   > [devel]
   > remotefilelog.ensurestart=True
+  > remotefilelog.bg-wait=True
   > EOF
 
   $ hg init master
diff --git a/tests/test-remotefilelog-bgprefetch.t 
b/tests/test-remotefilelog-bgprefetch.t
--- a/tests/test-remotefilelog-bgprefetch.t
+++ b/tests/test-remotefilelog-bgprefetch.t
@@ -6,6 +6,7 @@
   $ cat >> $HGRCPATH < [devel]
   > remotefilelog.ensurestart=True
+  > remotefilelog.bg-wait=True
   > EOF
 
   $ hg init master



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


D7585: remotefilelog: add a developer option to wait for background processes

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  Currently, in the tests, most operation spawning background process as 
followed
  by commands waiting for these operations to complete. However this waiting is
  racy. First because it seems like we can start waiting before the background
  operation actually start, in which case it is prematurely detected as "done".
  Second, because some commands may spawn multiple background operation for the
  same operation (eg: rebase can apparently trigger multiple prefetch). The
  current approach could be updated to maybe handle the first issue, but the
  second one will never be properly handled.
  
  In most case, we do not care that the bg process keep running after the 
command
  end. (Since we explicitly wait for them to end before doing anything else).  
So
  we add an option to wait on the background process before exiting the command.
  We'll put it in use in the next changeset.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/remotefilelog/__init__.py
  hgext/remotefilelog/repack.py
  hgext/remotefilelog/shallowrepo.py

CHANGE DETAILS

diff --git a/hgext/remotefilelog/shallowrepo.py 
b/hgext/remotefilelog/shallowrepo.py
--- a/hgext/remotefilelog/shallowrepo.py
+++ b/hgext/remotefilelog/shallowrepo.py
@@ -232,8 +232,12 @@
 cmd += [b'-r', revs]
 # We know this command will find a binary, so don't block
 # on it starting.
+kwargs = {}
+if repo.ui.configbool(b'devel', b'remotefilelog.bg-wait'):
+kwargs['record_wait'] = repo.ui.atexit
+
 procutil.runbgcommand(
-cmd, encoding.environ, ensurestart=ensurestart
+cmd, encoding.environ, ensurestart=ensurestart, **kwargs
 )
 
 def prefetch(self, revs, base=None, pats=None, opts=None):
diff --git a/hgext/remotefilelog/repack.py b/hgext/remotefilelog/repack.py
--- a/hgext/remotefilelog/repack.py
+++ b/hgext/remotefilelog/repack.py
@@ -48,7 +48,13 @@
 cmd.append(b'--packsonly')
 repo.ui.warn(msg)
 # We know this command will find a binary, so don't block on it starting.
-procutil.runbgcommand(cmd, encoding.environ, ensurestart=ensurestart)
+kwargs = {}
+if repo.ui.configbool(b'devel', b'remotefilelog.bg-wait'):
+kwargs['record_wait'] = repo.ui.atexit
+
+procutil.runbgcommand(
+cmd, encoding.environ, ensurestart=ensurestart, **kwargs
+)
 
 
 def fullrepack(repo, options=None):
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -230,6 +230,7 @@
 configitem(b'packs', b'maxchainlen', default=1000)
 
 configitem(b'devel', b'remotefilelog.ensurestart', default=False)
+configitem(b'devel', b'remotefilelog.bg-wait', default=False)
 
 #  default TTL limit is 30 days
 _defaultlimit = 60 * 60 * 24 * 30



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


D7584: procutil: add a option to not fully detach background process

2019-12-09 Thread marmoute (Pierre-Yves David)
marmoute created this revision.
marmoute added a comment.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.


  target is the stable-branch

REVISION SUMMARY
  When writing test, it is useful to make code pretending to spawn a fully
  detached process while still actually waiting for it to finish. We add the
  option to `procutil.runbgcommand`, to do so. We will use this in 
remote-filelog
  tests.

REPOSITORY
  rHG Mercurial

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

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
@@ -548,12 +548,18 @@
 _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
 def runbgcommand(
-script, env, shell=False, stdout=None, stderr=None, ensurestart=True
+script,
+env,
+shell=False,
+stdout=None,
+stderr=None,
+ensurestart=True,
+record_wait=None,
 ):
 '''Spawn a command without waiting for it to finish.'''
 # we can't use close_fds *and* redirect stdin. I'm not sure that we
 # need to because the detached process has no console connection.
-subprocess.Popen(
+p = subprocess.Popen(
 tonativestr(script),
 shell=shell,
 env=tonativeenv(env),
@@ -562,46 +568,64 @@
 stdout=stdout,
 stderr=stderr,
 )
+if record_wait is not None:
+record_wait(p.wait)
 
 
 else:
 
 def runbgcommand(
-cmd, env, shell=False, stdout=None, stderr=None, ensurestart=True
+cmd,
+env,
+shell=False,
+stdout=None,
+stderr=None,
+ensurestart=True,
+record_wait=None,
 ):
-'''Spawn a command without waiting for it to finish.'''
+'''Spawn a command without waiting for it to finish.
+
+
+When `register_wait` is not None, the spawned process will not be fully
+detached and the `record_wait` argument will be called with a the
+`Subprocess.wait` function for the spawned process.  This is mostly
+useful for developper that need to make sure the spawned process
+finished before a certain point. (eg: writing test)'''
 # double-fork to completely detach from the parent process
 # based on http://code.activestate.com/recipes/278731
-pid = os.fork()
-if pid:
-if not ensurestart:
+if record_wait is None:
+pid = os.fork()
+if pid:
+if not ensurestart:
+return
+# Parent process
+(_pid, status) = os.waitpid(pid, 0)
+if os.WIFEXITED(status):
+returncode = os.WEXITSTATUS(status)
+else:
+returncode = -(os.WTERMSIG(status))
+if returncode != 0:
+# The child process's return code is 0 on success, an errno
+# value on failure, or 255 if we don't have a valid errno
+# value.
+#
+# (It would be slightly nicer to return the full exception 
info
+# over a pipe as the subprocess module does.  For now it
+# doesn't seem worth adding that complexity here, though.)
+if returncode == 255:
+returncode = errno.EINVAL
+raise OSError(
+returncode,
+b'error running %r: %s'
+% (cmd, os.strerror(returncode)),
+)
 return
-# Parent process
-(_pid, status) = os.waitpid(pid, 0)
-if os.WIFEXITED(status):
-returncode = os.WEXITSTATUS(status)
-else:
-returncode = -(os.WTERMSIG(status))
-if returncode != 0:
-# The child process's return code is 0 on success, an errno
-# value on failure, or 255 if we don't have a valid errno
-# value.
-#
-# (It would be slightly nicer to return the full exception info
-# over a pipe as the subprocess module does.  For now it
-# doesn't seem worth adding that complexity here, though.)
-if returncode == 255:
-returncode = errno.EINVAL
-raise OSError(
-returncode,
-b'error running %r: %s' % (cmd, os.strerror(returncode)),
-)
-return
 
 returncode = 255
 try:
-# Start a new session
-os.setsid()
+if record_wait is None:
+# Start a new session
+os.setsid()
 
  

D7575: hg-core: vendor Facebook's configparser crate

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

INLINE COMMENTS

> Alphare wrote in hg.rs:226
> This function looks very Facebook specific, I don't think we want to include 
> it at all.

My bad, it looks like you took care of it in a future patch.

REPOSITORY
  rHG Mercurial

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

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

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


D7576: hg-core: add configparser to library

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

INLINE COMMENTS

> Cargo.toml:19
>  memchr = "2.2.0"
> +parking_lot = "0.9"
> +pest = "2.1.0"

"The current minimum required Rust version is 1.36". This disqualifies this 
crate from being used in `hg-core` right now. Good news is that it is supposed 
to offer improvements over existing `std` types like `Mutex` and the like, so 
it's nothing that would be hard to replace.

Also, I've seen complaints online about the lack of benchmarks of `parking_lot` 
against `std` types to back-up their claims for performance. I have not looked 
into it myself.

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


D7577: hg-core: implement Mercurial's config file discovery logic

2019-12-09 Thread kevincox (Kevin Cox)
kevincox added inline comments.
kevincox accepted this revision.

INLINE COMMENTS

> config.rs:145
> +let paths = glob_res
> +.filter_map(|x| if let Ok(x) = x { Some(x) } else { None })
> +.sorted();

I believe this can just be `.flatten()`.

REPOSITORY
  rHG Mercurial

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

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

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


D7575: hg-core: vendor Facebook's configparser crate

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

INLINE COMMENTS

> c_api.rs:1
> +/*
> + * Copyright (c) Facebook, Inc. and its affiliates.

Do we need bindings to C ? I don't see what the use-case is at this stage of 
the Rust development.

> quark wrote in hg.rs:262-263
> You might want to respect `$PAGER`. We ignored it to reduce support burden 
> for mis-configuration.

+1

> hg.rs:226
> +impl ConfigSetHgExt for ConfigSet {
> +fn load_system( self) -> Vec {
> +let opts = Options::new().source("system").process_hgplain();

This function looks very Facebook specific, I don't think we want to include it 
at all.

> hg.rs:413
> +
> +impl FromConfigValue for String {
> +fn try_from_bytes(bytes: &[u8]) -> Result {

Our current strategy is to assume config files to be in local encoding, not 
UTF-8. This makes sense from Facebook's perspective, but now as an upstream 
solution (see previous work on `HgPath`).

> hg.rs:595
> +let branch = {
> +match parts.last() {
> +None => 1,

Is this hack still needed as of `1.34.2`?

> spec.pest:63
> +compound = _{ (config_item | section | comment_line | directive | blank_line 
> ) }
> +file = _{ SOI ~ compound ~ (new_line ~ compound)* ~ EOI }

`pest` is really cool.

REPOSITORY
  rHG Mercurial

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

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

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


D7574: hg-core: add utils::path to project

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

INLINE COMMENTS

> Cargo.toml:12
>  [dependencies]
> +anyhow = "1.0.20"
>  byteorder = "1.3.1"

Should we adopt this crate for error handling?

I feel like our current solution - although it might need a refactor - is good 
at forcing the programmer to provide context with finer-grained errors that 
what you are required to do with `anyhow`.  I actually like `anyhow` better 
than more involved crates, but we will need to have a good "error hygiene" if 
you will.

This seems like a better place to discuss this than the previous patch.

REPOSITORY
  rHG Mercurial

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

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

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


D7573: hg-core: vendor Facebook's path utils module

2019-12-09 Thread Raphaël Gomès
Alphare added inline comments.
Alphare accepted this revision.

INLINE COMMENTS

> path.rs:169
> +//
> +// XXX: Doing this preprocessing has the unfortunate side-effect that
> +// if an environment variable fails to expand on Windows, the resulting

Would it take a lot of effort to rectify this behavior?

REPOSITORY
  rHG Mercurial

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

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

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