D483: tests: fixed a bytes/unicode confusion in the test runner

2017-08-22 Thread alex.gaynor (Alex Gaynor)
alex.gaynor created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  py3k-test (bookmark) on default (branch)

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1460,7 +1460,7 @@
 if not el.endswith(b" (?)\n"):
 m = optline.match(el)
 if m:
-conditions = [c for c in m.group(2).split(' ')]
+conditions = [c for c in m.group(2).split(b' 
')]
 
 if self._hghave(conditions)[0]:
 # Don't append as optional line



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


D482: bundle2: fixed usage of an attribute that was removed in py3k

2017-08-22 Thread indygreg (Gregory Szorc)
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  The commit message should likely say something about how the existing use of 
`string.letters` was logically wrong, since it is locale dependent. 
`string.ascii_letters` is definitely the variable we should have been using all 
along.

REPOSITORY
  rHG Mercurial

BRANCH
  py3k-stuff (bookmark) on default (branch)

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

To: alex.gaynor, 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


Re: D464: Use an unambigious path suffix for the commit editor file.

2017-08-22 Thread Sean Farley

Jun Wu  writes:

> I think this patch is about changing the suffix. I guess some less powerful
> editors may only support matching file types by suffixes.

Yeah, it seems that way.

> Please correct me if I'm wrong, but I failed to see how the
> "experimental.editortmpinhg" setting could be used as-is to change the
> suffix. Therefore I think the patch is still needed.
>
> Maybe we can change it to a config option? Like, instead of saying:
>
> extra_defaults = {
> 'prefix': 'editor',
> 'suffix': '.txt',
> }
>
> Changing ".txt" there to be a config option (maybe
> experimental.editorsuffix).

That seems a bit over complicated to me. Why not just just use the
random tmp as a directory instead of a file while renaming the file at
the same time:

/tmp/XYZ123/hg-editor (or HG_EDITOR or whatever)

This would allow 'editortmpinhg'[1] to just be .hg/hg-editor (or
HG_EDITOR etc). The '~' seems a bit like a quick hack and I think I'd
prefer to do this cleanly. My logic here is:

1) if we can append a character to the suffix, then we should be able to
change the directory

2) we might want different 'file types' for different tmp files and '~'
   seems that it might not get us far enough. For instance:
   a) editor,
   b) conflicts
   c) histedit
   etc

For (a) and (c), I hacked something together for my fork of magit
(called mahgic) so that I can have different modes for commit (to show
the diff) and for histedit (so that 'tab' and 'enter' will show the
commit at the point).

[1] I planned on making editortmpinhg a more thorough thing so that
everything would be in the .hg directory so that programs (like emacs)
would be able to find the correct repo given only the tmp file.


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


D451: revset: remove order information from tree

2017-08-22 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> quark wrote in revset.py:55
> Agree `anyorder` could be a surprise. I was trying to optimize aggressively. 
> Maybe `followorder` is a better default since `subset & x` is the old default.

Actually, `defineorder` as default also makes sense and seems to be better. 
I'll use it.

REPOSITORY
  rHG Mercurial

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

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


[PATCH 2 of 7 v2] md5sum: assume hashlib exists now that we're 2.7 only

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503428230 14400
#  Tue Aug 22 14:57:10 2017 -0400
# Node ID 6a9a8a60bced4b42a4b019b2f98c97672ce7a42b
# Parent  536b3969d2242224898f574919b134df4ba190a8
md5sum: assume hashlib exists now that we're 2.7 only

diff --git a/tests/md5sum.py b/tests/md5sum.py
--- a/tests/md5sum.py
+++ b/tests/md5sum.py
@@ -8,17 +8,11 @@
 
 from __future__ import absolute_import
 
+import hashlib
 import os
 import sys
 
 try:
-import hashlib
-md5 = hashlib.md5
-except ImportError:
-import md5
-md5 = md5.md5
-
-try:
 import msvcrt
 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
@@ -32,7 +26,7 @@ for filename in sys.argv[1:]:
 sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg))
 sys.exit(1)
 
-m = md5()
+m = hashlib.md5()
 try:
 for data in iter(lambda: fp.read(8192), b''):
 m.update(data)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 7 of 7 v2] python3: whitelist test-imports-checker.t, which now passes

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503414046 14400
#  Tue Aug 22 11:00:46 2017 -0400
# Node ID 2959ea035b9d1ddfe41dc48c2893a9ebd6c2f160
# Parent  fb3748bd846a240924cbf6172162dbe6851514e5
python3: whitelist test-imports-checker.t, which now passes

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -20,6 +20,7 @@ test-empty-dir.t
 test-empty.t
 test-excessive-merge.t
 test-hghave.t
+test-imports-checker.t
 test-issue1089.t
 test-issue1993.t
 test-issue842.t
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 6 of 7 v2] contrib: make import checker always think in terms of bytes

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503421108 14400
#  Tue Aug 22 12:58:28 2017 -0400
# Node ID fb3748bd846a240924cbf6172162dbe6851514e5
# Parent  8dd9a90a0dede651e23211a772732ed19e5a29c5
contrib: make import checker always think in terms of bytes

The doctests now do some regrettable things, but they'll always work
since we're dealing with ASCII module names etc.

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -616,22 +616,26 @@ def _cycle_sortkey(c):
 def embedded(f, modname, src):
 """Extract embedded python code
 
+>>> def _forcestr(thing):
+... if not isinstance(thing, str):
+... return thing.decode('ascii')
+... return thing
 >>> def test(fn, lines):
-... for s, m, f, l in embedded(fn, "example", lines):
-... print("%s %s %s" % (m, f, l))
-... print(repr(s))
+... for s, m, f, l in embedded(fn, b"example", lines):
+... print("%s %s %d" % (_forcestr(m), _forcestr(f), l))
+... print(repr(_forcestr(s)))
 >>> lines = [
-...   'comment',
-...   '  >>> from __future__ import print_function',
-...   "  >>> ' multiline",
-...   "  ... string'",
-...   '  ',
-...   'comment',
-...   '  $ cat > foo.py < from __future__ import print_function',
-...   '  > EOF',
+...   b'comment',
+...   b'  >>> from __future__ import print_function',
+...   b"  >>> ' multiline",
+...   b"  ... string'",
+...   b'  ',
+...   b'comment',
+...   b'  $ cat > foo.py < from __future__ import print_function',
+...   b'  > EOF',
 ... ]
->>> test("example.t", lines)
+>>> test(b"example.t", lines)
 example[2] doctest.py 2
 "from __future__ import print_function\\n' multiline\\nstring'\\n"
 example[7] foo.py 7
@@ -653,16 +657,16 @@ def embedded(f, modname, src):
 if not inlinepython:
 # We've just entered a Python block.
 inlinepython = n
-t = 'doctest.py'
+t = b'doctest.py'
 script.append(l[prefix:])
 continue
 if l.startswith(b'  ... '): # python inlines
 script.append(l[prefix:])
 continue
-cat = re.search(r"\$ \s*cat\s*>\s*(\S+\.py)\s*<<\s*EOF", l)
+cat = re.search(br"\$ \s*cat\s*>\s*(\S+\.py)\s*<<\s*EOF", l)
 if cat:
 if inlinepython:
-yield ''.join(script), ("%s[%d]" %
+yield b''.join(script), (b"%s[%d]" %
(modname, inlinepython)), t, inlinepython
 script = []
 inlinepython = 0
@@ -671,7 +675,7 @@ def embedded(f, modname, src):
 continue
 if shpython and l.startswith(b'  > '): # sh continuation
 if l == b'  > EOF\n':
-yield ''.join(script), ("%s[%d]" %
+yield b''.join(script), (b"%s[%d]" %
(modname, shpython)), t, shpython
 script = []
 shpython = 0
@@ -679,7 +683,7 @@ def embedded(f, modname, src):
 script.append(l[4:])
 continue
 if inlinepython and l == b'  \n':
-yield ''.join(script), ("%s[%d]" %
+yield b''.join(script), (b"%s[%d]" %
(modname, inlinepython)), t, inlinepython
 script = []
 inlinepython = 0
@@ -697,11 +701,11 @@ def sources(f, modname):
 """
 py = False
 if not f.endswith('.t'):
-with open(f) as src:
+with open(f, 'rb') as src:
 yield src.read(), modname, f, 0
 py = True
 if py or f.endswith('.t'):
