Re: [PATCH] mdiff: split on unicode character boundaries when shortening function name

2018-02-22 Thread Denis Laxalde
Josef 'Jeff' Sipek wrote:
> # HG changeset patch
> # User Josef 'Jeff' Sipek 
> # Date 1519251311 18000
> #  Wed Feb 21 17:15:11 2018 -0500
> # Node ID b99df94fdd4813e0ce538a8caa682802da4a6cb2
> # Parent  106872aa15af9919220705ed72c78459774e1575
> mdiff: split on unicode character boundaries when shortening function name
> 
> Splitting the raw bytes may lead to truncating the string in the middle of a
> UTF-8 character which would lead to the generated diff containing an invalid
> byte sequence even though the original data had none.  For example, the
> Unicode codepoint U+308B (る) gets represented as \xe3\x82\x8b in UTF-8.
> Before this change a diff on i18n/ja.po would yield:
> 
>   @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用す<82>
> 
> After this change, the output is cleaner:
> 
>   @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用する場合の注意点:"
> 
> diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
> --- a/mercurial/mdiff.py
> +++ b/mercurial/mdiff.py
> @@ -348,7 +348,12 @@ def _unidiff(t1, t2, opts=defaultopts):
>  # alphanumeric char.
>  for i in xrange(astart - 1, lastpos - 1, -1):
>  if l1[i][0:1].isalnum():
> -func = ' ' + l1[i].rstrip()[:40]
> +func = l1[i].rstrip()
> +try:
> +func = func.decode("utf-8")[:40].encode("utf-8")
> +except:
> +func = func[:40]

I'd suggest catching exception types explicitly (UnicodeDecodeError and
UnicodeEncodeError I guess) and avoid "bare" except.

(No idea if the change itself is correct by the way.)

> +func = ' ' + func
>  lastfunc[1] = func
>  break
>  # by recording this hunk's starting point as the next place to
> ___
> 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


D2377: util: add a file object proxy that can read at most N bytes

2018-02-22 Thread lothiraldan (Boris Feld)
lothiraldan accepted this revision.
lothiraldan added a comment.


  LGTM

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH STABLE] graphlog: document what "_" and "*" mean

2018-02-22 Thread Feld Boris

LGTM


On 22/02/2018 08:34, Anton Shestakov wrote:

# HG changeset patch
# User Anton Shestakov 
# Date 1519283924 -28800
#  Thu Feb 22 15:18:44 2018 +0800
# Branch stable
# Node ID a1b8de1983b1c5421f7c7195e01b20df5306500a
# Parent  c19e66dacaa184feba31136c18a369ba995ddfe4
graphlog: document what "_" and "*" mean

Documenting "*" should've been a part of 9b3f95d9783d, but I somehow didn't
notice that the symbols are explained in the command's help text.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3301,9 +3301,10 @@ def log(ui, repo, *pats, **opts):
  
  With --graph the revisions are shown as an ASCII art DAG with the most

  recent changeset at the top.
-'o' is a changeset, '@' is a working directory parent, 'x' is obsolete,
-and '+' represents a fork where the changeset from the lines below is a
-parent of the 'o' merge on the same line.
+'o' is a changeset, '@' is a working directory parent, '_' closes a branch,
+'x' is obsolete, '*' is unstable, and '+' represents a fork where the
+changeset from the lines below is a parent of the 'o' merge on the same
+line.
  Paths in the DAG are represented with '|', '/' and so forth. ':' in place
  of a '|' indicates one or more revisions in a path are omitted.
  
___

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


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


[PATCH V2] patches: release the GIL while applying the patch

2018-02-22 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1517839431 -3600
#  Mon Feb 05 15:03:51 2018 +0100
# Node ID 585005c9c4901f4f94847e8637fbc58cc5b29c56
# Parent  0c34cb461a1ea5d3f8e1300e0b8bc16ed8fa8802
# EXP-Topic parallel-patching
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
585005c9c490
patches: release the GIL while applying the patch

This will allow multiple threads to apply patches at the same time.

diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
--- a/mercurial/cext/mpatch.c
+++ b/mercurial/cext/mpatch.c
@@ -109,7 +109,9 @@ static PyObject *patches(PyObject *self,
goto cleanup;
}
out = PyBytes_AsString(result);
+   Py_BEGIN_ALLOW_THREADS
r = mpatch_apply(out, in, inlen, patch);
+   Py_END_ALLOW_THREADS
if (r < 0) {
Py_DECREF(result);
result = NULL;
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2090: fancyopts: add support for custom multi-arg opts in fancyopts.py

2018-02-22 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> fancyopts.py:258
> +elif isinstance(default, list):
> +return _listopt(default[:])
> +elif type(default) is type(1):

Perhaps it's safer to make `defaultvalue()` a function returning
a copy of default, instead of passing a copy to `_listopt()`.

If we make `_listopt` public and start putting it into the static command
table, things will go wrong.

REPOSITORY
  rHG Mercurial

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

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


mercurial@36352: 15 new changesets

2018-02-22 Thread Mercurial Commits
15 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/ddd9474d2e08
changeset:   36338:ddd9474d2e08
user:Martin von Zweigbergk 
date:Tue Feb 06 08:48:05 2018 -0800
summary: walkrepos: don't reimplement any()

https://www.mercurial-scm.org/repo/hg/rev/a4d41ba4ad23
changeset:   36339:a4d41ba4ad23
user:Martin von Zweigbergk 
date:Tue Feb 06 08:49:37 2018 -0800
summary: verify: don't reimplement any()

https://www.mercurial-scm.org/repo/hg/rev/06464d1ce6cd
changeset:   36340:06464d1ce6cd
user:Martin von Zweigbergk 
date:Tue Feb 06 08:52:12 2018 -0800
summary: convert: don't reimplement any()

https://www.mercurial-scm.org/repo/hg/rev/28a97cf212af
changeset:   36341:28a97cf212af
user:Martin von Zweigbergk 
date:Tue Feb 06 08:54:36 2018 -0800
summary: strip: don't reimplement any()

https://www.mercurial-scm.org/repo/hg/rev/02c35e640b3c
changeset:   36342:02c35e640b3c
user:Martin von Zweigbergk 
date:Tue Feb 06 08:55:54 2018 -0800
summary: mq: don't reimplement any()

https://www.mercurial-scm.org/repo/hg/rev/c8891cc3fa9e
changeset:   36343:c8891cc3fa9e
user:Martin von Zweigbergk 
date:Tue Feb 06 08:57:22 2018 -0800
summary: mq: don't reimplement any()

https://www.mercurial-scm.org/repo/hg/rev/a65502597d8d
changeset:   36344:a65502597d8d
user:Augie Fackler 
date:Wed Feb 21 09:43:35 2018 -0500
summary: py3: whitelist another eight passing tests

https://www.mercurial-scm.org/repo/hg/rev/f85e32a5e5c8
changeset:   36345:f85e32a5e5c8
user:Augie Fackler 
date:Wed Feb 21 10:08:35 2018 -0500
summary: narrow: use list comprehension instead of filter for filtering 
lists

https://www.mercurial-scm.org/repo/hg/rev/f62369667a7c
changeset:   36346:f62369667a7c
user:Augie Fackler 
date:Wed Feb 21 10:10:02 2018 -0500
summary: py3: use list comprehensions instead of filter where we need to 
eagerly filter

https://www.mercurial-scm.org/repo/hg/rev/f6ddbcff5d7b
changeset:   36347:f6ddbcff5d7b
user:Augie Fackler 
date:Wed Feb 21 11:56:22 2018 -0500
summary: tests: port extension in test-narrow-expanddirstate.t to Python 3

https://www.mercurial-scm.org/repo/hg/rev/f3b9377d6aea
changeset:   36348:f3b9377d6aea
user:Augie Fackler 
date:Wed Feb 21 11:58:41 2018 -0500
summary: narrowbundle2: this dict contains native strings, look kws up as 
such

https://www.mercurial-scm.org/repo/hg/rev/658d694a656e
changeset:   36349:658d694a656e
user:Augie Fackler 
date:Wed Feb 21 19:11:11 2018 -0800
summary: narrowbundle2: replace map() with equivalent list comprehension

https://www.mercurial-scm.org/repo/hg/rev/ff7a19ad7aa3
changeset:   36350:ff7a19ad7aa3
user:Augie Fackler 
date:Wed Feb 21 12:03:44 2018 -0500
summary: narrowchangegroup: remove backwards compatibility with old hg

https://www.mercurial-scm.org/repo/hg/rev/87e950a070e6
changeset:   36351:87e950a070e6
user:Augie Fackler 
date:Wed Feb 21 11:56:51 2018 -0500
summary: narrowwirepeer: add some strkwargs to fix a crash on py3

https://www.mercurial-scm.org/repo/hg/rev/5dbeddbf164a
changeset:   36352:5dbeddbf164a
bookmark:@
tag: tip
user:Augie Fackler 
date:Wed Feb 21 11:57:11 2018 -0500
summary: narrowcommands: add some missing strkwargs calls for py3

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


Re: [PATCH STABLE] graphlog: document what "_" and "*" mean

2018-02-22 Thread Yuya Nishihara
On Thu, 22 Feb 2018 15:34:03 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov 
> # Date 1519283924 -28800
> #  Thu Feb 22 15:18:44 2018 +0800
> # Branch stable
> # Node ID a1b8de1983b1c5421f7c7195e01b20df5306500a
> # Parent  c19e66dacaa184feba31136c18a369ba995ddfe4
> graphlog: document what "_" and "*" mean

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


Re: [PATCH V2] patches: release the GIL while applying the patch

2018-02-22 Thread Yuya Nishihara
On Thu, 22 Feb 2018 12:10:12 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1517839431 -3600
> #  Mon Feb 05 15:03:51 2018 +0100
> # Node ID 585005c9c4901f4f94847e8637fbc58cc5b29c56
> # Parent  0c34cb461a1ea5d3f8e1300e0b8bc16ed8fa8802
> # EXP-Topic parallel-patching
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 585005c9c490
> patches: release the GIL while applying the patch
> 
> This will allow multiple threads to apply patches at the same time.
> 
> diff --git a/mercurial/cext/mpatch.c b/mercurial/cext/mpatch.c
> --- a/mercurial/cext/mpatch.c
> +++ b/mercurial/cext/mpatch.c
> @@ -109,7 +109,9 @@ static PyObject *patches(PyObject *self,
>   goto cleanup;
>   }
>   out = PyBytes_AsString(result);
> + Py_BEGIN_ALLOW_THREADS
>   r = mpatch_apply(out, in, inlen, patch);
> + Py_END_ALLOW_THREADS

Bad macro. I've inserted one more block to make clang-format happy.

/* clang-format off */
{
Py_BEGIN_ALLOW_THREADS
r = mpatch_apply(out, in, inlen, patch);
Py_END_ALLOW_THREADS
}
/* clang-format on */
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] help: fix wording describing SSH requirements

