D2451: py3: whitelist test-push-http.t as passing

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -235,6 +235,7 @@
 test-push-checkheads-unpushed-D5.t
 test-push-checkheads-unpushed-D6.t
 test-push-checkheads-unpushed-D7.t
+test-push-http.t
 test-push-warn.t
 test-pushvars.t
 test-rebase-bookmarks.t



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


D2449: wireproto: use %d to encode an int, not a %s

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/wireproto.py

CHANGE DETAILS

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -955,7 +955,7 @@
  encoding.tolocal(old), new) or False
 
 output = output.getvalue() if output else ''
-return bytesresponse('%s\n%s' % (int(r), output))
+return bytesresponse('%d\n%s' % (int(r), output))
 
 @wireprotocommand('stream_out')
 def stream(repo, proto):



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


D2445: bundle2: **strkwargs love on various kwargs constructions

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bundle2.py

CHANGE DETAILS

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1946,7 +1946,8 @@
 value = inpart.params.get(name)
 if value is not None:
 kwargs[name] = value
-raise error.PushkeyFailed(inpart.params['in-reply-to'], **kwargs)
+raise error.PushkeyFailed(inpart.params['in-reply-to'],
+  **pycompat.strkwargs(kwargs))
 
 @parthandler('error:unsupportedcontent', ('parttype', 'params'))
 def handleerrorunsupportedcontent(op, inpart):
@@ -1959,7 +1960,7 @@
 if params is not None:
 kwargs['params'] = params.split('\0')
 
-raise error.BundleUnknownFeatureError(**kwargs)
+raise error.BundleUnknownFeatureError(**pycompat.strkwargs(kwargs))
 
 @parthandler('error:pushraced', ('message',))
 def handleerrorpushraced(op, inpart):
@@ -2001,7 +2002,8 @@
 for key in ('namespace', 'key', 'new', 'old', 'ret'):
 if key in inpart.params:
 kwargs[key] = inpart.params[key]
-raise error.PushkeyFailed(partid=str(inpart.id), **kwargs)
+raise error.PushkeyFailed(partid=str(inpart.id),
+  **pycompat.strkwargs(kwargs))
 
 @parthandler('bookmarks')
 def handlebookmark(op, inpart):



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


D2450: util: handle fileno() on Python 3 throwing io.UnsupportedOperation

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

REVISION SUMMARY
  Fortunately, the exception exists on Python 2 so we don't have to do
  something weirder than this.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -26,6 +26,7 @@
 import gc
 import hashlib
 import imp
+import io
 import itertools
 import mmap
 import os
@@ -1178,7 +1179,10 @@
 
 def _isstdout(f):
 fileno = getattr(f, 'fileno', None)
-return fileno and fileno() == sys.__stdout__.fileno()
+try:
+return fileno and fileno() == sys.__stdout__.fileno()
+except io.UnsupportedOperation:
+return False # fileno() raised UnsupportedOperation
 
 def shellenviron(environ=None):
 """return environ with optional override, useful for shelling out"""



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


D2448: httppeer: explicitly catch urlerr.httperror and re-raise

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

REVISION SUMMARY
  On Python 3 it seems urllib.error.HTTPError doesn't set the .args
  field of the exception to have any contents, which then breaks our
  socket.error catch. This works around that issue.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/httppeer.py

CHANGE DETAILS

diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -439,6 +439,11 @@
 if len(vals) < 2:
 raise error.ResponseError(_("unexpected response:"), r)
 return vals
+except urlerr.httperror:
+# Catch and re-raise these so we don't try and treat them
+# like generic socket errors. They lack any values in
+# .args on Python 3 which breaks our socket.error block.
+raise
 except socket.error as err:
 if err.args[0] in (errno.ECONNRESET, errno.EPIPE):
 raise error.Abort(_('push failed: %s') % err.args[1])



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


D2447: hgweb: pass exception message to builtin Exception ctor as sysstr

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

REVISION SUMMARY
  If we don't do this, the bytes gets repr()ed on Python 3 and we get
  bogus error strings sent to clients. Ick.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hgweb/common.py

CHANGE DETAILS

diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -93,7 +93,7 @@
 def __init__(self, code, message=None, headers=None):
 if message is None:
 message = _statusmessage(code)
-Exception.__init__(self, message)
+Exception.__init__(self, pycompat.sysstr(message))
 self.code = code
 if headers is None:
 headers = []



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


D2438: util: use util.shellquote() instead of repr() in date parse abort

2018-02-25 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 6099.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2438?vs=6086=6099

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

AFFECTED FILES
  mercurial/util.py
  tests/test-commit.t
  tests/test-revset.t

CHANGE DETAILS

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -413,7 +413,7 @@
   hg: parse error: invalid \x escape
   [255]
   $ log 'date(tip)'
-  hg: parse error: invalid date: 'tip'
+  hg: parse error: invalid date: tip
   [255]
   $ log '0:date'
   abort: unknown revision 'date'!
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -18,7 +18,7 @@
   hg: parse error: impossible time zone offset: 444
   [255]
   $ hg commit -d '115.1' -m commit-4
-  hg: parse error: invalid date: '1\t15.1'
+  hg: parse error: invalid date: '115.1'
   [255]
   $ hg commit -d 'foo bar' -m commit-5
   hg: parse error: invalid date: 'foo bar'
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2192,7 +2192,7 @@
 else:
 break
 else:
-raise error.ParseError(_('invalid date: %r') % date)
+raise error.ParseError(_('invalid date: %s') % shellquote(date))
 # validate explicit (probably user-specified) date and
 # time zone offset. values must fit in signed 32 bits for
 # current 32-bit linux runtimes. timezones go from UTC-12



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