-with open(f) as src:
+with open(f, 'rb') as src:
 for script, modname, t, line in embedded(f, modname, src):
 yield script, modname, t, line
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 7 v2] tests: update test-archive to always use hashlib

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503428272 14400
#  Tue Aug 22 14:57:52 2017 -0400
# Node ID 97dba357fcdb6caf5a0f9f5f074a69306a5a8950
# Parent  6a9a8a60bced4b42a4b019b2f98c97672ce7a42b
tests: update test-archive to always use hashlib

We don't need the fallback to the old modules anymore.

diff --git a/tests/test-archive.t b/tests/test-archive.t
--- a/tests/test-archive.t
+++ b/tests/test-archive.t
@@ -211,15 +211,12 @@ The '-t' should override autodetection
   > done
 
   $ cat > md5comp.py < from __future__ import print_function
-  > try:
-  > from hashlib import md5
-  > except ImportError:
-  > from md5 import md5
+  > from __future__ import absolute_import, print_function
+  > import hashlib
   > import sys
   > f1, f2 = sys.argv[1:3]
-  > h1 = md5(open(f1, 'rb').read()).hexdigest()
-  > h2 = md5(open(f2, 'rb').read()).hexdigest()
+  > h1 = hashlib.md5(open(f1, 'rb').read()).hexdigest()
+  > h2 = hashlib.md5(open(f2, 'rb').read()).hexdigest()
   > print(h1 == h2 or "md5 differ: " + repr((h1, h2)))
   > EOF
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 7 v2] undumprevlog: update to valid Python 3 syntax

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503421131 14400
#  Tue Aug 22 12:58:51 2017 -0400
# Node ID 536b3969d2242224898f574919b134df4ba190a8
# Parent  af20468eb0a499c094dbd6e27ffcacf54cf5a8e6
undumprevlog: update to valid Python 3 syntax

I didn't do anything to ensure correctness here, just enough to avoid
tracebacks in the import checker, which uses the native ast module to
try and parse all our Python files.

diff --git a/contrib/undumprevlog b/contrib/undumprevlog
--- a/contrib/undumprevlog
+++ b/contrib/undumprevlog
@@ -3,7 +3,7 @@
 # $ hg init
 # $ undumprevlog < repo.dump
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import sys
 from mercurial import (
@@ -27,7 +27,7 @@ while True:
 if l.startswith("file:"):
 f = l[6:-1]
 r = revlog.revlog(opener, f)
-print f
+print(f)
 elif l.startswith("node:"):
 n = node.bin(l[6:-1])
 elif l.startswith("linkrev:"):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 7 v2] tests: stop using old except syntax in test-bundle2-format

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503428707 14400
#  Tue Aug 22 15:05:07 2017 -0400
# Node ID ccb38cfe8b6d7833490e9db28eda18968f27c490
# Parent  97dba357fcdb6caf5a0f9f5f074a69306a5a8950
tests: stop using old except syntax in test-bundle2-format

diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -89,7 +89,7 @@ Create an extension to test bundle2 API
   > p = p.split('=', 1)
   > try:
   > bundler.addparam(*p)
-  > except ValueError, exc:
+  > except ValueError as exc:
   > raise error.Abort('%s' % exc)
   > 
   > if opts['compress']:
@@ -164,7 +164,7 @@ Create an extension to test bundle2 API
   > try:
   > for chunk in bundler.getchunks():
   > file.write(chunk)
-  > except RuntimeError, exc:
+  > except RuntimeError as exc:
   > raise error.Abort(exc)
   > finally:
   > file.flush()
@@ -180,9 +180,9 @@ Create an extension to test bundle2 API
   > unbundler = bundle2.getunbundler(ui, sys.stdin)
   > op = bundle2.processbundle(repo, unbundler, lambda: tr)
   > tr.close()
-  > except error.BundleValueError, exc:
+  > except error.BundleValueError as exc:
   > raise error.Abort('missing support for %s' % exc)
-  > except error.PushRaced, exc:
+  > except error.PushRaced as exc:
   > raise error.Abort('push race: %s' % exc)
   > finally:
   > if tr is not None:
@@ -206,7 +206,7 @@ Create an extension to test bundle2 API
   > unbundler = bundle2.getunbundler(ui, sys.stdin)
   > try:
   > params = unbundler.params
-  > except error.BundleValueError, exc:
+  > except error.BundleValueError as exc:
   >raise error.Abort('unknown parameters: %s' % exc)
   > ui.write('options count: %i\n' % len(params))
   > for key in sorted(params):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 7 v2] contrib: work around some modules not existing on Py3 in import checker

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503413909 14400
#  Tue Aug 22 10:58:29 2017 -0400
# Node ID 8dd9a90a0dede651e23211a772732ed19e5a29c5
# Parent  ccb38cfe8b6d7833490e9db28eda18968f27c490
contrib: work around some modules not existing on Py3 in import checker

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -12,7 +12,10 @@ import sys
 # to work when run from a virtualenv.  The modules were chosen empirically
 # so that the return value matches the return value without virtualenv.
 if True: # disable lexical sorting checks
-import BaseHTTPServer
+try:
+import BaseHTTPServer as basehttpserver
+except ImportError:
+basehttpserver = None
 import zlib
 
 # Whitelist of modules that symbols can be directly imported from.
@@ -183,8 +186,9 @@ def populateextmods(localmods):
 def list_stdlib_modules():
 """List the modules present in the stdlib.
 
+>>> py3 = sys.version_info[0] >= 3
 >>> mods = set(list_stdlib_modules())
->>> 'BaseHTTPServer' in mods
+>>> 'BaseHTTPServer' in mods or py3
 True
 
 os.path isn't really a module, so it's missing:
@@ -201,7 +205,7 @@ def list_stdlib_modules():
 >>> 'collections' in mods
 True
 
->>> 'cStringIO' in mods
+>>> 'cStringIO' in mods or py3
 True
 
 >>> 'cffi' in mods
@@ -223,7 +227,9 @@ def list_stdlib_modules():
 stdlib_prefixes = {sys.prefix, sys.exec_prefix}
 # We need to supplement the list of prefixes for the search to work
 # when run from within a virtualenv.
-for mod in (BaseHTTPServer, zlib):
+for mod in (basehttpserver, zlib):
+if mod is None:
+continue
 try:
 # Not all module objects have a __file__ attribute.
 filename = mod.__file__
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D451: revset: remove order information from tree

2017-08-22 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> martinvonz wrote in test-revset.t:2893
> Does that mean you'll remove the other.sort() in fullreposet.__and__?

In another way. With the new code (`anyorder` gets aggressively used), 
`fullrepo & xs` would be optimized to `xs & fullrepo` and the latter does not 
have the sort.

REPOSITORY
  rHG Mercurial

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

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


[PATCH] obscache: use _readmarkers() from core with correct signature

2017-08-22 Thread Martin von Zweigbergk via Mercurial-devel
# HG changeset patch
# User Martin von Zweigbergk 
# Date 1503424759 25200
#  Tue Aug 22 10:59:19 2017 -0700
# Node ID efc4b69aecfb3b407ca362cff31805e9672c
# Parent  95470e817c00b03fcf99e486412cc7d7f0116681
obscache: use _readmarkers() from core with correct signature

The copied _readmarkers() went stale with Mercurial core commit
5d3ba4395288 (obsstore: let read marker API take a range of offsets,
2017-06-04). At the same time, the Mercurial core version of the
function gained the desired offset argument, so we can now use that
function.

diff --git a/hgext3rd/evolve/obscache.py b/hgext3rd/evolve/obscache.py
--- a/hgext3rd/evolve/obscache.py
+++ b/hgext3rd/evolve/obscache.py
@@ -127,6 +127,11 @@
   % diskversion)
 return diskversion, obsolete.formats[diskversion][0](data, off)
 
+if obsolete._readmarkers.__code__.co_argcount > 1:
+# hg-4.3+ has the "offset" parameter, and _fm?readmarkers also have an
+# extra "stop" parameter
+_readmarkers = obsolete._readmarkers
+
 def markersfrom(obsstore, byteoffset, firstmarker):
 if not firstmarker:
 return list(obsstore)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D482: bundle2: fixed usage of an attribute that was removed in py3k

2017-08-22 Thread alex.gaynor (Alex Gaynor)
alex.gaynor created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

BRANCH
  py3k-stuff (bookmark) on default (branch)

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

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
@@ -587,7 +587,7 @@
 """add a stream level parameter"""
 if not name:
 raise ValueError('empty parameter name')
-if name[0] not in string.letters:
+if name[0] not in pycompat.bytestr(string.ascii_letters):
 raise ValueError('non letter first character: %r' % name)
 self._params.append((name, value))
 
@@ -765,7 +765,7 @@
 """
 if not name:
 raise ValueError('empty parameter name')