2018-02-22 Thread Yuya Nishihara
On Wed, 21 Feb 2018 17:51:08 -0500, Josef 'Jeff' Sipek wrote:
> # HG changeset patch
> # User Josef 'Jeff' Sipek 
> # Date 1519249869 18000
> #  Wed Feb 21 16:51:09 2018 -0500
> # Node ID 106872aa15af9919220705ed72c78459774e1575
> # Parent  c8891cc3fa9ec855a3bdefd3dd759d19927c6b85
> help: fix wording describing SSH requirements

Queued for stable, thanks.

Dropped i18n/*.po changes. You don't need to update i18n/*.po files, which
are managed separately.

https://www.mercurial-scm.org/wiki/TranslatingMercurial
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] mdiff: split on unicode character boundaries when shortening function name

2018-02-22 Thread Yuya Nishihara
On Thu, 22 Feb 2018 09:01:14 +0100, Denis Laxalde wrote:
> Josef 'Jeff' Sipek wrote:
> > # HG changeset patch
> > # User Josef 'Jeff' Sipek 
> > # Date 1519251311 18000
> > #  Wed Feb 21 17:15:11 2018 -0500
> > # Node ID b99df94fdd4813e0ce538a8caa682802da4a6cb2
> > # Parent  106872aa15af9919220705ed72c78459774e1575
> > mdiff: split on unicode character boundaries when shortening function name
> > 
> > Splitting the raw bytes may lead to truncating the string in the middle of a
> > UTF-8 character which would lead to the generated diff containing an invalid
> > byte sequence even though the original data had none.  For example, the
> > Unicode codepoint U+308B (る) gets represented as \xe3\x82\x8b in UTF-8.
> > Before this change a diff on i18n/ja.po would yield:
> > 
> > @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用す<82>
> > 
> > After this change, the output is cleaner:
> > 
> > @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用する場合の注意点:"
> > 
> > diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
> > --- a/mercurial/mdiff.py
> > +++ b/mercurial/mdiff.py
> > @@ -348,7 +348,12 @@ def _unidiff(t1, t2, opts=defaultopts):
> >  # alphanumeric char.
> >  for i in xrange(astart - 1, lastpos - 1, -1):
> >  if l1[i][0:1].isalnum():
> > -func = ' ' + l1[i].rstrip()[:40]
> > +func = l1[i].rstrip()
> > +try:
> > +func = func.decode("utf-8")[:40].encode("utf-8")
> > +except:
> > +func = func[:40]
> 
> I'd suggest catching exception types explicitly (UnicodeDecodeError and
> UnicodeEncodeError I guess) and avoid "bare" except.
> 
> (No idea if the change itself is correct by the way.)

Nah, it's wrong to assume external world is always UTF-8. It might be okayish
to split func as a UTF-8 as best effort, but which shouldn't involve encoding
conversion.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH V2] patches: release the GIL while applying the patch

2018-02-22 Thread Yuya Nishihara
On Thu, 22 Feb 2018 12:10:12 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1517839431 -3600
> #  Mon Feb 05 15:03:51 2018 +0100
> # Node ID 585005c9c4901f4f94847e8637fbc58cc5b29c56
> # Parent  0c34cb461a1ea5d3f8e1300e0b8bc16ed8fa8802
> # EXP-Topic parallel-patching
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 585005c9c490
> patches: release the GIL while applying the patch
> 
> This will allow multiple threads to apply patches at the same time.

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


Re: [PATCH 2 of 2] perfbranchmap: allow to select the filter to benchmark

2018-02-22 Thread Yuya Nishihara
On Wed, 21 Feb 2018 15:38:12 +0100, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1519209792 -3600
> #  Wed Feb 21 11:43:12 2018 +0100
> # Node ID ddab5cae846a3e05ec4b951472e562fce06301ea
> # Parent  f40e09835c645bbc0b535228ac743d84e952f866
> # EXP-Topic filter-perfbranchmap
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> ddab5cae846a
> perfbranchmap: allow to select the filter to benchmark

Queued, thanks.

> @@ -1591,6 +1593,9 @@ def perfbranchmap(ui, repo, full=False, 
>  return d
>  # add filter in smaller subset to bigger subset
>  possiblefilters = set(repoview.filtertable)
> +print("FILTERNAMES", filternames)

Looks like a debug print. Removed in flight.
If you really need it, please use ui.status() or something.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: D2297: py3: backout 7c54917b31f6 to make sure second argument of open() is str

2018-02-22 Thread Yuya Nishihara
"There are around 100 occurences of open() call, it's better if we can
prevent replacing all these calls
"In future, when we will dropping all the compatibility code, we don't have
to take care of changing pycompat.open back to open

Yeah, that's the point why we have `from pycompat import open` to compensate
the mess introduced by our code transformer. We want to keep 'rb' without b''.
We could do that by the transformer, but I think it's better to keep the
transformer less complicated.

FWIW, we'll need to port many of these 100 open() calls to vfs. I have vague
memory that Python 3.5 or 3.6 introduced another mess on Windows I/O around
ANSI vs Unicode.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2297: py3: backout 7c54917b31f6 to make sure second argument of open() is str

2018-02-22 Thread yuja (Yuya Nishihara)
yuja added a comment.


  "There are around 100 occurences of open() call, it's better if we can
  prevent replacing all these calls
  "In future, when we will dropping all the compatibility code, we don't have
  to take care of changing pycompat.open back to open
  
  Yeah, that's the point why we have `from pycompat import open` to compensate
  the mess introduced by our code transformer. We want to keep 'rb' without b''.
  We could do that by the transformer, but I think it's better to keep the
  transformer less complicated.
  
  FWIW, we'll need to port many of these 100 open() calls to vfs. I have vague
  memory that Python 3.5 or 3.6 introduced another mess on Windows I/O around
  ANSI vs Unicode.

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH] mdiff: split on unicode character boundaries when shortening function name

2018-02-22 Thread Yuya Nishihara
On Thu, 22 Feb 2018 10:01:00 -0500, Josef 'Jeff' Sipek wrote:
> On Thu, Feb 22, 2018 at 21:01:44 +0900, Yuya Nishihara wrote:
> > On Thu, 22 Feb 2018 09:01:14 +0100, Denis Laxalde wrote:
> > > Josef 'Jeff' Sipek wrote:
> > > > # HG changeset patch
> > > > # User Josef 'Jeff' Sipek 
> > > > # Date 1519251311 18000
> > > > #  Wed Feb 21 17:15:11 2018 -0500
> > > > # Node ID b99df94fdd4813e0ce538a8caa682802da4a6cb2
> > > > # Parent  106872aa15af9919220705ed72c78459774e1575
> > > > mdiff: split on unicode character boundaries when shortening function 
> > > > name
> > > > 
> > > > Splitting the raw bytes may lead to truncating the string in the middle 
> > > > of a
> > > > UTF-8 character which would lead to the generated diff containing an 
> > > > invalid
> > > > byte sequence even though the original data had none.  For example, the
> > > > Unicode codepoint U+308B (る) gets represented as \xe3\x82\x8b in UTF-8.
> > > > Before this change a diff on i18n/ja.po would yield:
> > > > 
> > > > @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用す<82>
> > > > 
> > > > After this change, the output is cleaner:
> > > > 
> > > > @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用する場合の注意点:"
> > > > 
> > > > diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
> > > > --- a/mercurial/mdiff.py
> > > > +++ b/mercurial/mdiff.py
> > > > @@ -348,7 +348,12 @@ def _unidiff(t1, t2, opts=defaultopts):
> > > >  # alphanumeric char.
> > > >  for i in xrange(astart - 1, lastpos - 1, -1):
> > > >  if l1[i][0:1].isalnum():
> > > > -func = ' ' + l1[i].rstrip()[:40]
> > > > +func = l1[i].rstrip()
> > > > +try:
> > > > +func = 
> > > > func.decode("utf-8")[:40].encode("utf-8")
> > > > +except:
> > > > +func = func[:40]
> > > 
> > > I'd suggest catching exception types explicitly (UnicodeDecodeError and
> > > UnicodeEncodeError I guess) and avoid "bare" except.
> > > 
> > > (No idea if the change itself is correct by the way.)
> > 
> > Nah, it's wrong to assume external world is always UTF-8. It might be 
> > okayish
> > to split func as a UTF-8 as best effort, but which shouldn't involve 
> > encoding
> > conversion.
> 
> Yeah... I thought that might be an issue.  The code in the 'except' is meant
> as best-effort -

Ok, I didn't notice that. It's indeed better to catch the UnicodeError.

That said, UTF-8 is well designed encoding, we can easily find the nearest
multi-byte boundary by looking back a couple of bytes.

https://en.wikipedia.org/wiki/UTF-8#Description

> if there is any UTF-8 issue decoding/encoding, just fall
> back to previous method.  That of course wouldn't help if the input happened
> to be valid UTF-8 but wasn't actually UTF-8.
> 
> I had to do the encode step, otherwise I got a giant stack trace saying that
> unicode strings cannot be  using ascii encoder.
> (Leaving it un-encoded would also mean that this for loop would output
> either a unicode string or a raw string - which seems unclean.)
> 
> I'm not really sure how to proceed.  Most UTF-8 decoders should handle the
> illegal byte sequence ok, but it still feels wrong to let it make a mess of
> valid data.  The answer might be to just ignore this issue.  :|

As an old Linux user, I would say yeah, don't bother about non-ascii characters,
it's just bytes. Alternatively, maybe we could take it a UTF-8 sequence and find
a possible boundary, but I'm not sure if it's a good idea.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 5801] New: pure-python manifest code produces corrupt unsorted manifests

2018-02-22 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5801

Bug ID: 5801
   Summary: pure-python manifest code produces corrupt unsorted
manifests
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Mac OS
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@mercurial-scm.org
  Reporter: duri...@gmail.com
CC: mercurial-devel@mercurial-scm.org

The only steps to reproduce I have right now involve a repo from timeless
that's a conversion of hg-git, but I can reliably build a corrupt commit with a
merge of two revisions if I use HGMODULEPOLICY=py. If I use HGMODULEPOLICY=c,
the problem doesn't happen.

This does appear to be rare, and the resulting manifest can't even be checked
out so it's obvious *right away* something is borked, but we should still
address this promptly, probably with backports to older versions...

Here's the traceback:

Traceback (most recent call last):
  File "/opt/hg/bin/hg", line 41, in 
dispatch.run()
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 88, in run
status = (dispatch(req) or 0) & 255
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 183, in dispatch
ret = _runcatch(req)
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 324, in _runcatch
return _callcatch(ui, _runcatchfunc)
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 332, in _callcatch
return scmutil.callcatch(ui, func)
  File "/opt/hg/lib/python/mercurial/scmutil.py", line 154, in callcatch
return func()
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 314, in _runcatchfunc
return _dispatch(req)
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 917, in _dispatch
cmdpats, cmdoptions)
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 674, in runcommand
ret = _runcommand(ui, options, cmd, d)
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 925, in _runcommand
return cmdfunc()
  File "/opt/hg/lib/python/mercurial/dispatch.py", line 914, in 
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
  File "/opt/hg/lib/python/mercurial/util.py", line 1228, in check
return func(*args, **kwargs)
  File "/opt/hg/lib/python/mercurial/util.py", line 1228, in check
return func(*args, **kwargs)
  File "/opt/hg/lib/python/hgext/mq.py", line 3590, in mqcommand
return orig(ui, repo, *args, **kwargs)
  File "/opt/hg/lib/python/mercurial/util.py", line 1228, in check
return func(*args, **kwargs)
  File "/opt/hg/lib/python/mercurial/commands.py", line 1963, in export
opts=patch.diffallopts(ui, opts))
  File "/opt/hg/lib/python/mercurial/cmdutil.py", line 1555, in export
repo, ctx, match, switch_parent, rev, seqno, write, opts)
  File "/opt/hg/lib/python/mercurial/cmdutil.py", line 1499, in _exportsingle
for chunk, label in patch.diffui(repo, prev, node, match, opts=diffopts):
  File "/opt/hg/lib/python/mercurial/patch.py", line 2486, in difflabel
for chunk in func(*args, **kw):
  File "/opt/hg/lib/python/mercurial/patch.py", line 2339, in diff
losedatafn=losedatafn, prefix=prefix, relroot=relroot, copy=copy,
  File "/opt/hg/lib/python/mercurial/patch.py", line 2396, in diffhunks
changes = repo.status(ctx1, ctx2, match=match)
  File "/opt/hg/lib/python/mercurial/localrepo.py", line 2055, in status
listsubrepos)
  File "/opt/hg/lib/python/mercurial/context.py", line 362, in status
listunknown)
  File "/opt/hg/lib/python/mercurial/context.py", line 131, in _buildstatus
mf2 = self._buildstatusmanifest(s)
  File "/opt/hg/lib/python/mercurial/context.py", line 109, in
_buildstatusmanifest
return self.manifest()
  File "/opt/hg/lib/python/mercurial/context.py", line 189, in manifest
return self._manifest
  File "/opt/hg/lib/python/mercurial/util.py", line 966, in __get__
result = self.func(obj)
  File "/opt/hg/lib/python/mercurial/context.py", line 547, in _manifest
return self._manifestctx.read()
  File "/opt/hg/lib/python/mercurial/manifest.py", line 1471, in read
self._data = manifestdict(text)
  File "/opt/hg/lib/python/mercurial/manifest.py", line 423, in __init__
self._lm = _lazymanifest(data)
ValueError: Manifest lines not in sorted order.

(from running `hg export` on a thusly corrupt revision)

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


Re: [PATCH] mdiff: split on unicode character boundaries when shortening function name

2018-02-22 Thread Josef 'Jeff' Sipek
On Fri, Feb 23, 2018 at 01:06:28 +0900, Yuya Nishihara wrote:
> On Thu, 22 Feb 2018 10:01:00 -0500, Josef 'Jeff' Sipek wrote:
...
> > Yeah... I thought that might be an issue.  The code in the 'except' is meant
> > as best-effort -
> 
> Ok, I didn't notice that. It's indeed better to catch the UnicodeError.
> 
> That said, UTF-8 is well designed encoding, we can easily find the nearest
> multi-byte boundary by looking back a couple of bytes.
> 
> https://en.wikipedia.org/wiki/UTF-8#Description

Right, but isn't this code required to handle any-to-any situation?  That
is, the versioned data can be in any encoding, and the terminal can be in
any encoding.  Currently, the code "handles" it by just copying bytes.  This
obviously breaks down the moment multi-byte characters show up.

UTF-8 being resilient is a good thing, but IMO that justifies leaving the
code alone.

I don't know if there is some weird variable length encoding (other than
UTF-8) out there that hg needs to handle.

> > if there is any UTF-8 issue decoding/encoding, just fall
> > back to previous method.  That of course wouldn't help if the input happened
> > to be valid UTF-8 but wasn't actually UTF-8.
> > 
> > I had to do the encode step, otherwise I got a giant stack trace saying that
> > unicode strings cannot be  using ascii encoder.
> > (Leaving it un-encoded would also mean that this for loop would output
> > either a unicode string or a raw string - which seems unclean.)
> > 
> > I'm not really sure how to proceed.  Most UTF-8 decoders should handle the
> > illegal byte sequence ok, but it still feels wrong to let it make a mess of
> > valid data.  The answer might be to just ignore this issue.  :|
> 
> As an old Linux user, I would say yeah, don't bother about non-ascii 
> characters,
> it's just bytes. Alternatively, maybe we could take it a UTF-8 sequence and 
> find
> a possible boundary, but I'm not sure if it's a good idea.

As in: implement a UTF-8 decoder to "seek" to the right place?  Eh.

I'm looking forward to the day when everything is only Unicode, but that'll
be a while...

Jeff.

-- 
Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former.
- Albert Einstein
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] namespace: fastpath name lookup on invalid name

2018-02-22 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1519313522 -3600
#  Thu Feb 22 16:32:02 2018 +0100
# Node ID b65a85952c09cf4c71a1458fbc4ec77c49683314
# Parent  428de1a59f2df3d6d07ff1d7164c8ee56cbb7825
# EXP-Topic noname
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
b65a85952c09
namespace: fastpath name lookup on invalid name

Since label cannot contains leading or trailing whitespace we can skip looking
for them. This is useful in repositories with slow labels (eg: special type of
tags). Short command running on a specific revision can benefit from such
shortcut.

eg on a repository where loading tags take 0.4s:

1: hg log --template '{node}\n' --rev 'rev(0)'
   0.560 seconds

2: hg log --template '{node}\n' --rev ' rev(0)'
   0.109 seconds

The changeset introduce a generic way to do such fast-pathing to help
extensions writer to apply the same principle to their extensions.

diff --git a/mercurial/namespaces.py b/mercurial/namespaces.py
--- a/mercurial/namespaces.py
+++ b/mercurial/namespaces.py
@@ -1,5 +1,7 @@
 from __future__ import absolute_import
 
+import re
+
 from .i18n import _
 from . import (
 templatekw,
@@ -15,6 +17,23 @@ def tolist(val):
 else:
 return [val]
 
+def lazynamemap(regexp, function):
+"""wrap a namemap function in order to call it only if the name matches a
+regexp
+"""
+namefilter = re.compile(regexp)
+
+def namemap(repo, name):
+if namefilter.match(name):
+return function(repo, name)
+return []
+return namemap
+
+# no ":", "\n", "\0", "\r" within the name, no " " around it.
+commonfilter = b'^[^ :\0\r\n]+([^:\0\r\n]*[^ :\0\r\n]+)?$'
+# at some point we allowed ":" in branch names.
+branchfilter = b'^[^ \0\r\n]+([^\0\r\n]*[^ \0\r\n]+)?$'
+
 class namespaces(object):
 """provides an interface to register and operate on multiple namespaces. 
See
 the namespace class below for details on the namespace object.
@@ -30,7 +49,8 @@ class namespaces(object):
 # we need current mercurial named objects (bookmarks, tags, and
 # branches) to be initialized somewhere, so that place is here
 bmknames = lambda repo: repo._bookmarks.keys()
-bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
+_bmknamemap = lambda repo, name: tolist(repo._bookmarks.get(name))
+bmknamemap = lazynamemap(commonfilter, _bmknamemap)
 bmknodemap = lambda repo, node: repo.nodebookmarks(node)
 n = namespace("bookmarks", templatename="bookmark",
   logfmt=columns['bookmark'],
@@ -40,7 +60,8 @@ class namespaces(object):
 self.addnamespace(n)
 
 tagnames = lambda repo: [t for t, n in repo.tagslist()]
-tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name))
+_tagnamemap = lambda repo, name: tolist(repo._tagscache.tags.get(name))
+tagnamemap = lazynamemap(commonfilter, _tagnamemap)
 tagnodemap = lambda repo, node: repo.nodetags(node)
 n = namespace("tags", templatename="tag",
   logfmt=columns['tag'],
@@ -51,7 +72,8 @@ class namespaces(object):
 self.addnamespace(n)
 
 bnames = lambda repo: repo.branchmap().keys()
-bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
+_bnamemap = lambda repo, name: tolist(repo.branchtip(name, True))
+bnamemap = lazynamemap(branchfilter, _bnamemap)
 bnodemap = lambda repo, node: [repo[node].branch()]
 n = namespace("branches", templatename="branch",
   logfmt=columns['branch'],
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Diff at end of commit message

2018-02-22 Thread Uwe Brauer
>>> "Stefan" == Stefan Schwarzer  writes:

> When I commit a change, I edit the commit message in the
> editor. Inside the editor, I like a diff of the changes
> that are about to be committed.

> I found out that I can set a template for the commit
> message in my Mercurial configuration file under
> `[committemplate]`. At the moment, I use

> [committemplate]
> changeset = {desc}\n
> HG: Enter commit message.  Lines beginning with 'HG:' are removed.
> HG: {extramsg}
> HG: --
> HG: user: {author}\n{ifeq(p2rev, "-1", "",
>"HG: branch merge\n")
>}HG: branch '{branch}'\n{if(activebookmark,
>"HG: bookmark '{activebookmark}'\n")   }{subrepos %
>"HG: subrepo {subrepo}\n"  }{file_adds %
>"HG: added {file}\n"   }{file_mods %
>"HG: changed {file}\n" }{file_dels %
>"HG: removed {file}\n" }{if(files, "",
>"HG: no files changed\n")}
>HG:  >8 
>HG: Do not touch the line above.
>HG: Everything below will be removed.
>{diff()}

> which I took from the `hgrc` manpage and added the `{diff()}`
> at the end.

Thanks, I just tried that out, and indeed your template shows up in my
editor (gnuclient) which I use for those purpose.

But then how to you display your message, sorry for this elementary
question but I played a bit around and it is not really display. I must
miss here something obvious.

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


D2392: debugcommands: add debugwireproto command

2018-02-22 Thread indygreg (Gregory Szorc)
indygreg added a subscriber: sid0.
indygreg added a comment.


  @sid0: I reckon we could find a way to take what I did in this commit and 
turn it into a wire protocol conformance tester. i.e. if we could refactor the 
test so it instantiates the server via alternate mechanisms, we could point the 
test at a separate server implementation as a means to tease out implementation 
differences. Just thought you'd like to know in case Mononoke would be 
interested in this.

REPOSITORY
  rHG Mercurial

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

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


D2393: cleanup: say goodbye to manifestv2 format

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

REVISION SUMMARY
  This experiment was a bust: we'd hoped for smaller repository sizes,
  but things got larger. Google ended up rolling out tree manifests in a
  format that's compatible with the original manifest format, and I
  believe Facebook is doing the same. This code was never implemented as
  native speedups, so I'm pretty comfortable saying nobody is using the
  experimental feature. Let's rip it out.
  
  I noticed this code still kicking around because I was investigating a
  repo corruption issue for timeless.
  
  .. bc::
  
Support for the experimental manifestv2 format has been removed, as
it was never completed and failed to meet expectations.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/help/internals/requirements.txt
  mercurial/localrepo.py
  mercurial/manifest.py
  mercurial/upgrade.py
  tests/test-manifest.py
  tests/test-manifestv2.t
  tests/test-upgrade-repo.t

CHANGE DETAILS

diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -31,23 +31,18 @@
   abort: cannot upgrade repository; unsupported source requirement: shared
   [255]
 
-Do not yet support upgrading manifestv2 and treemanifest repos
-
-  $ hg --config experimental.manifestv2=true init manifestv2
-  $ hg -R manifestv2 debugupgraderepo
-  abort: cannot upgrade repository; unsupported source requirement: manifestv2
-  [255]
+Do not yet support upgrading treemanifest repos
 
   $ hg --config experimental.treemanifest=true init treemanifest
   $ hg -R treemanifest debugupgraderepo
   abort: cannot upgrade repository; unsupported source requirement: 
treemanifest
   [255]
 
-Cannot add manifestv2 or treemanifest requirement during upgrade
+Cannot add treemanifest requirement during upgrade
 
   $ hg init disallowaddedreq
-  $ hg -R disallowaddedreq --config experimental.manifestv2=true --config 
experimental.treemanifest=true debugupgraderepo
-  abort: cannot upgrade repository; do not support adding requirement: 
manifestv2, treemanifest
+  $ hg -R disallowaddedreq --config experimental.treemanifest=true 
debugupgraderepo
+  abort: cannot upgrade repository; do not support adding requirement: 
treemanifest
   [255]
 
 An upgrade of a repository created with recommended settings only suggests 
optimizations
diff --git a/tests/test-manifestv2.t b/tests/test-manifestv2.t
deleted file mode 100644
--- a/tests/test-manifestv2.t
+++ /dev/null
@@ -1,102 +0,0 @@
-Create repo with old manifest
-
-  $ cat << EOF >> $HGRCPATH
-  > [format]
-  > usegeneraldelta=yes
-  > EOF
-
-  $ hg init existing
-  $ cd existing
-  $ echo footext > foo
-  $ hg add foo
-  $ hg commit -m initial
-
-We're using v1, so no manifestv2 entry is in requires yet.
-
-  $ grep manifestv2 .hg/requires
-  [1]
-
-Let's clone this with manifestv2 enabled to switch to the new format for
-future commits.
-
-  $ cd ..
-  $ hg clone --pull existing new --config experimental.manifestv2=1
-  requesting all changes
-  adding changesets
-  adding manifests
-  adding file changes
-  added 1 changesets with 1 changes to 1 files
-  new changesets 0fc9a4fafa44
-  updating to branch default
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cd new
-
-Check that entry was added to .hg/requires.
-
-  $ grep manifestv2 .hg/requires
-  manifestv2
-
-Make a new commit.
-
-  $ echo newfootext > foo
-  $ hg commit -m new
-
-Check that the manifest actually switched to v2.
-
-  $ hg debugdata -m 0
-  foo\x0021e958b1dca695a60ee2e9cf151753204ee0f9e9 (esc)
-
-  $ hg debugdata -m 1
-  \x00 (esc)
-  \x00foo\x00 (esc)
-  I\xab\x7f\xb8(\x83\xcas\x15\x9d\xc2\xd3\xd3:5\x08\xbad5_ (esc)
-
-Check that manifestv2 is used if the requirement is present, even if it's
-disabled in the config.
-
-  $ echo newerfootext > foo
-  $ hg --config experimental.manifestv2=False commit -m newer
-
-  $ hg debugdata -m 2
-  \x00 (esc)
-  \x00foo\x00 (esc)
-  \xa6\xb1\xfb\xef]\x91\xa1\x19`\xf3.#\x90S\xf8\x06 \xe2\x19\x00 (esc)
-
-Check that we can still read v1 manifests.
-
-  $ hg files -r 0
-  foo
-
-  $ cd ..
-
-Check that entry is added to .hg/requires on repo creation
-
-  $ hg --config experimental.manifestv2=True init repo
-  $ cd repo
-  $ grep manifestv2 .hg/requires
-  manifestv2
-
-Set up simple repo
-
-  $ echo a > file1
-  $ echo b > file2
-  $ echo c > file3
-  $ hg ci -Aqm 'initial'
-  $ echo d > file2
-  $ hg ci -m 'modify file2'
-
-Check that 'hg verify', which uses manifest.readdelta(), works
-
-  $ hg verify
-  checking changesets
-  checking manifests
-  crosschecking files in changesets and manifests
-  checking files
-  3 files, 2 changesets, 4 total revisions
-
-Check that manifest revlog is smaller than for v1
-
-  $ hg debugindex -m
- revoffset  length  delta 

D2391: sshpeer: factor out code for creating peers from pipes

2018-02-22 Thread dhduvall (Danek Duvall)
dhduvall added inline comments.

INLINE COMMENTS

> sshpeer.py:537
> +
> +``path`` and ``path`` are stored on the eventual peer instance and may
> +not be used for anything meaningful.

That second `path` should be `proc`?

REPOSITORY
  rHG Mercurial

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

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


D2393: cleanup: say goodbye to manifestv2 format

2018-02-22 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  LGTM. Last time I was going to remove it, I left it in because Durham felt 
that it was useful for forcing him to not specialize the manifest API too much 
for how v1 works. I believe he's pretty much done with that now, so that should 
no longer be a reason to keep this around. Thanks for cleaning up.

INLINE COMMENTS

> manifest.py:537
> +def text(self):
> +# use (probably) native version for v1
> +return self._lm.text()

delete "for v1"?

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 2 of 2 RFC] dispatch: look up command by [:] syntax (PoC)

2018-02-22 Thread Anton Shestakov
On Thu, 22 Feb 2018 23:54:47 +0900
Yuya Nishihara  wrote:

> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1516798904 -32400
> #  Wed Jan 24 22:01:44 2018 +0900
> # Node ID cb9e1cad42a9a13f17c4c75d350cd509b08f4a21
> # Parent  e2030eaec92b1ed12577cbe48cd0495d106818a9
> dispatch: look up command by [:] syntax (PoC)
> 
> This allows us to run the show command without giving up our show alias.
> The separator ':' is copied from the merge-tools syntax, ":".
> 
>   [alias]
>   show = log -pvr
>   work = show:show work

This syntax looks alright to me as a user, but maybe this should also
support "internal:foo" form in addition to ":foo", in case people want
to spell it out, and to be fully compatible syntax-wise with
merge-tools. My thought is that if somebody asks why not use backslash
with core commands to avoid aliases (like in bash, e.g. \ls) then we
can say that this is simply 100% reuse of pre-existing syntax (in
addition to mentioning namespaces for extensions).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2392: debugcommands: add debugwireproto command

2018-02-22 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  We currently don't have a low-level mechanism for sending
  arbitrary wire protocol commands. Having a generic and robust
  mechanism for sending wire protocol commands, examining wire
  data, etc would make it vastly easier to test the wire protocol
  and debug server operation. This is a problem I've wanted a
  solution for numerous times, especially recently as I've been
  hacking on a new version of the wire protocol.
  
  This commit establishes a `hg debugwireproto` command for sending
  data to a peer.
  
  The command invents a mini language for specifying actions to take.
  This will enable a lot of flexibility for issuing commands and testing
  variations for how commands are sent.
  
  Right now, we only support low-level raw sends and receives. These
  are probably the least valuable commands to intended users of this
  command. But they are the most useful commands to implement to
  bootstrap the feature (I've chosen to reimplement test-ssh-proto.t
  using this command to prove its usefulness).
  
  We invent a mechanism to wrap a file object so we can observe
  activity on it. We have similar functionality in badserverext.py,
  but that's a test-only extension and is pretty specific to HTTP
  server. The new functionality needed to live in core because it
  needs to be accessible to `hg debugwireproto`.
  
  My eventual goal of `hg debugwireproto` is to allow calling wire
  protocol commands with a human-friendly interface. Essentially,
  people can type in a command name and arguments and
  `hg debugwireproto` will figure out how to send that on the wire.
  I'd love to eventually be able to save the server's raw response
  to a file. This would allow us to e.g. call "getbundle" wire
  protocol commands easily.
  
  test-ssh-proto.t has been updated to use the new command in lieu
  of piping directly to a server process. As part of the transition,
  test behavior improved. Before, we piped all request data to the
  server at once. Now, we have explicit control over the ordering of
  operations. e.g. we can send one command, receive its response,
  then send another command. This will allow us to more robustly
  test race conditions, buffering behavior, etc.
  
  There were some subtle changes in test behavior. For example,
  previous behavior would often send trailing newlines to the server.
  The new mechanism doesn't treat literal newlines specially and
  requires newlines be escaped in the payload.
  
  Because the new logging code is very low level, it is easy to
  introduce race conditions in tests. For example, the number of bytes
  returned by a read() may vary depending on load. This is why tests
  make heavy use of "readline" for consuming data: the result of
  that operation should be deterministic and not subject to race
  conditions. There are still some uses of "readavailable." However,
  those are only for reading from stderr. I was able to reproduce
  timing issues with my system under load when using "readavailable"
  globally. But if I "readline" to grab stdout, "readavailable"
  appears to work deterministically for stderr. I think this is
  because the server writes to stderr first. As long as the OS
  delivers writes to pipes in the same order they were made, this
  should work. If there are timing issues, we can introduce a
  mechanism to readline from stderr.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/debugcommands.py
  mercurial/util.py
  tests/test-completion.t
  tests/test-help.t
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -12,10 +12,29 @@
   $ echo 0 > foo
   $ hg -q add foo
   $ hg commit -m initial
-  $ cd ..
+
+A no-op connection performs a handshake
+
+  $ hg debugwireproto --localssh << EOF
+  > EOF
+  creating ssh peer from handshake results
+
+Raw peers don't perform any activity
+
+  $ hg debugwireproto --localssh --peer raw << EOF
+  > EOF
+  using raw connection to peer
+  $ hg debugwireproto --localssh --peer ssh1 << EOF
+  > EOF
+  creating ssh peer for wire protocol version 1
+  $ hg debugwireproto --localssh --peer ssh2 << EOF
+  > EOF
+  creating ssh peer for wire protocol version 2
 
 Test a normal behaving server, for sanity
 
+  $ cd ..
+
   $ hg --debug debugpeer ssh://user@dummy/server
   running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' 
(glob) (no-windows !)
   running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" 
(glob) (windows !)
@@ -33,26 +52,51 @@
 
 Server should answer the "hello" command in isolation
 
-  $ hg -R server serve --stdio << EOF
-  > hello
+  $ hg -R server debugwireproto --localssh --peer raw << EOF
+  > raw
+  > hello\n
+  > readline
+  > readline
   > EOF
-  384

D2391: sshpeer: factor out code for creating peers from pipes

2018-02-22 Thread indygreg (Gregory Szorc)
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  An upcoming commit will want to instantiate an SSH peer via
  an alternate mechanism that doesn't require running a new
  SSH command. To facilitate that, we extract the code for
  creating a peer from pipes to its own function.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -531,6 +531,35 @@
 # And handshake is performed before the peer is instantiated. So
 # we need no custom code.
 
+def makepeer(ui, path, proc, stdin, stdout, stderr):
+"""Make a peer instance from existing pipes.
+
+``path`` and ``path`` are stored on the eventual peer instance and may
+not be used for anything meaningful.
+
+``stdin``, ``stdout``, and ``stderr`` are the pipes connected to the
+SSH server's stdio handles.
+
+This function is factored out to allow creating peers that don't
+actually spawn a new process. It is useful for starting SSH protocol
+servers and clients via non-standard means, which can be useful for
+testing.
+"""
+try:
+protoname, caps = _performhandshake(ui, stdin, stdout, stderr)
+except Exception:
+_cleanuppipes(ui, stdout, stdin, stderr)
+raise
+
+if protoname == wireprotoserver.SSHV1:
+return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps)
+elif protoname == wireprotoserver.SSHV2:
+return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps)
+else:
+_cleanuppipes(ui, stdout, stdin, stderr)
+raise error.RepoError(_('unknown version of SSH protocol: %s') %
+  protoname)
+
 def instance(ui, path, create):
 """Create an SSH peer.
 
@@ -565,17 +594,4 @@
 proc, stdin, stdout, stderr = _makeconnection(ui, sshcmd, args, remotecmd,
   remotepath, sshenv)
 
-try:
-protoname, caps = _performhandshake(ui, stdin, stdout, stderr)
-except Exception:
-_cleanuppipes(ui, stdout, stdin, stderr)
-raise
-
-if protoname == wireprotoserver.SSHV1:
-return sshv1peer(ui, path, proc, stdin, stdout, stderr, caps)
-elif protoname == wireprotoserver.SSHV2:
-return sshv2peer(ui, path, proc, stdin, stdout, stderr, caps)
-else:
-_cleanuppipes(ui, stdout, stdin, stderr)
-raise error.RepoError(_('unknown version of SSH protocol: %s') %
-  protoname)
+return makepeer(ui, path, proc, stdin, stdout, stderr)



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


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-02-22 Thread sangeet259 (Sangeet Kumar Mishra)
sangeet259 updated this revision to Diff 6008.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2394?vs=6007=6008

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -422,7 +422,14 @@
 def fromrule(cls, state, rule):
 """Parses the given rule, returning an instance of the histeditaction.
 """
-rulehash = rule.strip().split(' ', 1)[0]
+ruleid = rule.strip().split(' ', 1)[0]
+# The ruleid can be anything like revison no,rulehashes, "tip","@" etc
+# Check for validation of rule ids and get the rulehash
+try:
+_ctx = scmutil.revsingle(state.repo, ruleid)
+rulehash = _ctx.hex()[:12]
+except RepoLookupError :
+raise error.ParseError("invalid changeset %s" % ruleid)
 try:
 rev = node.bin(rulehash)
 except TypeError:



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


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-02-22 Thread sangeet259 (Sangeet Kumar Mishra)
sangeet259 added a comment.


  **What I did**: @durin42 suggested in the issue page 
 that the error was in the 
`verify` function of the `histedit.py` file. But when I ran through debugger 
using a revision number, the code was throwing the error before it reaches the 
`verify` function. Specifically in the `fromrules` function of the 
`histedit.py` file.
  It was earlier only accepting rulehashes, I changed that to accept any revset 
using the `scmutil.revsingle` function suggested by @timeless on the IRC 
channel.

REPOSITORY
  rHG Mercurial

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

To: sangeet259, durin42, #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 6 remotenames-ext] Back out "remotenames: push anonymous head if --force is given"

2018-02-22 Thread Sean Farley

Ryan McElroy  writes:

> On 2/20/18 11:44 PM, Sean Farley wrote:
>> Ryan McElroy  writes:
>>
>>> # HG changeset patch
>>> # User Ryan McElroy 
>>> # Date 1519040197 28800
>>> #  Mon Feb 19 03:36:37 2018 -0800
>>> # Node ID 6b80188783ee2626030113a9b2319f2fd14a8119
>>> # Parent  905b79d62df82d8ca16ecac175e6236fe959f4ed
>>> Back out "remotenames: push anonymous head if --force is given"
>>>
>>> Original commit changeset: 905b79d62df8
>>>
>>> There are already two ways to do this:
>>> * set remotenames.forcecompat = True
>>> * set remotenames.pushanonheads = True
>>>
>>> The backed out revision violated the expectation of someone who does not 
>>> have
>>> forcecompat = true. It also did not have any tests.
>> I actually quite liked this, to be honest. Those settings are fairly
>> unintuitive settings and --force is the de facto way to override a push
>> on the client.
>>
>> Also, it seems you pushed this less than a day (which was a holiday!) of
>> it being on the list. That's seems a bit rushed, no?
>
> Sorry I'm out of touch with US holidays. I pushed in draft phase and I'm happy
> to drop them all.

It's alright. I was thinking of maybe just going ahead and splitting the
extension up before this sprint. We can just punt on this and discuss it
there.


signature.asc
Description: PGP signature
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-02-22 Thread rishabhmadan96 (Rishabh Madan)
rishabhmadan96 added a comment.


  It'd be better if you could update the commit message with the necessary 
details that you mentioned in your previous comment.

REPOSITORY
  rHG Mercurial

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

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


[Bug 5802] New: old pager.attend setting breaks hg import

2018-02-22 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5802

Bug ID: 5802
   Summary: old pager.attend setting breaks hg import
   Product: Mercurial
   Version: stable branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: pager
  Assignee: bugzi...@mercurial-scm.org
  Reporter: g...@reaperworld.com
CC: mercurial-devel@mercurial-scm.org

Running version 4.5 I just tried to import a patch and vim got all messed up
thinking there was no TTY.  I realized it was a pager problem as when I 
`^[:q`'d I saw the `(end)` that you see at the bottom of the screen in less.

I tracked it down to the attend setting no longer being needed with some help
from smf.

Not sure what the action is here? Maybe just ignore the setting completely?  

Anyways, here's an asciinema showing how to produce it
https://asciinema.org/a/jjlREL0N4S2uUWuYLppZoV6YO

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


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-02-22 Thread sangeet259 (Sangeet Kumar Mishra)
sangeet259 added a comment.


  Oh, I forgot adding tests as @durin42 told. Doing that right away!

REPOSITORY
  rHG Mercurial

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

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


D2394: histedit: make histedit's commands accept revsets (issue5746)

2018-02-22 Thread sangeet259 (Sangeet Kumar Mishra)
sangeet259 created this revision.
Herald added a reviewer: durin42.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -422,7 +422,14 @@
 def fromrule(cls, state, rule):
 """Parses the given rule, returning an instance of the histeditaction.
 """
-rulehash = rule.strip().split(' ', 1)[0]
+ruleid = rule.strip().split(' ', 1)[0]
+# The ruleid can be anything like revison no,rulehashes, "tip","@" etc
+# Check for validation of rule ids and get the rulehash 
+try:
+_ctx = scmutil.revsingle(state.repo,ruleid)
+rulehash = _ctx.hex()[:12]
+except RepoLookupError :
+raise error.ParseError("invalid changeset %s" % ruleid)
 try:
 rev = node.bin(rulehash)
 except TypeError:



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


[PATCH 2 of 2 RFC] dispatch: look up command by [:] syntax (PoC)

2018-02-22 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1516798904 -32400
#  Wed Jan 24 22:01:44 2018 +0900
# Node ID cb9e1cad42a9a13f17c4c75d350cd509b08f4a21
# Parent  e2030eaec92b1ed12577cbe48cd0495d106818a9
dispatch: look up command by [:] syntax (PoC)

This allows us to run the show command without giving up our show alias.
The separator ':' is copied from the merge-tools syntax, ":".

  [alias]
  show = log -pvr
  work = show:show work

  $ hg work

So, do we like it?

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -707,6 +707,19 @@ def findcmd(cmd, table, strict=True):
 
 raise error.UnknownCommand(cmd, allcmds)
 
+def findcmdspace(name, commands, strict=True):
+"""Look up (aliases, command table entry) from commands module"""
+# TODO: ':' vs '.'
+ns, sep, cmd = name.partition(':')
+if not sep:
+return findcmd(name, commands.table, strict=strict)
+table = commands.namespace.get(ns)
+if table is None:
+raise error.UnknownCommand(name)
+# TODO: wrap Ambiguous/UnknownCommand exception to return a full name?
+# TODO: might want to require strict=True for namespaced name
+return findcmd(cmd, table, strict=strict)
+
 def changebranch(ui, repo, revs, label):
 """ Change the branch name of given revs to label """
 
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -234,7 +234,7 @@ def _runcatch(req):
 try:
 cmdargs = fancyopts.fancyopts(req.args[:], commands.globalopts, {})
 cmd = cmdargs[0]
-aliases, entry = cmdutil.findcmd(cmd, commands.table, False)
+aliases, entry = cmdutil.findcmdspace(cmd, commands, strict=False)
 realcmd = aliases[0]
 except (error.UnknownCommand, error.AmbiguousCommand,
 IndexError, getopt.GetoptError):
@@ -602,8 +602,8 @@ def _parse(ui, args):
 
 if args:
 cmd, args = args[0], args[1:]
-aliases, entry = cmdutil.findcmd(cmd, commands.table,
- ui.configbool("ui", "strict"))
+aliases, entry = cmdutil.findcmdspace(cmd, commands,
+  ui.configbool("ui", "strict"))
 cmd = aliases[0]
 args = aliasargs(entry[0], args)
 defaults = ui.config("defaults", cmd)
diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -322,8 +322,8 @@ def help_(ui, commands, name, unknowncmd
 
 def helpcmd(name, subtopic=None):
 try:
-aliases, entry = cmdutil.findcmd(name, commands.table,
- strict=unknowncmd)
+aliases, entry = cmdutil.findcmdspace(name, commands,
+  strict=unknowncmd)
 except error.AmbiguousCommand as inst:
 # py3k fix: except vars can't be used outside the scope of the
 # except block, nor can be used inside a lambda. python issue4617
@@ -524,7 +524,7 @@ def help_(ui, commands, name, unknowncmd
 indicateomitted(rst, omitted)
 
 try:
-cmdutil.findcmd(name, commands.table)
+cmdutil.findcmdspace(name, commands)
 rst.append(_("\nuse 'hg help -c %s' to see help for "
"the %s command\n") % (name, name))
 except error.UnknownCommand:
diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -11,6 +11,24 @@ Redundant options used to crash (issue43
   $ hg ci -Ama
   adding a
 
+Look up command by canonical name:
+
+  $ hg :log
+  changeset:   0:cb9a9f314b8b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: a
+  
+  $ hg --config alias.log='log -G' :log
+  changeset:   0:cb9a9f314b8b
+  tag: tip
+  user:test
+  date:Thu Jan 01 00:00:00 1970 +
+  summary: a
+  
+  $ hg --config extensions.purge= purge:purge
+
 Missing arg:
 
   $ hg cat
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -496,6 +496,14 @@ Test ambiguous command help
   
   (use 'hg help -v ad' to show built-in aliases and global options)
 
+  $ hg help :ad
+  list of commands:
+  
+   add   add the specified files on the next commit
+   addremove add all new files, delete all missing files
+  
+  (use 'hg help -v :ad' to show built-in aliases and global options)
+
 Test command without options
 
   $ hg help verify
@@ -670,6 +678,13 @@ Test command without options
   (use 'hg help' for the full list of commands or 'hg -v' for details)
   [255]
 
+Look up command by canonical name:
+
+  $ hg --config alias.status=log help status | grep 'alias for'
+  alias for: hg log
+  $ hg --config alias.status=log help :status | 

[PATCH 1 of 2 RFC] dispatch: remember command table per extension (PoC DO NOT PUSH)

2018-02-22 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1516797703 -32400
#  Wed Jan 24 21:41:43 2018 +0900
# Node ID e2030eaec92b1ed12577cbe48cd0495d106818a9
# Parent  b8d0761a85c7421071750de23228415306852d69
dispatch: remember command table per extension (PoC DO NOT PUSH)

The next patch will make it possible to look up commands shadowed by user
aliases.

This patch shouldn't be published because namespace[] cannot be updated by
extensions.wrapcommand(). That might be okay, but wouldn't be what we want.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -64,10 +64,12 @@ from . import (
 
 release = lockmod.release
 
+# commands table per extension ('' for built-in commands)
+namespace = {'': {}}
+# active commands table (may be updated by dispatcher and extensions)
 table = {}
-table.update(debugcommandsmod.command._table)
-
-command = registrar.command(table)
+
+command = registrar.command()
 readonly = registrar.command.readonly
 
 # common command options
@@ -5606,4 +5608,11 @@ def loadcmdtable(ui, name, cmdtable):
 if overrides:
 ui.warn(_("extension '%s' overrides commands: %s\n")
 % (name, " ".join(overrides)))
+namespace[name] = cmdtable
 table.update(cmdtable)
+
+# load built-in commands
+namespace[''].update(debugcommandsmod.command._table)
+namespace[''].update(command._table)
+table.update(debugcommandsmod.command._table)
+table.update(command._table)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] mdiff: split on unicode character boundaries when shortening function name

2018-02-22 Thread Josef 'Jeff' Sipek
On Thu, Feb 22, 2018 at 21:01:44 +0900, Yuya Nishihara wrote:
> On Thu, 22 Feb 2018 09:01:14 +0100, Denis Laxalde wrote:
> > Josef 'Jeff' Sipek wrote:
> > > # HG changeset patch
> > > # User Josef 'Jeff' Sipek 
> > > # Date 1519251311 18000
> > > #  Wed Feb 21 17:15:11 2018 -0500
> > > # Node ID b99df94fdd4813e0ce538a8caa682802da4a6cb2
> > > # Parent  106872aa15af9919220705ed72c78459774e1575
> > > mdiff: split on unicode character boundaries when shortening function name
> > > 
> > > Splitting the raw bytes may lead to truncating the string in the middle 
> > > of a
> > > UTF-8 character which would lead to the generated diff containing an 
> > > invalid
> > > byte sequence even though the original data had none.  For example, the
> > > Unicode codepoint U+308B (る) gets represented as \xe3\x82\x8b in UTF-8.
> > > Before this change a diff on i18n/ja.po would yield:
> > > 
> > >   @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用す<82>
> > > 
> > > After this change, the output is cleaner:
> > > 
> > >   @@ -28953,7 +28953,7 @@ msgstr "Mercurial と SSH を併用する場合の注意点:"
> > > 
> > > diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
> > > --- a/mercurial/mdiff.py
> > > +++ b/mercurial/mdiff.py
> > > @@ -348,7 +348,12 @@ def _unidiff(t1, t2, opts=defaultopts):
> > >  # alphanumeric char.
> > >  for i in xrange(astart - 1, lastpos - 1, -1):
> > >  if l1[i][0:1].isalnum():
> > > -func = ' ' + l1[i].rstrip()[:40]
> > > +func = l1[i].rstrip()
> > > +try:
> > > +func = func.decode("utf-8")[:40].encode("utf-8")
> > > +except:
> > > +func = func[:40]
> > 
> > I'd suggest catching exception types explicitly (UnicodeDecodeError and
> > UnicodeEncodeError I guess) and avoid "bare" except.
> > 
> > (No idea if the change itself is correct by the way.)
> 
> Nah, it's wrong to assume external world is always UTF-8. It might be okayish
> to split func as a UTF-8 as best effort, but which shouldn't involve encoding
> conversion.

Yeah... I thought that might be an issue.  The code in the 'except' is meant
as best-effort - if there is any UTF-8 issue decoding/encoding, just fall
back to previous method.  That of course wouldn't help if the input happened
to be valid UTF-8 but wasn't actually UTF-8.

I had to do the encode step, otherwise I got a giant stack trace saying that
unicode strings cannot be  using ascii encoder.
(Leaving it un-encoded would also mean that this for loop would output
either a unicode string or a raw string - which seems unclean.)

I'm not really sure how to proceed.  Most UTF-8 decoders should handle the
illegal byte sequence ok, but it still feels wrong to let it make a mess of
valid data.  The answer might be to just ignore this issue.  :|

Jeff.

-- 
All science is either physics or stamp collecting.
- Ernest Rutherford
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D2297: py3: backout 7c54917b31f6 to make sure second argument of open() is str

2018-02-22 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D2297#37960, @yuja wrote:
  
  > Can you elaborate why you think it wasn't a good idea to replace open()?
  >
  > IMHO, it's as hackish as replacing '' with b''.
  
  
  Added couple of points.

REPOSITORY
  rHG Mercurial

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

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


mercurial@36358: 6 new changesets

2018-02-22 Thread Mercurial Commits
6 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/cc9d0763c8e9
changeset:   36353:cc9d0763c8e9
user:Daniel Ploch 
date:Wed Feb 21 20:05:29 2018 -0800
summary: fancyopts: add support for custom multi-arg opts in fancyopts.py

https://www.mercurial-scm.org/repo/hg/rev/0d5eaa97676b
changeset:   36354:0d5eaa97676b
user:Augie Fackler 
date:Wed Feb 21 22:49:15 2018 -0500
summary: narrowbundle2: drop legacy getcgkwargs variable

https://www.mercurial-scm.org/repo/hg/rev/cd4f13f1ea2f
changeset:   36355:cd4f13f1ea2f
user:Augie Fackler 
date:Wed Feb 21 22:49:40 2018 -0500
summary: narrowbundle2: use native string to get kwargs from dict

https://www.mercurial-scm.org/repo/hg/rev/7e97174a1835
changeset:   36356:7e97174a1835
user:Augie Fackler 
date:Wed Feb 21 23:24:51 2018 -0500
summary: py3: whitelist another 11 passing tests

https://www.mercurial-scm.org/repo/hg/rev/adce75cdf8f8
changeset:   36357:adce75cdf8f8
user:Augie Fackler 
date:Thu Feb 22 00:51:32 2018 -0500
summary: narrowbundle2: more kwargs native string fixes

https://www.mercurial-scm.org/repo/hg/rev/075ef2d2e38d
changeset:   36358:075ef2d2e38d
bookmark:@
tag: tip
user:Augie Fackler 
date:Thu Feb 22 01:00:57 2018 -0500
summary: py3: two more narrow tests passing

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


D2367: narrowcommands: add some missing strkwargs calls for py3

2018-02-22 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  This one got pushed with a wrong commit message.

REPOSITORY
  rHG Mercurial

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

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


D2383: sshpeer: defer pipe buffering and stderr sidechannel binding

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG11ba1a96f946: sshpeer: defer pipe buffering and stderr 
sidechannel binding (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2383?vs=5969=6001

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

AFFECTED FILES
  mercurial/sshpeer.py
  tests/test-check-interfaces.py

CHANGE DETAILS

diff --git a/tests/test-check-interfaces.py b/tests/test-check-interfaces.py
--- a/tests/test-check-interfaces.py
+++ b/tests/test-check-interfaces.py
@@ -59,16 +59,20 @@
 def badmethod(self):
 pass
 
+class dummypipe(object):
+def close(self):
+pass
+
 def main():
 ui = uimod.ui()
 
 checkobject(badpeer())
 checkobject(httppeer.httppeer(ui, 'http://localhost'))
 checkobject(localrepo.localpeer(dummyrepo()))
-checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, None, None,
-  None, None))
-checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, None, None,
-  None, None))
+checkobject(sshpeer.sshv1peer(ui, 'ssh://localhost/foo', None, dummypipe(),
+  dummypipe(), None, None))
+checkobject(sshpeer.sshv2peer(ui, 'ssh://localhost/foo', None, dummypipe(),
+  dummypipe(), None, None))
 checkobject(bundlerepo.bundlepeer(dummyrepo()))
 checkobject(statichttprepo.statichttppeer(dummyrepo()))
 checkobject(unionrepo.unionpeer(dummyrepo()))
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -156,13 +156,13 @@
 # move to threading.
 stdin, stdout, stderr, proc = util.popen4(cmd, bufsize=0, env=sshenv)
 
-stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
-stdin = doublepipe(ui, stdin, stderr)
-
 return proc, stdin, stdout, stderr
 
 def _performhandshake(ui, stdin, stdout, stderr):
 def badresponse():
+# Flush any output on stderr.
+_forwardoutput(ui, stderr)
+
 msg = _('no suitable response from remote hg')
 hint = ui.config('ui', 'ssherrorhint')
 raise error.RepoError(msg, hint=hint)
@@ -331,6 +331,9 @@
 if not caps:
 badresponse()
 
+# Flush any output on stderr before proceeding.
+_forwardoutput(ui, stderr)
+
 return protoname, caps
 
 class sshv1peer(wireproto.wirepeer):
@@ -347,6 +350,12 @@
 # self._subprocess is unused. Keeping a handle on the process
 # holds a reference and prevents it from being garbage collected.
 self._subprocess = proc
+
+# And we hook up our "doublepipe" wrapper to allow querying
+# stderr any time we perform I/O.
+stdout = doublepipe(ui, util.bufferedinputpipe(stdout), stderr)
+stdin = doublepipe(ui, stdin, stderr)
+
 self._pipeo = stdin
 self._pipei = stdout
 self._pipee = stderr



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


D2385: wireproto: document the wonky push protocol for SSH

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb8d0761a85c7: wireproto: document the wonky push protocol 
for SSH (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2385?vs=5978=6003

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

AFFECTED FILES
  mercurial/sshpeer.py
  mercurial/wireprotoserver.py

CHANGE DETAILS

diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -347,12 +347,16 @@
 return [data[k] for k in keys]
 
 def forwardpayload(self, fpout):
+# We initially send an empty response. This tells the client it is
+# OK to start sending data. If a client sees any other response, it
+# interprets it as an error.
+_sshv1respondbytes(self._fout, b'')
+
 # The file is in the form:
 #
 # \n
 # ...
 # 0\n
-_sshv1respondbytes(self._fout, b'')
 count = int(self._fin.readline())
 while count:
 fpout.write(self._fin.read(count))
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -466,25 +466,40 @@
 return self._sendrequest(cmd, args, framed=True).read()
 
 def _callpush(self, cmd, fp, **args):
+# The server responds with an empty frame if the client should
+# continue submitting the payload.
 r = self._call(cmd, **args)
 if r:
 return '', r
+
+# The payload consists of frames with content followed by an empty
+# frame.
 for d in iter(lambda: fp.read(4096), ''):
 self._writeframed(d)
 self._writeframed("", flush=True)
+
+# In case of success, there is an empty frame and a frame containing
+# the integer result (as a string).
+# In case of error, there is a non-empty frame containing the error.
 r = self._readframed()
 if r:
 return '', r
 return self._readframed(), ''
 
 def _calltwowaystream(self, cmd, fp, **args):
+# The server responds with an empty frame if the client should
+# continue submitting the payload.
 r = self._call(cmd, **args)
 if r:
 # XXX needs to be made better
 raise error.Abort(_('unexpected remote reply: %s') % r)
+
+# The payload consists of frames with content followed by an empty
+# frame.
 for d in iter(lambda: fp.read(4096), ''):
 self._writeframed(d)
 self._writeframed("", flush=True)
+
 return self._pipei
 
 def _getamount(self):



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


D2380: sshpeer: return framed file object when needed

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG043e77f3be09: sshpeer: return framed file object when 
needed (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2380?vs=5966=5998

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -349,6 +349,12 @@
 self._pipee = stderr
 self._caps = caps
 
+# Commands that have a "framed" response where the first line of the
+# response contains the length of that response.
+_FRAMED_COMMANDS = {
+'batch',
+}
+
 # Begin of _basepeer interface.
 
 @util.propertycache
@@ -391,26 +397,7 @@
 
 __del__ = _cleanup
 
-def _submitbatch(self, req):
-rsp = self._callstream("batch", cmds=wireproto.encodebatchcmds(req))
-available = self._getamount()
-# TODO this response parsing is probably suboptimal for large
-# batches with large responses.
-toread = min(available, 1024)
-work = rsp.read(toread)
-available -= toread
-chunk = work
-while chunk:
-while ';' in work:
-one, work = work.split(';', 1)
-yield wireproto.unescapearg(one)
-toread = min(available, 1024)
-chunk = rsp.read(toread)
-available -= toread
-work += chunk
-yield wireproto.unescapearg(work)
-
-def _sendrequest(self, cmd, args):
+def _sendrequest(self, cmd, args, framed=False):
 if (self.ui.debugflag
 and self.ui.configbool('devel', 'debug.peer-request')):
 dbg = self.ui.debug
@@ -444,20 +431,27 @@
 self._pipeo.write(v)
 self._pipeo.flush()
 
+# We know exactly how many bytes are in the response. So return a proxy
+# around the raw output stream that allows reading exactly this many
+# bytes. Callers then can read() without fear of overrunning the
+# response.
+if framed:
+amount = self._getamount()
+return util.cappedreader(self._pipei, amount)
+
 return self._pipei
 
 def _callstream(self, cmd, **args):
 args = pycompat.byteskwargs(args)
-return self._sendrequest(cmd, args)
+return self._sendrequest(cmd, args, framed=cmd in 
self._FRAMED_COMMANDS)
 
 def _callcompressable(self, cmd, **args):
 args = pycompat.byteskwargs(args)
-return self._sendrequest(cmd, args)
+return self._sendrequest(cmd, args, framed=cmd in 
self._FRAMED_COMMANDS)
 
 def _call(self, cmd, **args):
 args = pycompat.byteskwargs(args)
-self._sendrequest(cmd, args)
-return self._readframed()
+return self._sendrequest(cmd, args, framed=True).read()
 
 def _callpush(self, cmd, fp, **args):
 r = self._call(cmd, **args)



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


D2381: tests: store protocol payload in files

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG02782e6e2c38: tests: store protocol payload in files 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2381?vs=5967=5999

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

AFFECTED FILES
  tests/test-ssh-proto.t

CHANGE DETAILS

diff --git a/tests/test-ssh-proto.t b/tests/test-ssh-proto.t
--- a/tests/test-ssh-proto.t
+++ b/tests/test-ssh-proto.t
@@ -463,13 +463,14 @@
 
 Send an upgrade request to a server that supports upgrade
 
-  $ hg -R server serve --stdio << EOF
-  > upgrade this-is-some-token proto=exp-ssh-v2-0001
-  > hello
-  > between
-  > pairs 81
-  > 
-
-  > EOF
+  >>> with open('payload', 'wb') as fh:
+  ... fh.write(b'upgrade this-is-some-token proto=exp-ssh-v2-0001\n')
+  ... fh.write(b'hello\n')
+  ... fh.write(b'between\n')
+  ... fh.write(b'pairs 81\n')
+  ... 
fh.write(b'-')
+
+  $ hg -R server serve --stdio < payload
   upgraded this-is-some-token exp-ssh-v2-0001
   383
   capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
@@ -540,29 +541,31 @@
 
 Command after upgrade to version 2 is processed
 
-  $ hg -R server serve --stdio << EOF
-  > upgrade this-is-some-token proto=exp-ssh-v2-0001
-  > hello
-  > between
-  > pairs 81
-  > 
-hello
-  > EOF
+  >>> with open('payload', 'wb') as fh:
+  ... fh.write(b'upgrade this-is-some-token proto=exp-ssh-v2-0001\n')
+  ... fh.write(b'hello\n')
+  ... fh.write(b'between\n')
+  ... fh.write(b'pairs 81\n')
+  ... 
fh.write(b'-')
+  ... fh.write(b'hello\n')
+  $ hg -R server serve --stdio < payload
   upgraded this-is-some-token exp-ssh-v2-0001
   383
   capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
   384
   capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN
 
 Multiple upgrades is not allowed
 
-  $ hg -R server serve --stdio << EOF
-  > upgrade this-is-some-token proto=exp-ssh-v2-0001
-  > hello
-  > between
-  > pairs 81
-  > 
-upgrade
 another-token proto=irrelevant
-  > hello
-  > EOF
+  >>> with open('payload', 'wb') as fh:
+  ... fh.write(b'upgrade this-is-some-token proto=exp-ssh-v2-0001\n')
+  ... fh.write(b'hello\n')
+  ... fh.write(b'between\n')
+  ... fh.write(b'pairs 81\n')
+  ... 
fh.write(b'-')
+  ... fh.write(b'upgrade another-token proto=irrelevant\n')
+  ... fh.write(b'hello\n')
+  $ hg -R server serve --stdio < payload
   upgraded this-is-some-token exp-ssh-v2-0001
   383
   capabilities: lookup changegroupsubset branchmap pushkey known getbundle 
unbundlehash batch streamreqs=generaldelta,revlogv1 $USUAL_BUNDLE2_CAPS_SERVER$ 
unbundle=HG10GZ,HG10BZ,HG10UN



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


D2378: sshpeer: rename _recv and _send to _readframed and _writeframed

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG7f8f74531b0b: sshpeer: rename _recv and _send to 
_readframed and _writeframed (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2378?vs=5964=5996

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -452,28 +452,28 @@
 
 def _call(self, cmd, **args):
 self._callstream(cmd, **args)
-return self._recv()
+return self._readframed()
 
 def _callpush(self, cmd, fp, **args):
 r = self._call(cmd, **args)
 if r:
 return '', r
 for d in iter(lambda: fp.read(4096), ''):
-self._send(d)
-self._send("", flush=True)
-r = self._recv()
+self._writeframed(d)
+self._writeframed("", flush=True)
+r = self._readframed()
 if r:
 return '', r
-return self._recv(), ''
+return self._readframed(), ''
 
 def _calltwowaystream(self, cmd, fp, **args):
 r = self._call(cmd, **args)
 if r:
 # XXX needs to be made better
 raise error.Abort(_('unexpected remote reply: %s') % r)
 for d in iter(lambda: fp.read(4096), ''):
-self._send(d)
-self._send("", flush=True)
+self._writeframed(d)
+self._writeframed("", flush=True)
 return self._pipei
 
 def _getamount(self):
@@ -488,10 +488,10 @@
 except ValueError:
 self._abort(error.ResponseError(_("unexpected response:"), l))
 
-def _recv(self):
+def _readframed(self):
 return self._pipei.read(self._getamount())
 
-def _send(self, data, flush=False):
+def _writeframed(self, data, flush=False):
 self._pipeo.write("%d\n" % len(data))
 if data:
 self._pipeo.write(data)



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


D2384: wireprototypes: move baseprotocolhandler from wireprotoserver

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0c231df1ffdc: wireprototypes: move baseprotocolhandler from 
wireprotoserver (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2384?vs=5977=6002

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

AFFECTED FILES
  mercurial/wireprotoserver.py
  mercurial/wireprototypes.py

CHANGE DETAILS

diff --git a/mercurial/wireprototypes.py b/mercurial/wireprototypes.py
--- a/mercurial/wireprototypes.py
+++ b/mercurial/wireprototypes.py
@@ -5,6 +5,8 @@
 
 from __future__ import absolute_import
 
+import abc
+
 class bytesresponse(object):
 """A wire protocol response consisting of raw bytes."""
 def __init__(self, data):
@@ -64,3 +66,52 @@
 """
 def __init__(self, gen=None):
 self.gen = gen
+
+class baseprotocolhandler(object):
+"""Abstract base class for wire protocol handlers.
+
+A wire protocol handler serves as an interface between protocol command
+handlers and the wire protocol transport layer. Protocol handlers provide
+methods to read command arguments, redirect stdio for the duration of
+the request, handle response types, etc.
+"""
+
+__metaclass__ = abc.ABCMeta
+
+@abc.abstractproperty
+def name(self):
+"""The name of the protocol implementation.
+
+Used for uniquely identifying the transport type.
+"""
+
+@abc.abstractmethod
+def getargs(self, args):
+"""return the value for arguments in 
+
+returns a list of values (same order as )"""
+
+@abc.abstractmethod
+def forwardpayload(self, fp):
+"""Read the raw payload and forward to a file.
+
+The payload is read in full before the function returns.
+"""
+
+@abc.abstractmethod
+def mayberedirectstdio(self):
+"""Context manager to possibly redirect stdio.
+
+The context manager yields a file-object like object that receives
+stdout and stderr output when the context manager is active. Or it
+yields ``None`` if no I/O redirection occurs.
+
+The intent of this context manager is to capture stdio output
+so it may be sent in the response. Some transports support streaming
+stdio to the client in real time. For these transports, stdio output
+won't be captured.
+"""
+
+@abc.abstractmethod
+def client(self):
+"""Returns a string representation of this client (as bytes)."""
diff --git a/mercurial/wireprotoserver.py b/mercurial/wireprotoserver.py
--- a/mercurial/wireprotoserver.py
+++ b/mercurial/wireprotoserver.py
@@ -6,7 +6,6 @@
 
 from __future__ import absolute_import
 
-import abc
 import contextlib
 import struct
 import sys
@@ -39,55 +38,6 @@
 # to reflect BC breakages.
 SSHV2 = 'exp-ssh-v2-0001'
 
-class baseprotocolhandler(object):
-"""Abstract base class for wire protocol handlers.
-
-A wire protocol handler serves as an interface between protocol command
-handlers and the wire protocol transport layer. Protocol handlers provide
-methods to read command arguments, redirect stdio for the duration of
-the request, handle response types, etc.
-"""
-
-__metaclass__ = abc.ABCMeta
-
-@abc.abstractproperty
-def name(self):
-"""The name of the protocol implementation.
-
-Used for uniquely identifying the transport type.
-"""
-
-@abc.abstractmethod
-def getargs(self, args):
-"""return the value for arguments in 
-
-returns a list of values (same order as )"""
-
-@abc.abstractmethod
-def forwardpayload(self, fp):
-"""Read the raw payload and forward to a file.
-
-The payload is read in full before the function returns.
-"""
-
-@abc.abstractmethod
-def mayberedirectstdio(self):
-"""Context manager to possibly redirect stdio.
-
-The context manager yields a file-object like object that receives
-stdout and stderr output when the context manager is active. Or it
-yields ``None`` if no I/O redirection occurs.
-
-The intent of this context manager is to capture stdio output
-so it may be sent in the response. Some transports support streaming
-stdio to the client in real time. For these transports, stdio output
-won't be captured.
-"""
-
-@abc.abstractmethod
-def client(self):
-"""Returns a string representation of this client (as bytes)."""
-
 def decodevaluefromheaders(req, headerprefix):
 """Decode a long value from multiple HTTP request headers.
 
@@ -105,7 +55,7 @@
 
 return ''.join(chunks)
 
-class httpv1protocolhandler(baseprotocolhandler):
+class httpv1protocolhandler(wireprototypes.baseprotocolhandler):
 def __init__(self, req, ui):
 self._req = req
 self._ui = ui
@@ -364,7 +314,7 @@
 fout.write(b'\n')
 fout.flush()

D2379: sshpeer: move logic for sending a request into a new function

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa34d5ef53c2e: sshpeer: move logic for sending a request 
into a new function (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2379?vs=5965=5997

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -410,8 +410,7 @@
 work += chunk
 yield wireproto.unescapearg(work)
 
-def _callstream(self, cmd, **args):
-args = pycompat.byteskwargs(args)
+def _sendrequest(self, cmd, args):
 if (self.ui.debugflag
 and self.ui.configbool('devel', 'debug.peer-request')):
 dbg = self.ui.debug
@@ -447,11 +446,17 @@
 
 return self._pipei
 
+def _callstream(self, cmd, **args):
+args = pycompat.byteskwargs(args)
+return self._sendrequest(cmd, args)
+
 def _callcompressable(self, cmd, **args):
-return self._callstream(cmd, **args)
+args = pycompat.byteskwargs(args)
+return self._sendrequest(cmd, args)
 
 def _call(self, cmd, **args):
-self._callstream(cmd, **args)
+args = pycompat.byteskwargs(args)
+self._sendrequest(cmd, args)
 return self._readframed()
 
 def _callpush(self, cmd, fp, **args):



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


D2382: sshpeer: make pipe polling code more explicit

2018-02-22 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG066e6a9d52bb: sshpeer: make pipe polling code more explicit 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2382?vs=5968=6000

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

AFFECTED FILES
  mercurial/sshpeer.py

CHANGE DETAILS

diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -65,8 +65,11 @@
 
 (This will only wait for data if the setup is supported by `util.poll`)
 """
-if getattr(self._main, 'hasbuffer', False): # getattr for classic pipe
-return (True, True) # main has data, assume side is worth poking 
at.
+if (isinstance(self._main, util.bufferedinputpipe) and
+self._main.hasbuffer):
+# Main has data. Assume side is worth poking at.
+return True, True
+
 fds = [self._main.fileno(), self._side.fileno()]
 try:
 act = util.poll(fds)



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