D2442: filemerge: do what the context __bytes__ does, but locally

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3ab9d74dd1c5: filemerge: do what the context __bytes__ 
does, but locally (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2442?vs=6089=6098

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -520,8 +520,8 @@
 baselabel = 'base'
 env = {'HG_FILE': fcd.path(),
'HG_MY_NODE': short(mynode),
-   'HG_OTHER_NODE': str(fco.changectx()),
-   'HG_BASE_NODE': str(fca.changectx()),
+   'HG_OTHER_NODE': short(fco.changectx().node()),
+   'HG_BASE_NODE': short(fca.changectx().node()),
'HG_MY_ISLINK': 'l' in fcd.flags(),
'HG_OTHER_ISLINK': 'l' in fco.flags(),
'HG_BASE_ISLINK': 'l' in fca.flags(),



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


D2442: filemerge: do what the context __bytes__ does, but locally

2018-02-25 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  I agree that making this behavior explicit instead of relying on coercion is 
better. At least in this case.

REPOSITORY
  rHG Mercurial

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

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


D2441: py3: convert known-int values to bytes using %d

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG2831d918e1b4: py3: convert known-int values to bytes using 
%d (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2441?vs=6088=6097

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/obsolete.py
  mercurial/patch.py
  mercurial/progress.py

CHANGE DETAILS

diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -121,7 +121,7 @@
 if total:
 add = b'%*d/%d' % (len(str(total)), pos, total)
 else:
-add = str(pos)
+add = b'%d' % pos
 elif indicator.startswith('item') and item:
 slice = 'end'
 if '-' in indicator:
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -566,7 +566,7 @@
 root = tempfile.mkdtemp(prefix='hg-patch-')
 self.opener = vfsmod.vfs(root)
 # Avoid filename issues with these simple names
-fn = str(self.created)
+fn = '%d' % self.created
 self.opener.write(fn, data)
 self.created += 1
 self.files[fname] = (fn, mode, copied)
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -656,7 +656,7 @@
 self.caches.clear()
 # records the number of new markers for the transaction hooks
 previous = int(transaction.hookargs.get('new_obsmarkers', '0'))
-transaction.hookargs['new_obsmarkers'] = str(previous + len(new))
+transaction.hookargs['new_obsmarkers'] = '%d' % (previous + len(new))
 return len(new)
 
 def mergemarkers(self, transaction, data):
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1151,8 +1151,8 @@
 for newremotehead in outdated:
 r = pushop.remote.pushkey('phases',
   newremotehead.hex(),
-  str(phases.draft),
-  str(phases.public))
+  ('%d' % phases.draft),
+  ('%d' % phases.public))
 if not r:
 pushop.ui.warn(_('updating %s to public failed!\n')
% newremotehead)



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


D2440: py3: hunt down str(exception) instances and use util.forcebytestr

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG04c319a07c7b: py3: hunt down str(exception) instances and 
use util.forcebytestr (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2440?vs=6087=6096

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/scmutil.py
  mercurial/ui.py
  mercurial/url.py
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -3634,7 +3634,7 @@
 return zlib.decompress(data)
 except zlib.error as e:
 raise error.RevlogError(_('revlog decompress error: %s') %
-str(e))
+forcebytestr(e))
 
 def revlogcompressor(self, opts=None):
 return self.zlibrevlogcompressor()
@@ -3860,7 +3860,7 @@
 return ''.join(chunks)
 except Exception as e:
 raise error.RevlogError(_('revlog decompress error: %s') %
-str(e))
+forcebytestr(e))
 
 def revlogcompressor(self, opts=None):
 opts = opts or {}
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -449,7 +449,7 @@
 self.cookiejar = cookiejar
 except util.cookielib.LoadError as e:
 ui.warn(_('(error loading cookie file %s: %s; continuing without '
-  'cookies)\n') % (cookiefile, str(e)))
+  'cookies)\n') % (cookiefile, util.forcebytestr(e)))
 
 def http_request(self, request):
 if self.cookiejar:
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -366,7 +366,7 @@
 except error.ConfigError as inst:
 if trusted:
 raise
-self.warn(_("ignored: %s\n") % str(inst))
+self.warn(_("ignored: %s\n") % util.forcebytestr(inst))
 
 if self.plain():
 for k in ('debug', 'fallbackencoding', 'quiet', 'slash',
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -208,7 +208,7 @@
 ui.warn(_("(%s)\n") % inst.hint)
 except ImportError as inst:
 ui.warn(_("abort: %s!\n") % inst)
-m = str(inst).split()[-1]
+m = util.forcebytestr(inst).split()[-1]
 if m in "mpatch bdiff".split():
 ui.warn(_("(did you forget to compile extensions?)\n"))
 elif m in "zlib".split():
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -259,7 +259,8 @@
 bundle2.processbundle(self._repo, b)
 raise
 except error.PushRaced as exc:
-raise error.ResponseError(_('push failed:'), str(exc))
+raise error.ResponseError(_('push failed:'),
+  util.forcebytestr(exc))
 
 # End of _basewirecommands interface.
 
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2149,7 +2149,8 @@
 continue
 except error.UnsupportedBundleSpecification as e:
 repo.ui.debug('filtering %s because unsupported bundle '
-  'spec: %s\n' % (entry['URL'], str(e)))
+  'spec: %s\n' % (
+  entry['URL'], util.forcebytestr(e)))
 continue
 # If we don't have a spec and requested a stream clone, we don't know
 # what the entry is so don't attempt to apply it.
@@ -2254,7 +2255,8 @@
 bundle2.applybundle(repo, cg, tr, 'clonebundles', url)
 return True
 except urlerr.httperror as e:
-ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
+ui.warn(_('HTTP error fetching bundle: %s\n') %
+util.forcebytestr(e))
 except urlerr.urlerror as e:
 ui.warn(_('error fetching bundle: %s\n') % e.reason)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3899,7 +3899,7 @@
 try:
 return hg.updatetotally(ui, repo, checkout, brev)
 except error.UpdateAbort as inst:
-msg = _("not updating: %s") % str(inst)
+msg = _("not updating: %s") % util.forcebytestr(inst)
 hint = inst.hint
 raise error.UpdateAbort(msg, hint=hint)
 if modheads > 1:



To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel
___
Mercurial-devel mailing list

D2437: subrepo: use util.forcebytestr() instead of str() on exception

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1df7e7b8558e: subrepo: use util.forcebytestr() instead of 
str() on exception (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2437?vs=6082=6095

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

AFFECTED FILES
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -73,7 +73,8 @@
 raise ex
 except error.Abort as ex:
 subrepo = subrelpath(self)
-errormsg = str(ex) + ' ' + _('(in subrepository "%s")') % subrepo
+errormsg = (util.forcebytestr(ex) + ' '
++ _('(in subrepository "%s")') % subrepo)
 # avoid handling this exception by raising a SubrepoAbort exception
 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo,
cause=sys.exc_info())



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


D2436: tests: add missing b prefixes in test-commit.t

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa39126a40be6: tests: add missing b prefixes in 
test-commit.t (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2436?vs=6081=6094

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

AFFECTED FILES
  tests/test-commit.t

CHANGE DETAILS

diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -644,14 +644,14 @@
   $ cat > evil-commit.py < from __future__ import absolute_import
   > from mercurial import context, hg, node, ui as uimod
-  > notrc = u".h\u200cg".encode('utf-8') + '/hgrc'
+  > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
   > u = uimod.ui.load()
-  > r = hg.repository(u, '.')
+  > r = hg.repository(u, b'.')
   > def filectxfn(repo, memctx, path):
   > return context.memfilectx(repo, memctx, path,
-  > '[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r['tip'].node(), node.nullid],
-  >'evil', [notrc], filectxfn, 0)
+  > b'[hooks]\nupdate = echo owned')
+  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  >b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF
   $ $PYTHON evil-commit.py