-if name[0] not in string.letters:
+if name[0] not in pycompat.bytestr(string.ascii_letters):
 raise ValueError('non letter first character: %r' % name)
 try:
 handler = b2streamparamsmap[name.lower()]



To: alex.gaynor, 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] copies: fix misaligned lines

2017-08-22 Thread Gábor Stefanik
# HG changeset patch
# User Gábor Stefanik 
# Date 1503411399 -7200
#  Tue Aug 22 16:16:39 2017 +0200
# Node ID 3b8c9025f9b966a3e58334024c3f7b3136f500fe
# Parent  e02a08d63ad20097419f935fdd8a91c42ecd88e3
copies: fix misaligned lines

diff -r e02a08d63ad2 -r 3b8c9025f9b9 mercurial/copies.py
--- a/mercurial/copies.py   Tue Aug 22 16:08:31 2017 +0200
+++ b/mercurial/copies.py   Tue Aug 22 16:16:39 2017 +0200
@@ -379,7 +379,7 @@
 # if we have a dirty endpoint, we need to trigger graft logic, and also
 # keep track of which endpoint is dirty
 dirtyc1 = not (base == _c1 or base.descendant(_c1))
-dirtyc2 = not (base== _c2 or base.descendant(_c2))
+dirtyc2 = not (base == _c2 or base.descendant(_c2))
 graft = dirtyc1 or dirtyc2
 tca = base
 if graft:

 This message, including its attachments, is confidential and the property of 
NNG Llc. For more information please read NNG's email policy here:
http://www.nng.com/emailpolicy/
By responding to this email you accept the email policy.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 7 of 9 V3] template: compute dates in obsfatedate

2017-08-22 Thread Yuya Nishihara
On Mon, 21 Aug 2017 10:43:59 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1499088850 -7200
> #  Mon Jul 03 15:34:10 2017 +0200
> # Node ID faad6d683f7a30996007116d296df9ebf853c44d
> # Parent  2fee3b06f7b09f35dcfa312b645cf94090c11fb9
> # EXP-Topic obsfatetemplate
> template: compute dates in obsfatedate
> 
> Extract the dates from obsmarkers. Compute the min and max date from the
> obsmarker range list.
> 
> diff -r 2fee3b06f7b0 -r faad6d683f7a mercurial/obsutil.py
> --- a/mercurial/obsutil.pyMon Jul 03 15:34:00 2017 +0200
> +++ b/mercurial/obsutil.pyMon Jul 03 15:34:10 2017 +0200
> @@ -591,6 +591,20 @@
>  
>  return {'users': sorted(users)}
>  
> +def _successorsetdates(successorset, markers):
> +"""returns the max date and the min date of the markers list
> +"""
> +
> +if not markers:
> +return {}
> +
> +dates = [m[4] for m in markers]
> +
> +return {
> +'min_date': min(dates),
> +'max_date': max(dates)
> +}

Perhaps we'll want a list of dates, min(), and max() functions?

  "{min(markers % date)}"
   ^^^
   not work currently, so we'll probably need a function to
   extract 'date' fields from markers.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 9 V3] template: compute verb in obsfateverb

2017-08-22 Thread Yuya Nishihara
On Mon, 21 Aug 2017 10:43:57 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1499088807 -7200
> #  Mon Jul 03 15:33:27 2017 +0200
> # Node ID 66a2b0407c8cffedfae4897bd7a2f0e2d6a22363
> # Parent  84a35f753f9ab500902f5c06ce3845ce85e5b5a9
> # EXP-Topic obsfatetemplate
> template: compute verb in obsfateverb

> +@templatefunc('obsfateverb(successors, markers)')
> +def obsfateverb(context, mapping, args):
> +""" Compute obsfate related information based on successors and markers
> +"""
> +successors = evalfuncarg(context, mapping, args[0])
> +markers = evalfuncarg(context, mapping, args[1])
> +
> +return obsutil._successorsetverb(successors, markers)['verb']

This will need to check the number of arguments and their types.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 9 V3] template: add minimal obsfate template function

2017-08-22 Thread Yuya Nishihara
On Mon, 21 Aug 2017 10:43:56 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1502987171 -7200
> #  Thu Aug 17 18:26:11 2017 +0200
> # Node ID 84a35f753f9ab500902f5c06ce3845ce85e5b5a9
> # Parent  89a659e236b906e58a48dfed8a4e3b89372d7184
> # EXP-Topic obsfatetemplate
> template: add minimal obsfate template function

> +@templatekeyword("succsandmarkers")
> +def showsuccsandmarkers(repo, ctx, **args):
> +"""Returns a list of dict for each final successor of ctx.
> +
> +The dict contains successors node id in "successors" keys and the list of
> +obs-markers from ctx to the set of successors in "markers"
> +"""

Please mark all template keywords/functions as (EXPERIMENTAL). I believe
most people don't like "succs and markers" so these template functions will
probably change if someone come up with a better idea.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 6 of 9 V3] template: compute user in obsfateusers

2017-08-22 Thread Yuya Nishihara
On Mon, 21 Aug 2017 10:43:58 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1499088840 -7200
> #  Mon Jul 03 15:34:00 2017 +0200
> # Node ID 2fee3b06f7b09f35dcfa312b645cf94090c11fb9
> # Parent  66a2b0407c8cffedfae4897bd7a2f0e2d6a22363
> # EXP-Topic obsfatetemplate
> template: compute user in obsfateusers

> +def _successorsetusers(successorset, markers):
> +""" Returns a sorted list of markers users without duplicates
> +"""
> +if not markers:
> +return {}
> +
> +# Check that user is present in meta
> +markersmeta = [dict(m[3]) for m in markers]
> +users = set(meta.get('user') for meta in markersmeta if meta.get('user'))
> +
> +return {'users': sorted(users)}

[...]

> +@templatefunc('obsfateusers(successors, markers)')
> +def obsfateusers(context, mapping, args):
> +""" Compute obsfate related information based on successors and markers
> +"""
> +successors = evalfuncarg(context, mapping, args[0])
> +markers = evalfuncarg(context, mapping, args[1])
> +data = obsutil._successorsetusers(successors, markers)
> +
> +_hybrid = templatekw._hybrid
> +
> +def makemap(x):
> +return x
> +
> +def joinfmt(d):
> +return d
> +
> +return _hybrid(None, [data], makemap, joinfmt)

Why isn't this a list of users, but a list of dict of list of users?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D476: util: add an mmapread method

2017-08-22 Thread mbthomas (Mark Thomas)
mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is useful for large files that are only partly touched.

TEST PLAN
  Will be used and tested in a later patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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 mmap
 import os
 import platform as pyplatform
 import re as remod
@@ -407,6 +408,12 @@
 self._lenbuf += len(data)
 self._buffer.append(data)
 
+def mmapread(fp):
+try:
+return mmap.mmap(fp.fileno(), 0, access=mmap.ACCESS_READ)
+except ValueError: # cannot mmap an empty file
+return ''
+
 def popen2(cmd, env=None, newlines=False):
 # Setting bufsize to -1 lets the system decide the buffer size.
 # The default for bufsize is 0, meaning unbuffered. This leads to



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


mercurial@33866: new changeset

2017-08-22 Thread Mercurial Commits
New changeset in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/4e8a46c25fac
changeset:   33866:4e8a46c25fac
bookmark:@
tag: tip
user:Matthieu Laneuville 
date:Tue Aug 22 11:00:00 2017 +0200
summary: run-tests: pre instantiate pygments objects

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


D451: revset: remove order information from tree

2017-08-22 Thread yuja (Yuya Nishihara)
yuja added a comment.


  In https://phab.mercurial-scm.org/D451#7257, @yuja wrote:
  
  > So, `anyorder` for `not x` would be my mistake because `x and not y` could 
be
  >  theoretically flipped.
  
  
  FWIW, this should be okay since `not x` follows the order of the input subset.
  The order of the `x` doesn't matter.

REPOSITORY
  rHG Mercurial

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

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


D477: revlog: add option to mmap revlog index

2017-08-22 Thread mbthomas (Mark Thomas)
mbthomas created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Following on from Jun Wu's patch last October[1], we have found that using 
mmap
  for the revlog index in repos with large revlogs gives a noticable performance
  improvment (~150ms on each hg invocation), particularly for commands that 
don't
  touch the index very much.
  
  This changeset adds this as an option, activated by a new experimental config
  option so that it can be enabled on a per-repo basis.
  
  The default remains to be loading the full file, which seems to be the best
  option for smaller repos.  In the future we may want to make Mercurial switch
  to mmap when the size of the revlog index reaches a threshold, but we're not
  sure what that threshold should be yet.
  
  [1] 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/088737.html

TEST PLAN
  `hg log --config experimental.mmapindex=true`

REPOSITORY
  rHG Mercurial

BRANCH
  mmap-revlog (bookmark) on default (branch)

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

AFFECTED FILES
  mercurial/localrepo.py
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -19,6 +19,7 @@
 import hashlib
 import os
 import struct
+import sys
 import zlib
 
 # import stuff from node for others to import from revlog
@@ -300,6 +301,7 @@
 self._nodepos = None
 self._compengine = 'zlib'
 self._maxdeltachainspan = -1
+self._mmapindex = False
 
 v = REVLOG_DEFAULT_VERSION
 opts = getattr(opener, 'options', None)
@@ -323,6 +325,8 @@
 self._compengine = opts['compengine']
 if 'maxdeltachainspan' in opts:
 self._maxdeltachainspan = opts['maxdeltachainspan']