@@ -670,14 +670,14 @@
   $ cat > evil-commit.py < from __future__ import absolute_import
   > from mercurial import context, hg, node, ui as uimod
-  > notrc = "HG~1/hgrc"
+  > notrc = b"HG~1/hgrc"
   > u = uimod.ui.load()
-  > r = hg.repository(u, '.')
+  > r = hg.repository(u, b'.')
   > def filectxfn(repo, memctx, path):
   > return context.memfilectx(repo, memctx, path,
-  > '[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r['tip'].node(), node.nullid],
-  >'evil', [notrc], filectxfn, 0)
+  > b'[hooks]\nupdate = echo owned')
+  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  >b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF
   $ $PYTHON evil-commit.py
@@ -690,14 +690,14 @@
   $ cat > evil-commit.py < from __future__ import absolute_import
   > from mercurial import context, hg, node, ui as uimod
-  > notrc = "HG8B6C~2/hgrc"
+  > notrc = b"HG8B6C~2/hgrc"
   > u = uimod.ui.load()
-  > r = hg.repository(u, '.')
+  > r = hg.repository(u, b'.')
   > def filectxfn(repo, memctx, path):
   > return context.memfilectx(repo, memctx, path,
-  > '[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r['tip'].node(), node.nullid],
-  >'evil', [notrc], filectxfn, 0)
+  > b'[hooks]\nupdate = echo owned')
+  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  >b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF
   $ $PYTHON evil-commit.py



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


D2434: util: use pycompat.bytestr() instead of str()

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd26b0bedfaa4: util: use pycompat.bytestr() instead of str() 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2434?vs=6085=6092

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1188,7 +1188,7 @@
 return '0'
 if val is True:
 return '1'
-return str(val)
+return pycompat.bytestr(val)
 env = dict(encoding.environ)
 if environ:
 env.update((k, py2shell(v)) for k, v in environ.iteritems())



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


D2435: commitextras: fix on Python 3 by using sysstrs for __dict__ ops

2018-02-25 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG75c76cee1b1b: commitextras: fix on Python 3 by using 
sysstrs for __dict__ ops (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2435?vs=6080=6093

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

AFFECTED FILES
  hgext/commitextras.py

CHANGE DETAILS

diff --git a/hgext/commitextras.py b/hgext/commitextras.py
--- a/hgext/commitextras.py
+++ b/hgext/commitextras.py
@@ -70,7 +70,7 @@
 
 # This __dict__ logic is needed because the normal
 # extension.wrapfunction doesn't seem to work.
-repo.__dict__['commit'] = _wrappedcommit
+repo.__dict__[r'commit'] = _wrappedcommit
 return orig(ui, repo, *pats, **opts)
 finally:
-del repo.__dict__['commit']
+del repo.__dict__[r'commit']



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


D2435: commitextras: fix on Python 3 by using sysstrs for __dict__ ops

2018-02-25 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  That `__dict__` usage is... special.

REPOSITORY
  rHG Mercurial

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

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


D2440: py3: hunt down str(exception) instances and use util.forcebytestr

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

REVISION SUMMARY
  I decided to grep around for \sstr\( and see what low-hanging fruit
  that showed me. This was part of that hunt. That grep pattern still
  has some things worth exploring.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/exchange.py
  mercurial/localrepo.py
  mercurial/scmutil.py
  mercurial/ui.py
  mercurial/url.py
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -3634,7 +3634,7 @@
 return zlib.decompress(data)
 except zlib.error as e:
 raise error.RevlogError(_('revlog decompress error: %s') %
-str(e))
+forcebytestr(e))
 
 def revlogcompressor(self, opts=None):
 return self.zlibrevlogcompressor()
@@ -3860,7 +3860,7 @@
 return ''.join(chunks)
 except Exception as e:
 raise error.RevlogError(_('revlog decompress error: %s') %
-str(e))
+forcebytestr(e))
 
 def revlogcompressor(self, opts=None):
 opts = opts or {}
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -449,7 +449,7 @@
 self.cookiejar = cookiejar
 except util.cookielib.LoadError as e:
 ui.warn(_('(error loading cookie file %s: %s; continuing without '
-  'cookies)\n') % (cookiefile, str(e)))
+  'cookies)\n') % (cookiefile, util.forcebytestr(e)))
 
 def http_request(self, request):
 if self.cookiejar:
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -366,7 +366,7 @@
 except error.ConfigError as inst:
 if trusted:
 raise
-self.warn(_("ignored: %s\n") % str(inst))
+self.warn(_("ignored: %s\n") % util.forcebytestr(inst))
 
 if self.plain():
 for k in ('debug', 'fallbackencoding', 'quiet', 'slash',
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -208,7 +208,7 @@
 ui.warn(_("(%s)\n") % inst.hint)
 except ImportError as inst:
 ui.warn(_("abort: %s!\n") % inst)
-m = str(inst).split()[-1]
+m = util.forcebytestr(inst).split()[-1]
 if m in "mpatch bdiff".split():
 ui.warn(_("(did you forget to compile extensions?)\n"))
 elif m in "zlib".split():
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -259,7 +259,8 @@
 bundle2.processbundle(self._repo, b)
 raise
 except error.PushRaced as exc:
-raise error.ResponseError(_('push failed:'), str(exc))
+raise error.ResponseError(_('push failed:'),
+  util.forcebytestr(exc))
 
 # End of _basewirecommands interface.
 
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -2149,7 +2149,8 @@
 continue
 except error.UnsupportedBundleSpecification as e:
 repo.ui.debug('filtering %s because unsupported bundle '
-  'spec: %s\n' % (entry['URL'], str(e)))
+  'spec: %s\n' % (
+  entry['URL'], util.forcebytestr(e)))
 continue
 # If we don't have a spec and requested a stream clone, we don't know
 # what the entry is so don't attempt to apply it.
@@ -2254,7 +2255,8 @@
 bundle2.applybundle(repo, cg, tr, 'clonebundles', url)
 return True
 except urlerr.httperror as e:
-ui.warn(_('HTTP error fetching bundle: %s\n') % str(e))
+ui.warn(_('HTTP error fetching bundle: %s\n') %
+util.forcebytestr(e))
 except urlerr.urlerror as e:
 ui.warn(_('error fetching bundle: %s\n') % e.reason)
 
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3899,7 +3899,7 @@
 try:
 return hg.updatetotally(ui, repo, checkout, brev)
 except error.UpdateAbort as inst:
-msg = _("not updating: %s") % str(inst)
+msg = _("not updating: %s") % util.forcebytestr(inst)
 hint = inst.hint
 raise error.UpdateAbort(msg, hint=hint)
 if modheads > 1:



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

D2442: filemerge: do what the context __bytes__ does, but locally

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

REVISION SUMMARY
  str() here is clearly the wrong thing, and I think the code is clearer
  when it doesn't just depend on the magic __{str,bytes}__ behavior.
  
  I decided to grep around for \sstr\( and see what low-hanging fruit
  that showed me. This was part of that hunt. That grep pattern still
  has some things worth exploring.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -520,8 +520,8 @@
 baselabel = 'base'
 env = {'HG_FILE': fcd.path(),
'HG_MY_NODE': short(mynode),
-   'HG_OTHER_NODE': str(fco.changectx()),
-   'HG_BASE_NODE': str(fca.changectx()),
+   'HG_OTHER_NODE': short(fco.changectx().node()),
+   'HG_BASE_NODE': short(fca.changectx().node()),
'HG_MY_ISLINK': 'l' in fcd.flags(),
'HG_OTHER_ISLINK': 'l' in fco.flags(),
'HG_BASE_ISLINK': 'l' in fca.flags(),



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


D2444: http: drop custom http client logic

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

REVISION SUMMARY
  Eight and a half years ago, as my starter bug on code.google.com, I
  investigated a mysterious "broken pipe" error from seemingly random
  clients[0]. That investigation revealed a tragic story: the Python
  standard library's httplib was (and remains) barely functional. During
  large POSTs, if a server responds early with an error (even a
  permission denied error!) the client only notices that the server
  closed the connection and everything breaks. Such server behavior is
  implicitly legal under RFC 2616 (the latest HTTP RFC as of when I was
  last working on this), and my understanding is that later RFCs have
  made it explicitly legal to respond early with any status code outside
  the 2xx range.
  
  I embarked, probably foolishly, on a journey to write a new http
  library with better overall behavior. The http library appears to work
  well in most cases, but it can get confused in the presence of
  proxies, and it depends on select(2) which limits its utility if a lot
  of file descriptors are open. I haven't touched the http library in
  almost two years, and in the interim the Python community has
  discovered a better way[1] of writing network code. In theory some day
  urllib3 will have its own home-grown http library built on h11[2], or
  we could do that. Either way, it's time to declare our current
  confusingly-named "http2" client logic and move on. I do hope to
  revisit this some day: it's still garbage that we can't even respond
  with a 401 or 403 without reading the entire POST body from the
  client, but the goalposts on writing a new http client library have
  moved substantially. We're almost certainly better off just switching
  to requests and eventually picking up their http fixes than trying to
  live with something that realistically only we'll ever use. Another
  approach would be to write an adapter so that Mercurial can use pycurl
  if it's installed. Neither of those approaches seem like they should
  be investigated prior to a release of Mercurial that works on Python
  3: that's where the mindshare is going to be for any improvements to
  the state of the http client art.
  
  0: 
http://web.archive.org/web/20130501031801/http://code.google.com/p/support/issues/detail?id=2716
  1: http://sans-io.readthedocs.io/
  2: https://github.com/njsmith/h11

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/httpclient/__init__.py
  mercurial/httpclient/_readers.py
  mercurial/httpconnection.py
  mercurial/httppeer.py
  mercurial/url.py
  setup.py
  tests/test-check-code.t
  tests/test-commandserver.t

CHANGE DETAILS

diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -211,7 +211,6 @@
   ui.slash=True
   ui.interactive=False
   ui.mergemarkers=detailed
-  ui.usehttp2=true (?)
   ui.foo=bar
   ui.nontty=true
   web.address=localhost
@@ -221,7 +220,6 @@
   ui.slash=True
   ui.interactive=False
   ui.mergemarkers=detailed
-  ui.usehttp2=true (?)
   ui.nontty=true
 
   $ rm -R foo
diff --git a/tests/test-check-code.t b/tests/test-check-code.t
--- a/tests/test-check-code.t
+++ b/tests/test-check-code.t
@@ -13,8 +13,6 @@
   > -X mercurial/thirdparty \
   > | sed 's-\\-/-g' | "$check_code" --warnings --per-file=0 - || false
   Skipping i18n/polib.py it has no-che?k-code (glob)
-  Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
-  Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
   Skipping tests/badserverext.py it has no-che?k-code (glob)
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -806,7 +806,6 @@
 'mercurial.cext',
 'mercurial.cffi',
 'mercurial.hgweb',
-'mercurial.httpclient',
 'mercurial.pure',
 'mercurial.thirdparty',
 'mercurial.thirdparty.attr',
diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -470,17 +470,9 @@
 construct an opener suitable for urllib2
 authinfo will be added to the password manager
 '''
-# experimental config: ui.usehttp2
-if ui.configbool('ui', 'usehttp2'):
-handlers = [
-httpconnectionmod.http2handler(
-ui,
-passwordmgr(ui, ui.httppasswordmgrdb))
-]
-else:
-handlers = [httphandler()]
-if has_https:
-handlers.append(httpshandler(ui))
+handlers = [httphandler()]
+if has_https:
+handlers.append(httpshandler(ui))
 
 handlers.append(proxyhandler(ui))
 
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ 

D2434: util: use pycompat.bytestr() instead of str()

2018-02-25 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 6085.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2434?vs=6079=6085

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1188,7 +1188,7 @@
 return '0'
 if val is True:
 return '1'
-return str(val)
+return pycompat.bytestr(val)
 env = dict(encoding.environ)
 if environ:
 env.update((k, py2shell(v)) for k, v in environ.iteritems())



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


D2438: util: use util.shellquote() instead of repr() in date parse abort

2018-02-25 Thread durin42 (Augie Fackler)
durin42 updated this revision to Diff 6086.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2438?vs=6083=6086

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

AFFECTED FILES
  mercurial/util.py
  tests/test-commit.t
  tests/test-revset.t

CHANGE DETAILS

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -413,7 +413,7 @@
   hg: parse error: invalid \x escape
   [255]
   $ log 'date(tip)'
-  hg: parse error: invalid date: 'tip'
+  hg: parse error: invalid date: tip
   [255]
   $ log '0:date'
   abort: unknown revision 'date'!
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -18,7 +18,7 @@
   hg: parse error: impossible time zone offset: 444
   [255]
   $ hg commit -d '115.1' -m commit-4
-  hg: parse error: invalid date: '1\t15.1'
+  hg: parse error: invalid date: '115.1'
   [255]
   $ hg commit -d 'foo bar' -m commit-5
   hg: parse error: invalid date: 'foo bar'
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2192,7 +2192,7 @@
 else:
 break
 else:
-raise error.ParseError(_('invalid date: %r') % date)
+raise error.ParseError(_('invalid date: %s') % shellquote(date))
 # validate explicit (probably user-specified) date and
 # time zone offset. values must fit in signed 32 bits for
 # current 32-bit linux runtimes. timezones go from UTC-12



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


D2441: py3: convert known-int values to bytes using %d

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

REVISION SUMMARY
  I decided to grep around for \sstr\( and see what low-hanging fruit
  that showed me. This was part of that hunt. That grep pattern still
  has some things worth exploring.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/exchange.py
  mercurial/obsolete.py
  mercurial/patch.py
  mercurial/progress.py

CHANGE DETAILS

diff --git a/mercurial/progress.py b/mercurial/progress.py
--- a/mercurial/progress.py
+++ b/mercurial/progress.py
@@ -121,7 +121,7 @@
 if total:
 add = b'%*d/%d' % (len(str(total)), pos, total)
 else:
-add = str(pos)
+add = b'%d' % pos
 elif indicator.startswith('item') and item:
 slice = 'end'
 if '-' in indicator:
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -566,7 +566,7 @@
 root = tempfile.mkdtemp(prefix='hg-patch-')
 self.opener = vfsmod.vfs(root)
 # Avoid filename issues with these simple names
-fn = str(self.created)
+fn = '%d' % self.created
 self.opener.write(fn, data)
 self.created += 1
 self.files[fname] = (fn, mode, copied)
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -656,7 +656,7 @@
 self.caches.clear()
 # records the number of new markers for the transaction hooks
 previous = int(transaction.hookargs.get('new_obsmarkers', '0'))
-transaction.hookargs['new_obsmarkers'] = str(previous + len(new))
+transaction.hookargs['new_obsmarkers'] = '%d' % (previous + len(new))
 return len(new)
 
 def mergemarkers(self, transaction, data):
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1151,8 +1151,8 @@
 for newremotehead in outdated:
 r = pushop.remote.pushkey('phases',
   newremotehead.hex(),
-  str(phases.draft),
-  str(phases.public))
+  ('%d' % phases.draft),
+  ('%d' % phases.public))
 if not r:
 pushop.ui.warn(_('updating %s to public failed!\n')
% newremotehead)



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


D2443: statichttprepo: move HTTPRangeHandler from byterange and delete the latter

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

REVISION SUMMARY
  It turns out we've been toting around 472 lines of Python just for
  this 20-ish line class that teaches urllib how to handle '206 Partial
  Content'. byterange.py showed up in my \sstr\( Python 3 dragnet, and
  found itself having overstayed its welcome in our codebase.
  
  1. no-check-commit because we're moving code that has to have foo_bar naming.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/byterange.py
  mercurial/statichttprepo.py

CHANGE DETAILS

diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -13,7 +13,6 @@
 
 from .i18n import _
 from . import (
-byterange,
 changelog,
 error,
 localrepo,
@@ -82,10 +81,36 @@
 def close(self):
 pass
 
+# _RangeError and _HTTPRangeHandler were originally in byterange.py,
+# which was itself extracted from urlgrabber. See the last version of
+# byterange.py from history if you need more information.
+class _RangeError(IOError):
+"""Error raised when an unsatisfiable range is requested."""
+
+class _HTTPRangeHandler(urlreq.basehandler):
+"""Handler that enables HTTP Range headers.
+
+This was extremely simple. The Range header is a HTTP feature to
+begin with so all this class does is tell urllib2 that the
+"206 Partial Content" response from the HTTP server is what we
+expected.
+"""
+
+def http_error_206(self, req, fp, code, msg, hdrs):
+# 206 Partial Content Response
+r = urlreq.addinfourl(fp, hdrs, req.get_full_url())
+r.code = code
+r.msg = msg
+return r
+
+def http_error_416(self, req, fp, code, msg, hdrs):
+# HTTP's Range Not Satisfiable error
+raise _RangeError('Requested Range Not Satisfiable')
+
 def build_opener(ui, authinfo):
 # urllib cannot handle URLs with embedded user or passwd
 urlopener = url.opener(ui, authinfo)
-urlopener.add_handler(byterange.HTTPRangeHandler())
+urlopener.add_handler(_HTTPRangeHandler())
 
 class statichttpvfs(vfsmod.abstractvfs):
 def __init__(self, base):
diff --git a/mercurial/byterange.py b/mercurial/byterange.py
deleted file mode 100644
--- a/mercurial/byterange.py
+++ /dev/null
@@ -1,472 +0,0 @@
-#   This library is free software; you can redistribute it and/or
-#   modify it under the terms of the GNU Lesser General Public
-#   License as published by the Free Software Foundation; either
-#   version 2.1 of the License, or (at your option) any later version.
-#
-#   This library is distributed in the hope that it will be useful,
-#   but WITHOUT ANY WARRANTY; without even the implied warranty of
-#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#   Lesser General Public License for more details.
-#
-#   You should have received a copy of the GNU Lesser General Public
-#   License along with this library; if not, see
-#   .
-
-# This file is part of urlgrabber, a high-level cross-protocol url-grabber
-# Copyright 2002-2004 Michael D. Stenner, Ryan Tomayko
-
-# $Id: byterange.py,v 1.9 2005/02/14 21:55:07 mstenner Exp $
-
-from __future__ import absolute_import
-
-import email
-import ftplib
-import mimetypes
-import os
-import re
-import socket
-import stat
-
-from . import (
-urllibcompat,
-util,
-)
-
-urlerr = util.urlerr
-urlreq = util.urlreq
-
-addclosehook = urlreq.addclosehook
-addinfourl = urlreq.addinfourl
-splitattr = urlreq.splitattr
-splitpasswd = urlreq.splitpasswd
-splitport = urlreq.splitport
-splituser = urlreq.splituser
-unquote = urlreq.unquote
-
-class RangeError(IOError):
-"""Error raised when an unsatisfiable range is requested."""
-
-class HTTPRangeHandler(urlreq.basehandler):
-"""Handler that enables HTTP Range headers.
-
-This was extremely simple. The Range header is a HTTP feature to
-begin with so all this class does is tell urllib2 that the
-"206 Partial Content" response from the HTTP server is what we
-expected.
-
-Example:
-import urllib2
-import byterange
-
-range_handler = range.HTTPRangeHandler()
-opener = urlreq.buildopener(range_handler)
-
-# install it
-urlreq.installopener(opener)
-
-# create Request and set Range header
-req = urlreq.request('http://www.python.org/')
-req.header['Range'] = 'bytes=30-50'
-f = urlreq.urlopen(req)
-"""
-
-def http_error_206(self, req, fp, code, msg, hdrs):
-# 206 Partial Content Response
-r = urlreq.addinfourl(fp, hdrs, req.get_full_url())
-r.code = code
-r.msg = msg
-return r
-
-def http_error_416(self, req, fp, code, msg, hdrs):
-# HTTP's Range Not Satisfiable error
-raise 

Re: [PATCH 2 of 2] showconfig: allow multiple section.name selectors (issue5797)

2018-02-25 Thread Augie Fackler
On Wed, Feb 21, 2018 at 11:34:07PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519220867 -32400
> #  Wed Feb 21 22:47:47 2018 +0900
> # Node ID 46e1a9cc97996cc1469efabdeeb4a51ccc552413
> # Parent  11003771245a19f65107b141a9c1adc9461d43ea
> showconfig: allow multiple section.name selectors (issue5797)

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


Re: [PATCH] util: factor out shellsplit() function

2018-02-25 Thread Augie Fackler
On Wed, Feb 21, 2018 at 11:33:51PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519219227 -32400
> #  Wed Feb 21 22:20:27 2018 +0900
> # Node ID 44e4662d7a61ff8272a96045a60c3b005a099f64
> # Parent  0f36926b2651a65944bca6e4247600791e253438
> util: factor out shellsplit() function

queued, 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-25 Thread Augie Fackler
On Thu, Feb 22, 2018 at 09:41:01PM +0900, Yuya Nishihara wrote:
> 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.

Indeed. Python has a few of these, and I periodically pester some
clang-format devs at Google to try and get some progress. That might
finally have borne fruit in the last month: it sounds like eventually
we'll be able to define a macro to clang-format as ending with one of
{,;}, so the formatter will be able to do less-dumb things.

>
>   /* 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
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] diff: do not split function name if character encoding is unknown

2018-02-25 Thread Augie Fackler
On Fri, Feb 23, 2018 at 11:53:18PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519394998 -32400
> #  Fri Feb 23 23:09:58 2018 +0900
> # Node ID 98cfd7926442dc0a649e0359455ad6962815bd13
> # Parent  b8d0761a85c7421071750de23228415306852d69
> diff: do not split function name if character encoding is unknown

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


D2439: py3: whitelist another ten passing tests

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

REVISION SUMMARY
  I now see 293 tests passing[0] and 362 failing, so we're closing in on
  the halfway point. Hooray!
  
  0: A few tests appear to regress in small ways (doctest output
  
changes, for example) on Python 3.7.0a1, which is what I'm now
using to test. That said, I'm pleased to report no major regressions.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -17,6 +17,7 @@
 test-branch-tag-confict.t
 test-bundle-phases.t
 test-bundle-vs-outgoing.t
+test-bundle2-multiple-changegroups.t
 test-cappedreader.py
 test-casecollision.t
 test-cat.t
@@ -32,7 +33,9 @@
 test-clone-pull-corruption.t
 test-clone-r.t
 test-clone-update-order.t
+test-commit-amend.t
 test-commit-unresolved.t
+test-commit.t
 test-completion.t
 test-confused-revert.t
 test-contrib-check-code.t
@@ -112,6 +115,7 @@
 test-histedit-drop.t
 test-histedit-edit.t
 test-histedit-fold-non-commute.t
+test-histedit-fold.t
 test-histedit-no-change.t
 test-histedit-non-commute.t
 test-histedit-obsolete.t
@@ -158,6 +162,7 @@
 test-merge-revert.t
 test-merge-revert2.t
 test-merge-subrepos.t
+test-merge-symlinks.t
 test-merge1.t
 test-merge10.t
 test-merge2.t
@@ -194,7 +199,9 @@
 test-obsolete-checkheads.t
 test-obsolete-distributed.t
 test-parents.t
+test-pending.t
 test-permissions.t
+test-phases.t
 test-pull-branch.t
 test-pull-http.t
 test-pull-permission.t
@@ -229,7 +236,9 @@
 test-push-checkheads-unpushed-D6.t
 test-push-checkheads-unpushed-D7.t
 test-push-warn.t
+test-pushvars.t
 test-rebase-bookmarks.t
+test-rebase-cache.t
 test-rebase-check-restore.t
 test-rebase-dest.t
 test-rebase-emptycommit.t
@@ -243,6 +252,7 @@
 test-rebase-rename.t
 test-rebase-transaction.t
 test-record.t
+test-relink.t
 test-remove.t
 test-rename-after-merge.t
 test-rename-dir-merge.t



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


D2434: util: use pycompat.bytestr() instead of str()

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

REVISION SUMMARY
  This fixes at least some environment variable prints for util.system()
  callers on Python 3. Yay!

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1187,7 +1187,7 @@
 return '0'
 if val is True:
 return '1'
-return str(val)
+return pycompat.bytestr(val)
 env = dict(encoding.environ)
 if environ:
 env.update((k, py2shell(v)) for k, v in environ.iteritems())



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


D2437: subrepo: use util.forcebytestr() instead of str() on exception

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -73,7 +73,8 @@
 raise ex
 except error.Abort as ex:
 subrepo = subrelpath(self)
-errormsg = str(ex) + ' ' + _('(in subrepository "%s")') % subrepo
+errormsg = (util.forcebytestr(ex) + ' '
++ _('(in subrepository "%s")') % subrepo)
 # avoid handling this exception by raising a SubrepoAbort exception
 raise SubrepoAbort(errormsg, hint=ex.hint, subrepo=subrepo,
cause=sys.exc_info())



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


D2438: util: use util.shellquote() instead of repr() in date parse abort

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

REVISION SUMMARY
  This results in slight output changes. I'm not thrilled with seeing a
  literal tab instead of \t in the output, but this is, to my memory,
  consistent with how we've handled this in other places for Python 3
  porting. The loss of quotes in test-revset.t is also vaguely upsetting
  to me, but I don't view it as a BC problem since it's an error
  message, so let's roll with it for now.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py
  tests/test-commit.t
  tests/test-revset.t

CHANGE DETAILS

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -413,7 +413,7 @@
   hg: parse error: invalid \x escape
   [255]
   $ log 'date(tip)'
-  hg: parse error: invalid date: 'tip'
+  hg: parse error: invalid date: tip
   [255]
   $ log '0:date'
   abort: unknown revision 'date'!
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -18,7 +18,7 @@
   hg: parse error: impossible time zone offset: 444
   [255]
   $ hg commit -d '115.1' -m commit-4
-  hg: parse error: invalid date: '1\t15.1'
+  hg: parse error: invalid date: '115.1'
   [255]
   $ hg commit -d 'foo bar' -m commit-5
   hg: parse error: invalid date: 'foo bar'
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2191,7 +2191,7 @@
 else:
 break
 else:
-raise error.ParseError(_('invalid date: %r') % date)
+raise error.ParseError(_('invalid date: %s') % shellquote(date))
 # validate explicit (probably user-specified) date and
 # time zone offset. values must fit in signed 32 bits for
 # current 32-bit linux runtimes. timezones go from UTC-12



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


D2436: tests: add missing b prefixes in test-commit.t

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

REVISION SUMMARY
  1. skip-blame just some b prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-commit.t

CHANGE DETAILS

diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -644,14 +644,14 @@
   $ cat > evil-commit.py < from __future__ import absolute_import
   > from mercurial import context, hg, node, ui as uimod
-  > notrc = u".h\u200cg".encode('utf-8') + '/hgrc'
+  > notrc = u".h\u200cg".encode('utf-8') + b'/hgrc'
   > u = uimod.ui.load()
-  > r = hg.repository(u, '.')
+  > r = hg.repository(u, b'.')
   > def filectxfn(repo, memctx, path):
   > return context.memfilectx(repo, memctx, path,
-  > '[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r['tip'].node(), node.nullid],
-  >'evil', [notrc], filectxfn, 0)
+  > b'[hooks]\nupdate = echo owned')
+  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  >b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF
   $ $PYTHON evil-commit.py
@@ -670,14 +670,14 @@
   $ cat > evil-commit.py < from __future__ import absolute_import
   > from mercurial import context, hg, node, ui as uimod
-  > notrc = "HG~1/hgrc"
+  > notrc = b"HG~1/hgrc"
   > u = uimod.ui.load()
-  > r = hg.repository(u, '.')
+  > r = hg.repository(u, b'.')
   > def filectxfn(repo, memctx, path):
   > return context.memfilectx(repo, memctx, path,
-  > '[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r['tip'].node(), node.nullid],
-  >'evil', [notrc], filectxfn, 0)
+  > b'[hooks]\nupdate = echo owned')
+  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  >b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF
   $ $PYTHON evil-commit.py
@@ -690,14 +690,14 @@
   $ cat > evil-commit.py < from __future__ import absolute_import
   > from mercurial import context, hg, node, ui as uimod
-  > notrc = "HG8B6C~2/hgrc"
+  > notrc = b"HG8B6C~2/hgrc"
   > u = uimod.ui.load()
-  > r = hg.repository(u, '.')
+  > r = hg.repository(u, b'.')
   > def filectxfn(repo, memctx, path):
   > return context.memfilectx(repo, memctx, path,
-  > '[hooks]\nupdate = echo owned')
-  > c = context.memctx(r, [r['tip'].node(), node.nullid],
-  >'evil', [notrc], filectxfn, 0)
+  > b'[hooks]\nupdate = echo owned')
+  > c = context.memctx(r, [r[b'tip'].node(), node.nullid],
+  >b'evil', [notrc], filectxfn, 0)
   > r.commitctx(c)
   > EOF
   $ $PYTHON evil-commit.py



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


D2435: commitextras: fix on Python 3 by using sysstrs for __dict__ ops

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

REVISION SUMMARY
  I'm dubious of the __dict__ shenanigans in use here, but lack the
  enthusiasm for figuring out why that was done right now.
  
  1. skip-blame just some r prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/commitextras.py

CHANGE DETAILS

diff --git a/hgext/commitextras.py b/hgext/commitextras.py
--- a/hgext/commitextras.py
+++ b/hgext/commitextras.py
@@ -70,7 +70,7 @@
 
 # This __dict__ logic is needed because the normal
 # extension.wrapfunction doesn't seem to work.
-repo.__dict__['commit'] = _wrappedcommit
+repo.__dict__[r'commit'] = _wrappedcommit
 return orig(ui, repo, *pats, **opts)
 finally:
-del repo.__dict__['commit']
+del repo.__dict__[r'commit']



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


[PATCH 1 of 2] run-tests: cache hghave results

2018-02-25 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1519597345 18000
#  Sun Feb 25 17:22:25 2018 -0500
# Node ID e373776c800cffaf47934cf688307f5ce8e85d17
# Parent  3bdd64ed150679886ee87341ab3fcdda4f23ffc7
run-tests: cache hghave results

Spawning a process on Windows is expensive.  I've got a version of
test-lfs-test-server.t locally which prints the http request/responses that
totals 819 lines, with 149 conditional lines, 11 #if tests, and 2 test cases.
It takes just under 1 minute with this change to run both cases, vs just over
2 minutes without this change.  Worse, when I explored adding ui.debug to the
test, it takes 13 minutes due to all of the mismatches and retests, vs less than
1 minute with this change.  Overall, the difference when running all tests is
negligible- 103 minutes with this change, vs 105 without when using -j9.

`hghave` effectively ANDs the requirements, so for a list of requirements that
test successfully, they can all be individually cached.  The 'no-' prefixed
stuff can maybe be inverted (though it wants stdout for the False case).  It
might be possible to cache this at a higher level instead of per test, but this
is where the hghave() function lives.

It also looks like an exit value of 2 from `hghave` is treated specially, but
there's nothing preventing 2 missing features from also using this value.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1236,6 +1236,7 @@
 self.name = '%s (case %s)' % (self.name, _strpath(case))
 self.errpath = b'%s.%s.err' % (self.errpath[:-4], case)
 self._tmpname += b'-%s' % case
+self._have = {}
 
 @property
 def refpath(self):
@@ -1275,6 +1276,18 @@
 return self._processoutput(exitcode, output, salt, after, expected)
 
 def _hghave(self, reqs):
+if len(reqs) == 1:
+# Fastpath
+if reqs[0] in self._have:
+return self._have.get(reqs[0])
+elif all(r in self._have for r in reqs):
+for r in reqs:
+status, stdout = self._have.get(r)
+if not status:
+break
+else:
+return True, None
+
 # TODO do something smarter when all other uses of hghave are gone.
 runtestdir = os.path.abspath(os.path.dirname(_bytespath(__file__)))
 tdir = runtestdir.replace(b'\\', b'/')
@@ -1290,10 +1303,18 @@
 sys.exit(1)
 
 if ret != 0:
+# Don't bother trying to figure out which requirement in a list was
+# the failure.  But a single failure can be cached.
+if len(reqs) == 1:
+self._have[reqs[0]] = (False, stdout)
 return False, stdout
 
 if b'slow' in reqs:
 self._timeout = self._slowtimeout
+
+for r in reqs:
+self._have[r] = (True, None)
+
 return True, None
 
 def _iftest(self, args):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] run-tests: don't mask errors when a server fails to start

2018-02-25 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1519610652 18000
#  Sun Feb 25 21:04:12 2018 -0500
# Node ID 999316b407a5035d50aa511199895c83d4047423
# Parent  e373776c800cffaf47934cf688307f5ce8e85d17
run-tests: don't mask errors when a server fails to start

There are sporadic instances of this on Windows.  They seem to happen more
frequently after the test machine is rebooted, although the only way to hit it
on my laptop is to loop certain tests with -j9 for hours.  The problem with
masking out the specific failure is that there's no way to know if it's the same
line in the test that's failing, or if it is random.

The justification for adding this masking in 52e9e63f1495 was that the failures
occur regularly, but that's not the case anymore.  The port number is still
printed, in case that turns out to be useful.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1784,19 +1784,19 @@
 servefail, lines = getdiff(expected, got,
test.refpath, test.errpath)
 if servefail:
-raise test.failureException(
+self.stream.write(
 'server failed to start (HGPORT=%s)' % test._startport)
-else:
-self.stream.write('\n')
-for line in lines:
-line = highlightdiff(line, self.color)
-if PYTHON3:
-self.stream.flush()
-self.stream.buffer.write(line)
-self.stream.buffer.flush()
-else:
-self.stream.write(line)
-self.stream.flush()
+
+self.stream.write('\n')
+for line in lines:
+line = highlightdiff(line, self.color)
+if PYTHON3:
+self.stream.flush()
+self.stream.buffer.write(line)
+self.stream.buffer.flush()
+else:
+self.stream.write(line)
+self.stream.flush()
 
 # handle interactive prompt without releasing iolock
 if self._options.interactive:
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -541,10 +541,16 @@
   >   $ echo 'abort: child process failed to start blah'
   > EOF
   $ rt test-serve-fail.t
+  server failed to start (HGPORT=*) (glob)
+  --- $TESTTMP/test-serve-fail.t
+  +++ $TESTTMP/test-serve-fail.t.err
+  @@ -1 +1,2 @@
+ $ echo 'abort: child process failed to start blah'
+  +  abort: child process failed to start blah
   
   ERROR: test-serve-fail.t output changed
   !
-  Failed test-serve-fail.t: server failed to start (HGPORT=*) (glob)
+  Failed test-serve-fail.t: output changed
   # Ran 1 tests, 0 skipped, 1 failed.
   python hash seed: * (glob)
   [1]
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2] acl: replace bare getpass.getuser() by platform function

2018-02-25 Thread Gregory Szorc
On Sat, Feb 24, 2018 at 6:43 PM, Yuya Nishihara  wrote:

> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519524781 -32400
> #  Sun Feb 25 11:13:01 2018 +0900
> # Node ID 03eff66adb3b53f9776628f83b6433ee7b57ee52
> # Parent  38f4805020437f126f5c1c8f41d78445f9ab6547
> acl: replace bare getpass.getuser() by platform function
>

Queued these 2. Thanks for the follow-ups.


>
> Follows up dbadf28d4db0. bytestr() shouldn't be applied here because
> getuser()
> isn't guaranteed to be all in ASCII.
>
> This change means GetUserNameA() is used on Windows, but that's probably
> better than trying to get the current user name in UNIX way.
>
> diff --git a/hgext/acl.py b/hgext/acl.py
> --- a/hgext/acl.py
> +++ b/hgext/acl.py
> @@ -193,14 +193,11 @@ 3) Deny access to a file to anyone but u
>
>  from __future__ import absolute_import
>
> -import getpass
> -
>  from mercurial.i18n import _
>  from mercurial import (
>  error,
>  extensions,
>  match,
> -pycompat,
>  registrar,
>  util,
>  )
> @@ -341,7 +338,7 @@ def hook(ui, repo, hooktype, node=None,
>  user = urlreq.unquote(url[3])
>
>  if user is None:
> -user = pycompat.bytestr(getpass.getuser())
> +user = util.getuser()
>
>  ui.debug('acl: checking access for user "%s"\n' % user)
>
> ___
> 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


Re: [PATCH 1 of 2] acl: replace bare getpass.getuser() by platform function

2018-02-25 Thread Pulkit Goyal
Missed the followup. Thanks for it. Looks good to me.

On Sun, Feb 25, 2018 at 8:13 AM, Yuya Nishihara  wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1519524781 -32400
> #  Sun Feb 25 11:13:01 2018 +0900
> # Node ID 03eff66adb3b53f9776628f83b6433ee7b57ee52
> # Parent  38f4805020437f126f5c1c8f41d78445f9ab6547
> acl: replace bare getpass.getuser() by platform function
>
> Follows up dbadf28d4db0. bytestr() shouldn't be applied here because getuser()
> isn't guaranteed to be all in ASCII.
>
> This change means GetUserNameA() is used on Windows, but that's probably
> better than trying to get the current user name in UNIX way.
>
> diff --git a/hgext/acl.py b/hgext/acl.py
> --- a/hgext/acl.py
> +++ b/hgext/acl.py
> @@ -193,14 +193,11 @@ 3) Deny access to a file to anyone but u
>
>  from __future__ import absolute_import
>
> -import getpass
> -
>  from mercurial.i18n import _
>  from mercurial import (
>  error,
>  extensions,
>  match,
> -pycompat,
>  registrar,
>  util,
>  )
> @@ -341,7 +338,7 @@ def hook(ui, repo, hooktype, node=None,
>  user = urlreq.unquote(url[3])
>
>  if user is None:
> -user = pycompat.bytestr(getpass.getuser())
> +user = util.getuser()
>
>  ui.debug('acl: checking access for user "%s"\n' % user)
>
> ___
> 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