+if sys.version_info >= (2, 7) and 'mmapindex' in opts:
+self._mmapindex = opts['mmapindex']
 
 if self._chunkcachesize <= 0:
 raise RevlogError(_('revlog chunk cache size %r is not greater '
@@ -335,7 +339,10 @@
 self._initempty = True
 try:
 f = self.opener(self.indexfile)
-indexdata = f.read()
+if self._mmapindex:
+indexdata = util.buffer(util.mmapread(f))
+else:
+indexdata = f.read()
 f.close()
 if len(indexdata) > 0:
 v = versionformat_unpack(indexdata[:4])[0]
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -599,6 +599,8 @@
 chainspan = self.ui.configbytes('experimental', 'maxdeltachainspan', 
-1)
 if 0 <= chainspan:
 self.svfs.options['maxdeltachainspan'] = chainspan
+self.svfs.options['mmapindex'] = self.ui.configbool('experimental',
+'mmapindex')
 
 for r in self.requirements:
 if r.startswith('exp-compression-'):



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


D451: revset: remove order information from tree

2017-08-22 Thread yuja (Yuya Nishihara)
yuja added a comment.


  In https://phab.mercurial-scm.org/D451#7281, @quark wrote:
  
  > I think it's more correct if all core revsets support `defineorder` 
explicitly. The current code depends on `revset.makematcher` using ascending 
fullreposet as default to make `defineorder` implicitly functional. If the 
callsite passes an non-ascending (unordered, or descending) set to the returned 
matcher, the code would behave wrong (ex. `_flipand(1:0, _flipand(1:0, 0::1))` 
would be wrong if a descending fullreposet is passed).
  
  
  Perhaps `_flipand(1:0, _flipand(1:0, 0::1))` would return `[1, 0]` if the 
input set
  were reversed. IMHO, that's correct under the original design.
  
  > It seems to me that the reason why people can get ordering wrong is because 
of legacy APIs (`repo, subset, x`). I tried to address that by introducing 
`intersect(subset, xs, order)` and suggest `repo, x` API 
(https://phab.mercurial-scm.org/D453). If people write code using the new API, 
it's much harder to have ordering issues.
  > 
  > https://phab.mercurial-scm.org/D456 provides a good test coverage about 
core revset ordering issues. If we really want to address ordering issues of 
3rd party code, maybe we can deprecate `repo, subset, x` API and force people 
to either take `subset` and `order`, or none of them. Or require an explicit 
`supportorder` flag to be defined to mark it as order-safe.
  
  I agree new decorator API would be slightly better for trivial cases, but the 
situation
  for 3rd-party extensions would be worse. Before, `subset` was the canonical
  source of ordering. Since most revset predicates should not have their own 
order,
  they just needed to return a set in subset's order.
  
return subset.filter(...)
  
  IIUC, this will be no longer be valid. All revset predicates will have to 
take care
  of `order` flag if they need a `subset` argument, just because few predicates
  want to enforce their order. This seems not a good balance.

INLINE COMMENTS

> revset.py:55
>  
> -def getset(repo, subset, x):
> +def getset(repo, subset, x, order=anyorder):
>  if not x:

Perhaps the default `order=defineorder` would be safer
at this point.

> quark wrote in revset.py:893
> In this case, `y` is expected to completely redefine the order. So `y`'s 
> `subset`'s order does not matter.

So in your proposed design, that's true. x's order doesn't matter.

I just meant, in the original design, `x` should follow the subset's order
because `y` could have no explicit ordering (so `y` follows `x`, which follows 
`subset`.)

REPOSITORY
  rHG Mercurial

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

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


D451: revset: remove order information from tree

2017-08-22 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> yuja wrote in revset.py:55
> Perhaps the default `order=defineorder` would be safer
> at this point.

Agree `anyorder` could be a surprise. I was trying to optimize aggressively. 
Maybe `followorder` is a better default since `subset & x` is the old default.

REPOSITORY
  rHG Mercurial

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

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


[PATCH] copies: fix typo in comment

2017-08-22 Thread Gábor Stefanik
# HG changeset patch
# User Gábor Stefanik 
# Date 1503410911 -7200
#  Tue Aug 22 16:08:31 2017 +0200
# Node ID e02a08d63ad20097419f935fdd8a91c42ecd88e3
# Parent  af20468eb0a499c094dbd6e27ffcacf54cf5a8e6
copies: fix typo in comment

"will not be limited" was meant to be "will not be visited". I missed this
when writing the original graft-through-rename patch series.

diff -r af20468eb0a4 -r e02a08d63ad2 mercurial/copies.py
--- a/mercurial/copies.py   Mon Aug 21 21:35:06 2017 -0700
+++ b/mercurial/copies.py   Tue Aug 22 16:08:31 2017 +0200
@@ -635,8 +635,8 @@
 limit = the rev number to not search beyond
 data = dictionary of dictionary to store copy data. (see mergecopies)

-note: limit is only an optimization, and there is no guarantee that
-irrelevant revisions will not be limited
+note: limit is only an optimization, and provides no guarantee that
+irrelevant revisions will not be visited
 there is no easy way to make this algorithm stop in a guaranteed way
 once it "goes behind a certain revision".
 """

 This message, including its attachments, is confidential and the property of 
NNG Llc. For more information please read NNG's email policy here:
http://www.nng.com/emailpolicy/
By responding to this email you accept the email policy.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] run-tests: pre instantiate pygments objects

2017-08-22 Thread Yuya Nishihara
On Tue, 22 Aug 2017 11:29:09 +0200, mlaneuvi...@gmail.com wrote:
> # HG changeset patch
> # User Matthieu Laneuville 
> # Date 1503392400 -7200
> #  Tue Aug 22 11:00:00 2017 +0200
> # Node ID 8f0443200c166b82d42078362d6908f73c7fb58a
> # Parent  3cfc9070245fbaa8c4c010327f24d579a416370f
> run-tests: pre instantiate pygments objects

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


D451: revset: remove order information from tree

2017-08-22 Thread quark (Jun Wu)
quark added a comment.


  In https://phab.mercurial-scm.org/D451#7456, @yuja wrote:
  
  > Perhaps `_flipand(1:0, _flipand(1:0, 0::1))` would return `[1, 0]` if the 
input set
  >  were reversed. IMHO, that's correct under the original design.
  
  
  I see. The old code allows "weak define" that "define" becomes "follow". 
There is no way to tell if a revset is "strong define" or "weak define" from 
the help text. So it could be confusing sometimes.
  
list(revset.match(None, '_flipand(1:0, _flipand(1:0, 0::1))', 
order=ORDER)(repo, revset.baseset(INITSET)))
  
  | OLD CODE  | ORDER=define | ORDER=follow |
  | INITSET=[0,1] | [0,1]| [0,1]|
  | INITSET=[1,0] | [1,0]| [1,0]|
  |
  
  
  
  | NEW CODE  | ORDER=define | ORDER=follow |
  | INITSET=[0,1] | [0,1]| [0,1]|
  | INITSET=[1,0] | [0,1]| [1,0]|
  |
  
  Since `set.sort()` is lazy and optimized to a no-op. I think it's cleaner to 
migrate everything to "strong define" (for core revsets). Third party code 
needs change to follow that. If they do not need `subrepo` (ex. remotenames 
case), the new API could be easier to use.
  
  
  
  Unrelated to this series, I also think some revsets might want a 
non-ascending "define" order. For example, it seems more natural if `p1(A+B)` 
could be equivalent to `p1(A)+p1(B)`. Same applies to `p2`, `parents`, 
`children` and maybe `roots`, `heads`.

REPOSITORY
  rHG Mercurial

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

To: quark, #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 4 of 6] i18n: use saved object to get actual function information if available

2017-08-22 Thread Yuya Nishihara
On Tue, 22 Aug 2017 04:18:17 +0900, FUJIWARA Katsunori wrote:
> At Mon, 21 Aug 2017 21:46:35 +0900,
> Yuya Nishihara wrote:
> > 
> > On Wed, 16 Aug 2017 01:19:04 +0900, FUJIWARA Katsunori wrote:
> > > # HG changeset patch
> > > # User FUJIWARA Katsunori 
> > > # Date 1502792844 -32400
> > > #  Tue Aug 15 19:27:24 2017 +0900
> > > # Node ID b6dd19c795147e675b9caf58383b6cafd3f03534
> > > # Parent  1d204d17d51eb143f1ef66426cec1831cd8c93bf
> > > # Available At https://bitbucket.org/foozy/mercurial-wip
> > > #  hg pull https://bitbucket.org/foozy/mercurial-wip -r 
> > > b6dd19c79514
> > > # EXP-Topic i18n-fix-update-pot-issues
> > > i18n: use saved object to get actual function information if available
> > > 
> > > To list up available compression types instead of
> > > ".. bundlecompressionmarker" in "hg help bundlespec" output, proxy
> > > object "docobject" is used, because:
> > > 
> > > - current online help system requires that __doc__ of registered
> > >   object (maybe, function) is already well formatted in reST syntax
> > > 
> > > - bundletype() method of compressionengine classes is used to list up
> > >   available compression types, but
> > > 
> > > - __doc__ of bundletype() object (= "instancemethod") is read-only
> > 
> > Just curious. Any reason why we can't make the bundletype.__doc__ statically
> > formatted?
> 
> Would you suppose change like below ?
> 
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -3425,7 +3425,8 @@ class _zlibengine(compressionengine):
>  return 'zlib'
>  
>  def bundletype(self):
> -"""zlib compression using the DEFLATE algorithm.
> +"""``zlib``
> +zlib compression using the DEFLATE algorithm.
>  
>  All Mercurial clients should support this format. The compression
>  algorithm strikes a reasonable balance between compression ratio
> 

Yes.

> If we keep extensibility of compression algorithms, this kind of
> manual formatting causes broken help output easily, IMHO.
> 
> Though, I don't know any plan or actual implementation of compression
> type other than built-in ones :-)

I prefer keeping things simple until they actually be a problem.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 7] tests: stop using old except syntax in test-bundle2-format

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503428707 14400
#  Tue Aug 22 15:05:07 2017 -0400
# Node ID ccb38cfe8b6d7833490e9db28eda18968f27c490
# Parent  97dba357fcdb6caf5a0f9f5f074a69306a5a8950
tests: stop using old except syntax in test-bundle2-format

diff --git a/tests/test-bundle2-format.t b/tests/test-bundle2-format.t
--- a/tests/test-bundle2-format.t
+++ b/tests/test-bundle2-format.t
@@ -89,7 +89,7 @@ Create an extension to test bundle2 API
   > p = p.split('=', 1)
   > try:
   > bundler.addparam(*p)
-  > except ValueError, exc:
+  > except ValueError as exc:
   > raise error.Abort('%s' % exc)
   > 
   > if opts['compress']:
@@ -164,7 +164,7 @@ Create an extension to test bundle2 API
   > try:
   > for chunk in bundler.getchunks():
   > file.write(chunk)
-  > except RuntimeError, exc:
+  > except RuntimeError as exc:
   > raise error.Abort(exc)
   > finally:
   > file.flush()
@@ -180,9 +180,9 @@ Create an extension to test bundle2 API
   > unbundler = bundle2.getunbundler(ui, sys.stdin)
   > op = bundle2.processbundle(repo, unbundler, lambda: tr)
   > tr.close()
-  > except error.BundleValueError, exc:
+  > except error.BundleValueError as exc:
   > raise error.Abort('missing support for %s' % exc)
-  > except error.PushRaced, exc:
+  > except error.PushRaced as exc:
   > raise error.Abort('push race: %s' % exc)
   > finally:
   > if tr is not None:
@@ -206,7 +206,7 @@ Create an extension to test bundle2 API
   > unbundler = bundle2.getunbundler(ui, sys.stdin)
   > try:
   > params = unbundler.params
-  > except error.BundleValueError, exc:
+  > except error.BundleValueError as exc:
   >raise error.Abort('unknown parameters: %s' % exc)
   > ui.write('options count: %i\n' % len(params))
   > for key in sorted(params):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 7] tests: update test-archive to always use hashlib

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503428272 14400
#  Tue Aug 22 14:57:52 2017 -0400
# Node ID 97dba357fcdb6caf5a0f9f5f074a69306a5a8950
# Parent  6a9a8a60bced4b42a4b019b2f98c97672ce7a42b
tests: update test-archive to always use hashlib

We don't need the fallback to the old modules anymore.

diff --git a/tests/test-archive.t b/tests/test-archive.t
--- a/tests/test-archive.t
+++ b/tests/test-archive.t
@@ -211,15 +211,12 @@ The '-t' should override autodetection
   > done
 
   $ cat > md5comp.py < from __future__ import print_function
-  > try:
-  > from hashlib import md5
-  > except ImportError:
-  > from md5 import md5
+  > from __future__ import absolute_import, print_function
+  > import hashlib
   > import sys
   > f1, f2 = sys.argv[1:3]
-  > h1 = md5(open(f1, 'rb').read()).hexdigest()
-  > h2 = md5(open(f2, 'rb').read()).hexdigest()
+  > h1 = hashlib.md5(open(f1, 'rb').read()).hexdigest()
+  > h2 = hashlib.md5(open(f2, 'rb').read()).hexdigest()
   > print(h1 == h2 or "md5 differ: " + repr((h1, h2)))
   > EOF
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 7] undumprevlog: update to valid Python 3 syntax

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503421131 14400
#  Tue Aug 22 12:58:51 2017 -0400
# Node ID 536b3969d2242224898f574919b134df4ba190a8
# Parent  af20468eb0a499c094dbd6e27ffcacf54cf5a8e6
undumprevlog: update to valid Python 3 syntax

I didn't do anything to ensure correctness here, just enough to avoid
tracebacks in the import checker, which uses the native ast module to
try and parse all our Python files.

diff --git a/contrib/undumprevlog b/contrib/undumprevlog
--- a/contrib/undumprevlog
+++ b/contrib/undumprevlog
@@ -3,7 +3,7 @@
 # $ hg init
 # $ undumprevlog < repo.dump
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import sys
 from mercurial import (
@@ -27,7 +27,7 @@ while True:
 if l.startswith("file:"):
 f = l[6:-1]
 r = revlog.revlog(opener, f)
-print f
+print(f)
 elif l.startswith("node:"):
 n = node.bin(l[6:-1])
 elif l.startswith("linkrev:"):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 6 of 7] contrib: make import checker always think in terms of bytes

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503421108 14400
#  Tue Aug 22 12:58:28 2017 -0400
# Node ID b093ed60c94fe3f7c4edaead1b0b0a5b7b8cddda
# Parent  d31f856bd5d31a1adc377f2679da764b85700bf0
contrib: make import checker always think in terms of bytes

The doctests now do some regrettable things, but they'll always work
since we're dealing with ASCII module names etc.

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -616,22 +616,26 @@ def _cycle_sortkey(c):
 def embedded(f, modname, src):
 """Extract embedded python code
 
+>>> def _forcestr(thing):
+... if not isinstance(thing, str):
+... return thing.decode('ascii')
+... return thing
 >>> def test(fn, lines):
-... for s, m, f, l in embedded(fn, "example", lines):
-... print("%s %s %s" % (m, f, l))
-... print(repr(s))
+... for s, m, f, l in embedded(fn, b"example", lines):
+... print("%s %s %d" % (_forcestr(m), _forcestr(f), l))
+... print(repr(_forcestr(s)))
 >>> lines = [
-...   'comment',
-...   '  >>> from __future__ import print_function',
-...   "  >>> ' multiline",
-...   "  ... string'",
-...   '  ',
-...   'comment',
-...   '  $ cat > foo.py < from __future__ import print_function',
-...   '  > EOF',
+...   b'comment',
+...   b'  >>> from __future__ import print_function',
+...   b"  >>> ' multiline",
+...   b"  ... string'",
+...   b'  ',
+...   b'comment',
+...   b'  $ cat > foo.py < from __future__ import print_function',
+...   b'  > EOF',
 ... ]
->>> test("example.t", lines)
+>>> test(b"example.t", lines)
 example[2] doctest.py 2
 "from __future__ import print_function\\n' multiline\\nstring'\\n"
 example[7] foo.py 7
@@ -653,16 +657,16 @@ def embedded(f, modname, src):
 if not inlinepython:
 # We've just entered a Python block.
 inlinepython = n
-t = 'doctest.py'
+t = b'doctest.py'
 script.append(l[prefix:])
 continue
 if l.startswith(b'  ... '): # python inlines
 script.append(l[prefix:])
 continue
-cat = re.search(r"\$ \s*cat\s*>\s*(\S+\.py)\s*<<\s*EOF", l)
+cat = re.search(br"\$ \s*cat\s*>\s*(\S+\.py)\s*<<\s*EOF", l)
 if cat:
 if inlinepython:
-yield ''.join(script), ("%s[%d]" %
+yield b''.join(script), (b"%s[%d]" %
(modname, inlinepython)), t, inlinepython
 script = []
 inlinepython = 0
@@ -671,7 +675,7 @@ def embedded(f, modname, src):
 continue
 if shpython and l.startswith(b'  > '): # sh continuation
 if l == b'  > EOF\n':
-yield ''.join(script), ("%s[%d]" %
+yield b''.join(script), (b"%s[%d]" %
(modname, shpython)), t, shpython
 script = []
 shpython = 0
@@ -679,7 +683,7 @@ def embedded(f, modname, src):
 script.append(l[4:])
 continue
 if inlinepython and l == b'  \n':
-yield ''.join(script), ("%s[%d]" %
+yield b''.join(script), (b"%s[%d]" %
(modname, inlinepython)), t, inlinepython
 script = []
 inlinepython = 0
@@ -697,11 +701,11 @@ def sources(f, modname):
 """
 py = False
 if not f.endswith('.t'):
-with open(f) as src:
+with open(f, 'rb') as src:
 yield src.read(), modname, f, 0
 py = True
 if py or f.endswith('.t'):
-with open(f) as src:
+with open(f, 'rb') as src:
 for script, modname, t, line in embedded(f, modname, src):
 yield script, modname, t, line
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 7] contrib: work around some modules not existing on Py3 in import checker

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503413909 14400
#  Tue Aug 22 10:58:29 2017 -0400
# Node ID d31f856bd5d31a1adc377f2679da764b85700bf0
# Parent  ccb38cfe8b6d7833490e9db28eda18968f27c490
contrib: work around some modules not existing on Py3 in import checker

diff --git a/contrib/import-checker.py b/contrib/import-checker.py
--- a/contrib/import-checker.py
+++ b/contrib/import-checker.py
@@ -12,7 +12,10 @@ import sys
 # to work when run from a virtualenv.  The modules were chosen empirically
 # so that the return value matches the return value without virtualenv.
 if True: # disable lexical sorting checks
-import BaseHTTPServer
+try:
+import BaseHTTPServer
+except ImportError:
+BaseHTTPServer = None
 import zlib
 
 # Whitelist of modules that symbols can be directly imported from.
@@ -183,8 +186,9 @@ def populateextmods(localmods):
 def list_stdlib_modules():
 """List the modules present in the stdlib.
 
+>>> py3 = sys.version_info[0] >= 3
 >>> mods = set(list_stdlib_modules())
->>> 'BaseHTTPServer' in mods
+>>> 'BaseHTTPServer' in mods or py3
 True
 
 os.path isn't really a module, so it's missing:
@@ -201,7 +205,7 @@ def list_stdlib_modules():
 >>> 'collections' in mods
 True
 
->>> 'cStringIO' in mods
+>>> 'cStringIO' in mods or py3
 True
 
 >>> 'cffi' in mods
@@ -224,6 +228,8 @@ def list_stdlib_modules():
 # We need to supplement the list of prefixes for the search to work
 # when run from within a virtualenv.
 for mod in (BaseHTTPServer, zlib):
+if mod is None:
+continue
 try:
 # Not all module objects have a __file__ attribute.
 filename = mod.__file__
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 7 of 7] python3: whitelist test-imports-checker.t, which now passes

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503414046 14400
#  Tue Aug 22 11:00:46 2017 -0400
# Node ID 3045a38b4c069b3d3b2f306a5bd7a2be624bedaf
# Parent  b093ed60c94fe3f7c4edaead1b0b0a5b7b8cddda
python3: whitelist test-imports-checker.t, which now passes

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -20,6 +20,7 @@ test-empty-dir.t
 test-empty.t
 test-excessive-merge.t
 test-hghave.t
+test-imports-checker.t
 test-issue1089.t
 test-issue1993.t
 test-issue842.t
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 7] md5sum: assume hashlib exists now that we're 2.7 only

2017-08-22 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1503428230 14400
#  Tue Aug 22 14:57:10 2017 -0400
# Node ID 6a9a8a60bced4b42a4b019b2f98c97672ce7a42b
# Parent  536b3969d2242224898f574919b134df4ba190a8
md5sum: assume hashlib exists now that we're 2.7 only

diff --git a/tests/md5sum.py b/tests/md5sum.py
--- a/tests/md5sum.py
+++ b/tests/md5sum.py
@@ -8,17 +8,11 @@
 
 from __future__ import absolute_import
 
+import hashlib
 import os
 import sys
 
 try:
-import hashlib
-md5 = hashlib.md5
-except ImportError:
-import md5
-md5 = md5.md5
-
-try:
 import msvcrt
 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
@@ -32,7 +26,7 @@ for filename in sys.argv[1:]:
 sys.stderr.write('%s: Can\'t open: %s\n' % (filename, msg))
 sys.exit(1)
 
-m = md5()
+m = hashlib.md5()
 try:
 for data in iter(lambda: fp.read(8192), b''):
 m.update(data)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D478: run-tests: remove unused pygments token type

2017-08-22 Thread martinvonz (Martin von Zweigbergk)
martinvonz 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/D478

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -109,7 +109,6 @@
 default_style = ""
 skipped = token.string_to_tokentype("Token.Generic.Skipped")
 failed = token.string_to_tokentype("Token.Generic.Failed")
-error = token.string_to_tokentype("Token.Generic.Error")
 skippedname = token.string_to_tokentype("Token.Generic.SName")
 failedname = token.string_to_tokentype("Token.Generic.FName")
 styles = {



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


D451: revset: remove order information from tree

2017-08-22 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  I had also wanted to remove the need to pass subset, so I'd be happy so that 
change.

INLINE COMMENTS

> quark wrote in test-revset.t:2893
> This is caused by `fullreposet` having a default order. If we remove that, it 
> would be optimized to `` here.

Does that mean you'll remove the other.sort() in fullreposet.__and__?

REPOSITORY
  rHG Mercurial

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

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


[Bug 5666] New: Config Phabricator In-bound emails

2017-08-22 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5666

Bug ID: 5666
   Summary: Config Phabricator In-bound emails
   Product: Mercurial
   Version: 4.3-rc
  Hardware: All
OS: All
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: infrastructure
  Assignee: bugzi...@mercurial-scm.org
  Reporter: arcppzju+hg...@gmail.com
CC: kbullock+mercur...@ringworld.org,
mercurial-devel@mercurial-scm.org

Phabricator supports in-bound email handling so replies could become comments
on the website automatically.

See
https://secure.phabricator.com/book/phabricator/article/configuring_inbound_email/
for instructions.

-- 
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 5 of 7] contrib: work around some modules not existing on Py3 in import checker

2017-08-22 Thread Augie Fackler
This patch flunks test-check-code.t, please disregard this series in favor of a 
forthcoming v2.

> On Aug 22, 2017, at 3:08 PM, Augie Fackler  wrote:
> 
> # HG changeset patch
> # User Augie Fackler 
> # Date 1503413909 14400
> #  Tue Aug 22 10:58:29 2017 -0400
> # Node ID d31f856bd5d31a1adc377f2679da764b85700bf0
> # Parent  ccb38cfe8b6d7833490e9db28eda18968f27c490
> contrib: work around some modules not existing on Py3 in import checker
> 
> diff --git a/contrib/import-checker.py b/contrib/import-checker.py
> --- a/contrib/import-checker.py
> +++ b/contrib/import-checker.py
> @@ -12,7 +12,10 @@ import sys
> # to work when run from a virtualenv.  The modules were chosen empirically
> # so that the return value matches the return value without virtualenv.
> if True: # disable lexical sorting checks
> -import BaseHTTPServer
> +try:
> +import BaseHTTPServer
> +except ImportError:
> +BaseHTTPServer = None
> import zlib
> 
> # Whitelist of modules that symbols can be directly imported from.
> @@ -183,8 +186,9 @@ def populateextmods(localmods):
> def list_stdlib_modules():
> """List the modules present in the stdlib.
> 
> +>>> py3 = sys.version_info[0] >= 3
 mods = set(list_stdlib_modules())
> ->>> 'BaseHTTPServer' in mods
> +>>> 'BaseHTTPServer' in mods or py3
> True
> 
> os.path isn't really a module, so it's missing:
> @@ -201,7 +205,7 @@ def list_stdlib_modules():
 'collections' in mods
> True
> 
> ->>> 'cStringIO' in mods
> +>>> 'cStringIO' in mods or py3
> True
> 
 'cffi' in mods
> @@ -224,6 +228,8 @@ def list_stdlib_modules():
> # We need to supplement the list of prefixes for the search to work
> # when run from within a virtualenv.
> for mod in (BaseHTTPServer, zlib):
> +if mod is None:
> +continue
> try:
> # Not all module objects have a __file__ attribute.
> filename = mod.__file__
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



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


D451: revset: remove order information from tree

2017-08-22 Thread quark (Jun Wu)
quark added a comment.


  Interestingly, I checked some well known 3rd-party extensions:
  
  hgsubversion:
  
  - svnrev() uses "x for x in myset if x in subset" therefore enforces 
"defineorder" and wrong.
  - fromsvn() is also wrong similarly.
  
  hg-git:
  
  - fromgit(), gitnode(): happened to be "followorder" since it uses `x for x 
in subset if ...`
  
  mutable-history:
  
  - troubled(), suspended(), precursors(), ...: all of them use "subset &" , 
therefore enforces "followorder"
  
  remotenames:
  
  - remotenames(): uses "subset &" pattern
  - upstream(): uses "smartset.filteredset(subset, ...)", which could be 
changed to "subset.filter(...)"
  - pushed(): same as upstream()
  
  So there are only 2 users (upstream() and pushed()) which can benefit from 
"subset.filter(...)". All of the remaining cases could benefit from the simpler 
API and do not take the "subset" argument.

REPOSITORY
  rHG Mercurial

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

To: quark, #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: D464: Use an unambigious path suffix for the commit editor file.

2017-08-22 Thread Jun Wu
I think this patch is about changing the suffix. I guess some less powerful
editors may only support matching file types by suffixes.

Please correct me if I'm wrong, but I failed to see how the
"experimental.editortmpinhg" setting could be used as-is to change the
suffix. Therefore I think the patch is still needed.

Maybe we can change it to a config option? Like, instead of saying:

extra_defaults = {
'prefix': 'editor',
'suffix': '.txt',
}

Changing ".txt" there to be a config option (maybe
experimental.editorsuffix).

+mbolin since Phabricator inbound email does not work yet (I have filed an
infra bug at https://bz.mercurial-scm.org/5666).

Excerpts from Sean Farley's message of 2017-08-21 22:04:38 -0700:
> 
> mbolin (Michael Bolin)  writes:
> 
> > mbolin created this revision.
> > Herald added a subscriber: mercurial-devel.
> > Herald added a reviewer: hg-reviewers.
> >
> > REVISION SUMMARY
> >   Changes the path for a commit editor file from 
> > `/tmp/hg-editor-XX.txt` to
> >   `/tmp/hg-editor-XX.hgcommit.txt`.
> >   
> >   Some editors (such as Atom) make it possible to statically define a 
> > [TextMate]
> >   grammar for files with a particular suffix. For example, because Git 
> > reliably
> >   uses `.git/COMMIT_EDITMSG` and `.git/MERGE_MSG` as the paths for 
> > commit-type
> >   messages, it is trivial to define a grammar that is applied when files of
> >   either name are opened in Atom:
> >   
> >   
> > https://github.com/atom/language-git/blob/v0.19.1/grammars/git%20commit%20message.cson#L4-L5
> >   
> >   Because Hg currently uses the generic `.txt` suffix, it is much harder to
> >   disambiguate whether the file is an arbitrary text file as opposed to one
> >   created for the specific purpose of authoring an Hg commit message.
> >   
> >   It would be nice to update all of the other similar uses of temp files in 
> > Hg,
> >   but this seemed like the most impactful place to start.
> 
> This is actually why I created the `editortmpinhg' experimental setting.
> If I understand correctly, that should be enough to statically match
> `.hg/hg-editor-*.txt'. In fact, that's what I do here in my emacs
> thingy:
> 
> https://bitbucket.org/seanfarley/mahgic/src/default/lisp/hg-commit.el#hg-commit.el-348
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D464: commit: use an unambiguous path suffix for the commit editor file

2017-08-22 Thread quark (Jun Wu)
quark requested changes to this revision.
quark added a comment.


  There are some discussion in the list 
(https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-August/103382.html).
 Just mentioning it here since Phabricator In-Bound email handling is not 
configured properly.

REPOSITORY
  rHG Mercurial

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

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


D472: extensions: make wrapfunction() return a context manager

2017-08-22 Thread quark (Jun Wu)
quark added subscribers: mjpieters, quark.
quark accepted this revision.
quark added a comment.


  cc python expert @mjpieters to see if he has additional comments. But I think 
this is good enough.

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 7 of 7 v2] python3: whitelist test-imports-checker.t, which now passes

2017-08-22 Thread Pulkit Goyal
This series looks good to me. :)

On Wed, Aug 23, 2017 at 2:57 AM, Augie Fackler  wrote:
> # HG changeset patch
> # User Augie Fackler 
> # Date 1503414046 14400
> #  Tue Aug 22 11:00:46 2017 -0400
> # Node ID 2959ea035b9d1ddfe41dc48c2893a9ebd6c2f160
> # Parent  fb3748bd846a240924cbf6172162dbe6851514e5
> python3: whitelist test-imports-checker.t, which now passes
>
> diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
> --- a/contrib/python3-whitelist
> +++ b/contrib/python3-whitelist
> @@ -20,6 +20,7 @@ test-empty-dir.t
>  test-empty.t
>  test-excessive-merge.t
>  test-hghave.t
> +test-imports-checker.t
>  test-issue1089.t
>  test-issue1993.t
>  test-issue842.t
> ___
> 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] run-tests: pre instantiate pygments objects

2017-08-22 Thread mlaneuville
# HG changeset patch
# User Matthieu Laneuville 
# Date 1503392400 -7200
#  Tue Aug 22 11:00:00 2017 +0200
# Node ID 8f0443200c166b82d42078362d6908f73c7fb58a
# Parent  3cfc9070245fbaa8c4c010327f24d579a416370f
run-tests: pre instantiate pygments objects

Pre instantiate pygments objects to minimize overhead (cf. 20436925e080)

diff -r 3cfc9070245f -r 8f0443200c16 tests/run-tests.py
--- a/tests/run-tests.pyWed Aug 16 10:44:06 2017 -0700
+++ b/tests/run-tests.pyTue Aug 22 11:00:00 2017 +0200
@@ -136,6 +136,9 @@
 ]
 }
 
+runnerformatter = formatters.Terminal256Formatter(style=TestRunnerStyle)
+runnerlexer = TestRunnerLexer()
+
 if sys.version_info > (3, 5, 0):
 PYTHON3 = True
 xrange = range # we use xrange in one place, and we'd rather not use range
@@ -1637,9 +1640,8 @@
 if self.color:
 formatted = pygments.highlight(
 formatted,
-TestRunnerLexer(),
-formatters.Terminal256Formatter(
-style=TestRunnerStyle))
+runnerlexer,
+runnerformatter)
 self.stream.write(formatted)
 self.stream.write('!')
 
@@ -2046,18 +2048,16 @@
 if result.color:
 formatted = pygments.highlight(
 formatted,
-TestRunnerLexer(),
-formatters.Terminal256Formatter(
-style=TestRunnerStyle)).strip("\n")
+runnerlexer,
+runnerformatter).strip("\n")
 self.stream.writeln(formatted)
 for test, msg in result.failures:
 formatted = 'Failed %s: %s' % (test.name, msg)
 if result.color:
 formatted = pygments.highlight(
 formatted,
-TestRunnerLexer(),
-formatters.Terminal256Formatter(
-style=TestRunnerStyle)).strip("\n")
+runnerlexer,
+runnerformatter).strip("\n")
 self.stream.writeln(formatted)
 for test, msg in result.errors:
 self.stream.writeln('Errored %s: %s' % (test.name, msg))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D464: commit: use an unambiguous path suffix for the commit editor file

2017-08-22 Thread ryanmce (Ryan McElroy)
ryanmce requested changes to this revision.
ryanmce added a comment.
This revision now requires changes to proceed.


  But you should include a test to prevent regressions.

REPOSITORY
  rHG Mercurial

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

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


D464: commit: use an unambiguous path suffix for the commit editor file

2017-08-22 Thread ryanmce (Ryan McElroy)
ryanmce accepted this revision.
ryanmce added a comment.


  Should be safe and effective.

REPOSITORY
  rHG Mercurial

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

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


D472: extensions: make wrapfunction() return a context manager

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

REVISION SUMMARY
  Several extensions exist that temporarily want to wrap a function (at
  least narrowhg, any many of the extensions in hg-experimental). That's
  why we have the unwrapfunction() that was introduced in 
https://phab.mercurial-scm.org/rHG19578bb847310e32eae3d44466b51a698ced5b95
  (extensions: add unwrapfunction to undo wrapfunction, 2016-08-10).
  
  This patch makes wrapfunction() return a context manager. Since
  wrapfunction() returned the original function before this patch, we
  will be changing the return type. In order to limit breakages for
  callers that kept the reference to the unbound method around and then
  set it back on the container after it was done, this patch also
  implements a __get__ method that binds the original method to the
  container instance.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/extensions.py
  tests/test-extensions-wrapfunction.py
  tests/test-extensions-wrapfunction.py.out
  tests/test-filecache.py

CHANGE DETAILS

diff --git a/tests/test-filecache.py b/tests/test-filecache.py
--- a/tests/test-filecache.py
+++ b/tests/test-filecache.py
@@ -129,20 +129,16 @@
 def wrapinit(orig, *args, **kwargs):
 pass
 
-originit = extensions.wrapfunction(util.cachestat, '__init__', wrapinit)
-origcacheable = extensions.wrapfunction(util.cachestat, 'cacheable',
-wrapcacheable)
+with extensions.wrapfunction(util.cachestat, '__init__', wrapinit),\
+ extensions.wrapfunction(util.cachestat, 'cacheable', wrapcacheable):
 
-for fn in ['x', 'y']:
-try:
-os.remove(fn)
-except OSError:
-pass
+for fn in ['x', 'y']:
+try:
+os.remove(fn)
+except OSError:
+pass
 
-basic(fakerepo())
-
-util.cachestat.cacheable = origcacheable
-util.cachestat.__init__ = originit
+basic(fakerepo())
 
 def test_filecache_synced():
 # test old behavior that caused filecached properties to go out of sync
diff --git a/tests/test-extensions-wrapfunction.py.out 
b/tests/test-extensions-wrapfunction.py.out
--- a/tests/test-extensions-wrapfunction.py.out
+++ b/tests/test-extensions-wrapfunction.py.out
@@ -12,3 +12,8 @@
 unwrap 2: 2: [1, 'orig']
 unwrap 1: 1: ['orig']
 unwrap -: -: IndexError
+context manager ['orig']
+context manager [0, 'orig']
+context manager [1, 0, 'orig']
+context manager [0, 'orig']
+context manager ['orig']
diff --git a/tests/test-extensions-wrapfunction.py 
b/tests/test-extensions-wrapfunction.py
--- a/tests/test-extensions-wrapfunction.py
+++ b/tests/test-extensions-wrapfunction.py
@@ -37,3 +37,11 @@
 batchwrap(wrappers + [wrappers[0]])
 batchunwrap([(wrappers[i] if i >= 0 else None)
  for i in [3, None, 0, 4, 0, 2, 1, None]])
+
+print('context manager', dummy.getstack())
+with extensions.wrapfunction(dummy, 'getstack', wrappers[0]):
+print('context manager', dummy.getstack())
+with extensions.wrapfunction(dummy, 'getstack', wrappers[1]):
+print('context manager', dummy.getstack())
+print('context manager', dummy.getstack())
+print('context manager', dummy.getstack())
diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -399,6 +399,34 @@
 raise AttributeError(r"type '%s' has no property '%s'" % (
 cls, propname))
 
+class _wrappedfunction(object):
+'''context manager for temporarily wrapping a function'''
+
+def __init__(self, container, funcname, wrapper):
+assert callable(wrapper)
+
+origfn = getattr(container, funcname)
+assert callable(origfn)
+wrap = bind(wrapper, origfn)
+_updatewrapper(wrap, origfn, wrapper)
+setattr(container, funcname, wrap)
+
+self._container = container
+self._funcname = funcname
+self._origfn = origfn
+
+def __enter__(self):
+return self
+
+def __exit__(self, exctype, excvalue, traceback):
+unwrapfunction(self._container, self._funcname)
+
+def __get__(self, instance, owner):
+util.nouideprecwarn("Using the return value of wrapfunction() as a "
+"function is deprecated. Use it as context manager 
"
+"instead","4.4", stacklevel=2)
+return bind(self._origfn, instance)
+
 def wrapfunction(container, funcname, wrapper):
 '''Wrap the function named funcname in container
 
@@ -432,14 +460,7 @@
 your end users, you should play nicely with others by using the
 subclass trick.
 '''
-assert callable(wrapper)
-
-origfn = getattr(container, funcname)
-assert callable(origfn)
-wrap = bind(wrapper, origfn)
-_updatewrapper(wrap, origfn, wrapper)
-   

mercurial@33862: 2 new changesets (2 on stable)

2017-08-22 Thread Mercurial Commits
2 new changesets (2 on stable) in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/0e15d5ae52cf
changeset:   33861:0e15d5ae52cf
branch:  stable
parent:  33755:cde4cfeb6e3e
user:Martin von Zweigbergk 
date:Fri Aug 18 12:50:26 2017 -0700
summary: tests: use graph log in {latesttag} tests

https://www.mercurial-scm.org/repo/hg/rev/fb672eac2702
changeset:   33862:fb672eac2702
branch:  stable
tag: tip
user:Martin von Zweigbergk 
date:Tue Aug 15 23:23:55 2017 -0700
summary: templatekw: choose {latesttag} by len(changes), not date 
(issue5659)

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


mercurial@33865: 3 new changesets

2017-08-22 Thread Mercurial Commits
3 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/3160876c6e4e
changeset:   33863:3160876c6e4e
parent:  33860:3cfc9070245f
user:Jun Wu 
date:Thu Aug 10 22:17:15 2017 -0700
summary: rebase: choose merge base without unwanted revisions

https://www.mercurial-scm.org/repo/hg/rev/70354bd4f19b
changeset:   33864:70354bd4f19b
user:Jun Wu 
date:Fri Aug 11 01:34:11 2017 -0700
summary: rebase: only change self.state when collapsing in _finishrebase

https://www.mercurial-scm.org/repo/hg/rev/af20468eb0a4
changeset:   33865:af20468eb0a4
bookmark:@
tag: tip
parent:  33864:70354bd4f19b
parent:  33862:fb672eac2702
user:Sean Farley 
date:Mon Aug 21 21:35:06 2017 -0700
summary: merge with stable

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