[PATCH 2 of 2] fsmonitor: refresh pywatchman to upstream

2016-12-21 Thread Zack Hricz via Mercurial-devel
# HG changeset patch
# User zphricz 
# Date 1482294935 28800
#  Tue Dec 20 20:35:35 2016 -0800
# Node ID 969b5a85908b45e7d2ca0187bba4aa453ce04731
# Parent  445efa4de2742e3ba964bdabcce86897e53f0423
fsmonitor: refresh pywatchman to upstream

Update to upstream to version c77452 with additional fixes to tests.
The refresh includes fixes to improve windows compatibility.

diff --git a/hgext/fsmonitor/pywatchman/__init__.py 
b/hgext/fsmonitor/pywatchman/__init__.py
--- a/hgext/fsmonitor/pywatchman/__init__.py
+++ b/hgext/fsmonitor/pywatchman/__init__.py
@@ -26,9 +26,14 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+# no unicode literals
+
+import inspect
+import math
 import os
-import errno
-import math
 import socket
 import subprocess
 import time
@@ -36,11 +41,20 @@
 # Sometimes it's really hard to get Python extensions to compile,
 # so fall back to a pure Python implementation.
 try:
-import bser
+from . import bser
+# Demandimport causes modules to be loaded lazily. Force the load now
+# so that we can fall back on pybser if bser doesn't exist
+bser.pdu_info
 except ImportError:
-import pybser as bser
+from . import pybser as bser
 
-import capabilities
+from . import (
+capabilities,
+compat,
+encoding,
+load,
+)
+
 
 if os.name == 'nt':
 import ctypes
@@ -55,18 +69,29 @@
 FORMAT_MESSAGE_FROM_SYSTEM = 0x1000
 FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x0100
 FORMAT_MESSAGE_IGNORE_INSERTS = 0x0200
+WAIT_FAILED = 0x
 WAIT_TIMEOUT = 0x0102
 WAIT_OBJECT_0 = 0x
-ERROR_IO_PENDING = 997
+WAIT_IO_COMPLETION = 0x00C0
+INFINITE = 0x
+
+# Overlapped I/O operation is in progress. (997)
+ERROR_IO_PENDING = 0x03E5
+
+# The pointer size follows the architecture
+# We use WPARAM since this type is already conditionally defined
+ULONG_PTR = ctypes.wintypes.WPARAM
 
 class OVERLAPPED(ctypes.Structure):
 _fields_ = [
-("Internal", wintypes.ULONG), ("InternalHigh", wintypes.ULONG),
+("Internal", ULONG_PTR), ("InternalHigh", ULONG_PTR),
 ("Offset", wintypes.DWORD), ("OffsetHigh", wintypes.DWORD),
 ("hEvent", wintypes.HANDLE)
 ]
 
 def __init__(self):
+self.Internal = 0
+self.InternalHigh = 0
 self.Offset = 0
 self.OffsetHigh = 0
 self.hEvent = 0
@@ -97,6 +122,10 @@
 GetLastError.argtypes = []
 GetLastError.restype = wintypes.DWORD
 
+SetLastError = ctypes.windll.kernel32.SetLastError
+SetLastError.argtypes = [wintypes.DWORD]
+SetLastError.restype = None
+
 FormatMessage = ctypes.windll.kernel32.FormatMessageA
 FormatMessage.argtypes = [wintypes.DWORD, wintypes.LPVOID, wintypes.DWORD,
   wintypes.DWORD, ctypes.POINTER(wintypes.LPSTR),
@@ -105,12 +134,30 @@
 
 LocalFree = ctypes.windll.kernel32.LocalFree
 
-GetOverlappedResultEx = ctypes.windll.kernel32.GetOverlappedResultEx
-GetOverlappedResultEx.argtypes = [wintypes.HANDLE,
-  ctypes.POINTER(OVERLAPPED), LPDWORD,
-  wintypes.DWORD, wintypes.BOOL]
-GetOverlappedResultEx.restype = wintypes.BOOL
+GetOverlappedResult = ctypes.windll.kernel32.GetOverlappedResult
+GetOverlappedResult.argtypes = [wintypes.HANDLE,
+ctypes.POINTER(OVERLAPPED), LPDWORD,
+wintypes.BOOL]
+GetOverlappedResult.restype = wintypes.BOOL
 
+GetOverlappedResultEx = getattr(ctypes.windll.kernel32,
+'GetOverlappedResultEx', None)
+if GetOverlappedResultEx is not None:
+GetOverlappedResultEx.argtypes = [wintypes.HANDLE,
+  ctypes.POINTER(OVERLAPPED), LPDWORD,
+  wintypes.DWORD, wintypes.BOOL]
+GetOverlappedResultEx.restype = wintypes.BOOL
+
+WaitForSingleObjectEx = ctypes.windll.kernel32.WaitForSingleObjectEx
+WaitForSingleObjectEx.argtypes = [wintypes.HANDLE, wintypes.DWORD, 
wintypes.BOOL]
+WaitForSingleObjectEx.restype = wintypes.DWORD
+
+CreateEvent = ctypes.windll.kernel32.CreateEventA
+CreateEvent.argtypes = [LPDWORD, wintypes.BOOL, wintypes.BOOL,
+wintypes.LPSTR]
+CreateEvent.restype = wintypes.HANDLE
+
+# Windows Vista is the minimum supported client for CancelIoEx.
 CancelIoEx = ctypes.windll.kernel32.CancelIoEx
 CancelIoEx.argtypes = [wintypes.HANDLE, ctypes.POINTER(OVERLAPPED)]
 CancelIoEx.restype = wintypes.BOOL
@@ -132,8 +179,47 @@
 pass
 
 

[PATCH 1 of 2 v2] fsmonitor: fix exception message scraping

2016-12-21 Thread Zack Hricz via Mercurial-devel
# HG changeset patch
# User zphricz 
# Date 1482357094 28800
#  Wed Dec 21 13:51:34 2016 -0800
# Node ID a3d289ca22c1066bc929bb519b655fce9fd39bbe
# Parent  2bb8c53be961f41026ce99e1227ff2e530fbe425
fsmonitor: fix exception message scraping

pywatchman.CommandError formats its error message such that
'unable to resolve root' is not a prefix. This change fixes that by
instead just searching for it as a substring.

diff --git a/hgext/fsmonitor/watchmanclient.py 
b/hgext/fsmonitor/watchmanclient.py
--- a/hgext/fsmonitor/watchmanclient.py
+++ b/hgext/fsmonitor/watchmanclient.py
@@ -87,7 +87,7 @@
 useImmutableBser=True)
 return self._watchmanclient.query(*watchmanargs)
 except pywatchman.CommandError as ex:
-if ex.msg.startswith('unable to resolve root'):
+if 'unable to resolve root' in ex.msg:
 raise WatchmanNoRoot(self._root, ex.msg)
 raise Unavailable(ex.msg)
 except pywatchman.WatchmanError as ex:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Future of copy metadata

2016-12-21 Thread Marcin Kasperski

> Coupled with the design of having copy metadata in the filelog data
> (which is part of the hash and the merkle tree contributing to the
> changeset node), this means that if copy metadata isn't correct from
> the beginning, it is wrong forever.  That's a pretty painful
> constraint.
> (…)
> move copy/rename detection/metadata out of filelogs. I vaguely recall
> him suggesting it be computed at run-time and cached if performance
> dictates.

Why not stack both?

I like to know that whenever I do "hg mv", Mercurial is going to
remember the fact, even if I make some edits of the file before commiting.

But the fact, that Mercurial remembers, doesn't exclude possibility of
extending this information with dynamical detection at runtime.

I'd say this looks like interesting idea for extension (augment hg log
--follow, or maybe start from sth like hg log --follow-detect – and make
it consider not only statically remembered copies, but also those
dynamically detected). If it works, it may become default behaviour,
but it would be nice, if there were some way to dig whether someone
intentionally moved/copied the file.


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


[PATCH 1 of 2] fsmonitor: fix exception message scraping

2016-12-21 Thread Zack Hricz via Mercurial-devel
# HG changeset patch
# User zphricz 
# Date 1482295130 28800
#  Tue Dec 20 20:38:50 2016 -0800
# Node ID 445efa4de2742e3ba964bdabcce86897e53f0423
# Parent  6f9fcd29e29016587a5a7ac3157baec3eb39a134
fsmonitor: fix exception message scraping

pywatchman.CommandError formats its error message such that
'unable to resolve root' is not a prefix. This change fixes that by
instead just searching for it as a substring.

diff --git a/hgext/fsmonitor/watchmanclient.py 
b/hgext/fsmonitor/watchmanclient.py
--- a/hgext/fsmonitor/watchmanclient.py
+++ b/hgext/fsmonitor/watchmanclient.py
@@ -87,7 +87,7 @@
 useImmutableBser=True)
 return self._watchmanclient.query(*watchmanargs)
 except pywatchman.CommandError as ex:
-if ex.msg.startswith('unable to resolve root'):
+if 'unable to resolve root' in ex.msg:
 raise WatchmanNoRoot(self._root, ex.msg)
 raise Unavailable(ex.msg)
 except pywatchman.WatchmanError as ex:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2 v2] fsmonitor: refresh pywatchman to upstream

2016-12-21 Thread Zack Hricz via Mercurial-devel
# HG changeset patch
# User zphricz 
# Date 1482357422 28800
#  Wed Dec 21 13:57:02 2016 -0800
# Node ID 2176ee51fcde4fda4782f6835d987ae9a6d6a3f0
# Parent  a3d289ca22c1066bc929bb519b655fce9fd39bbe
fsmonitor: refresh pywatchman to upstream

Update to upstream to version c77452 with additional fixes to tests.
The refresh includes fixes to improve windows compatibility.
# no-check-commit

diff --git a/hgext/fsmonitor/pywatchman/__init__.py 
b/hgext/fsmonitor/pywatchman/__init__.py
--- a/hgext/fsmonitor/pywatchman/__init__.py
+++ b/hgext/fsmonitor/pywatchman/__init__.py
@@ -26,9 +26,14 @@
 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+# no unicode literals
+
+import inspect
+import math
 import os
-import errno
-import math
 import socket
 import subprocess
 import time
@@ -36,11 +41,20 @@
 # Sometimes it's really hard to get Python extensions to compile,
 # so fall back to a pure Python implementation.
 try:
-import bser
+from . import bser
+# Demandimport causes modules to be loaded lazily. Force the load now
+# so that we can fall back on pybser if bser doesn't exist
+bser.pdu_info
 except ImportError:
-import pybser as bser
+from . import pybser as bser
 
-import capabilities
+from . import (
+capabilities,
+compat,
+encoding,
+load,
+)
+
 
 if os.name == 'nt':
 import ctypes
@@ -55,18 +69,29 @@
 FORMAT_MESSAGE_FROM_SYSTEM = 0x1000
 FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x0100
 FORMAT_MESSAGE_IGNORE_INSERTS = 0x0200
+WAIT_FAILED = 0x
 WAIT_TIMEOUT = 0x0102
 WAIT_OBJECT_0 = 0x
-ERROR_IO_PENDING = 997
+WAIT_IO_COMPLETION = 0x00C0
+INFINITE = 0x
+
+# Overlapped I/O operation is in progress. (997)
+ERROR_IO_PENDING = 0x03E5
+
+# The pointer size follows the architecture
+# We use WPARAM since this type is already conditionally defined
+ULONG_PTR = ctypes.wintypes.WPARAM
 
 class OVERLAPPED(ctypes.Structure):
 _fields_ = [
-("Internal", wintypes.ULONG), ("InternalHigh", wintypes.ULONG),
+("Internal", ULONG_PTR), ("InternalHigh", ULONG_PTR),
 ("Offset", wintypes.DWORD), ("OffsetHigh", wintypes.DWORD),
 ("hEvent", wintypes.HANDLE)
 ]
 
 def __init__(self):
+self.Internal = 0
+self.InternalHigh = 0
 self.Offset = 0
 self.OffsetHigh = 0
 self.hEvent = 0
@@ -97,6 +122,10 @@
 GetLastError.argtypes = []
 GetLastError.restype = wintypes.DWORD
 
+SetLastError = ctypes.windll.kernel32.SetLastError
+SetLastError.argtypes = [wintypes.DWORD]
+SetLastError.restype = None
+
 FormatMessage = ctypes.windll.kernel32.FormatMessageA
 FormatMessage.argtypes = [wintypes.DWORD, wintypes.LPVOID, wintypes.DWORD,
   wintypes.DWORD, ctypes.POINTER(wintypes.LPSTR),
@@ -105,12 +134,30 @@
 
 LocalFree = ctypes.windll.kernel32.LocalFree
 
-GetOverlappedResultEx = ctypes.windll.kernel32.GetOverlappedResultEx
-GetOverlappedResultEx.argtypes = [wintypes.HANDLE,
-  ctypes.POINTER(OVERLAPPED), LPDWORD,
-  wintypes.DWORD, wintypes.BOOL]
-GetOverlappedResultEx.restype = wintypes.BOOL
+GetOverlappedResult = ctypes.windll.kernel32.GetOverlappedResult
+GetOverlappedResult.argtypes = [wintypes.HANDLE,
+ctypes.POINTER(OVERLAPPED), LPDWORD,
+wintypes.BOOL]
+GetOverlappedResult.restype = wintypes.BOOL
 
+GetOverlappedResultEx = getattr(ctypes.windll.kernel32,
+'GetOverlappedResultEx', None)
+if GetOverlappedResultEx is not None:
+GetOverlappedResultEx.argtypes = [wintypes.HANDLE,
+  ctypes.POINTER(OVERLAPPED), LPDWORD,
+  wintypes.DWORD, wintypes.BOOL]
+GetOverlappedResultEx.restype = wintypes.BOOL
+
+WaitForSingleObjectEx = ctypes.windll.kernel32.WaitForSingleObjectEx
+WaitForSingleObjectEx.argtypes = [wintypes.HANDLE, wintypes.DWORD, 
wintypes.BOOL]
+WaitForSingleObjectEx.restype = wintypes.DWORD
+
+CreateEvent = ctypes.windll.kernel32.CreateEventA
+CreateEvent.argtypes = [LPDWORD, wintypes.BOOL, wintypes.BOOL,
+wintypes.LPSTR]
+CreateEvent.restype = wintypes.HANDLE
+
+# Windows Vista is the minimum supported client for CancelIoEx.
 CancelIoEx = ctypes.windll.kernel32.CancelIoEx
 CancelIoEx.argtypes = [wintypes.HANDLE, ctypes.POINTER(OVERLAPPED)]
 CancelIoEx.restype = wintypes.BOOL
@@ -132,8 +179,47 @@
  

RE: [PATCH RFC] check-commit: add magic string to bypass check-commit

2016-12-21 Thread David Soria Parra via Mercurial-devel
> On 12/21/2016 10:47 PM, David Soria Parra wrote:
> >
> >
> >> -Original Message-
> >> From: Pierre-Yves David [mailto:pierre-yves.da...@ens-lyon.org]
> >>
> >> I would prefer to have that exclusion logic in 'test-check-commit.t',
> >> These commit still fails our commit checks, but we skip them from
> >> automated testing.
> >>
> >> Just add "and not desc('#no-check-commit')" to the revset there
> >
> > Seems reasonable, note however it changes the behavior as `# no-check-
> commit`
> > can appear anywhere when using `desc()` while my implementation
> searches for it
> > at the starting of a line.
> 
> The regex to feed 'desc()' with in order to mark start of line only is
> left as an exercise with the reader ;-)

Please read the code before making bold statements:

From hg help revsets
"desc(string)"
  Search commit message for string. The match is case-insensitive.

Note "string" not pattern. If we look into the implementation:

  @predicate('desc(string)', safe=True)
  def desc(repo, subset, x):
  # ...
  def matches(x):
  c = repo[x]
  return ds in encoding.lower(c.description())

note `ds in encoding.lower(c.description())`. Maybe my Python is not as strong 
as yours but last time
I checked this does not support regex unless I am mistaken.

I leave it to the reviewer to decide if we are taking the v1 with proper regex 
matching on multiline or settle
with desc() which does not support patterns.

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


Re: [PATCH RFC] check-commit: add magic string to bypass check-commit

2016-12-21 Thread Pierre-Yves David



On 12/21/2016 10:47 PM, David Soria Parra wrote:




-Original Message-
From: Pierre-Yves David [mailto:pierre-yves.da...@ens-lyon.org]

I would prefer to have that exclusion logic in 'test-check-commit.t',
These commit still fails our commit checks, but we skip them from
automated testing.

Just add "and not desc('#no-check-commit')" to the revset there


Seems reasonable, note however it changes the behavior as `# no-check-commit`
can appear anywhere when using `desc()` while my implementation searches for it
at the starting of a line.


The regex to feed 'desc()' with in order to mark start of line only is 
left as an exercise with the reader ;-)


Cheers,

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


Re: [PATCH V6] py3: make keys of keyword arguments strings

2016-12-21 Thread Pulkit Goyal
> Also after this patch, `hg version` now runs on Python 3.5. Hurray!

I just realised that this may not run for other people who have set up
some aliases in hgrc or have a different hgrc than me. So still we are
not able to run `hg version` on Python 3, but we will soon.
>
> diff -r 95b076f5ddee -r 3728b3d6924f mercurial/dispatch.py
> --- a/mercurial/dispatch.py Mon Nov 28 05:45:22 2016 +
> +++ b/mercurial/dispatch.py Tue Dec 13 20:53:40 2016 +0530
> @@ -803,7 +803,8 @@
>
>  msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
>  ui.log("command", '%s\n', msg)
> -d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
> +strcmdopt = pycompat.strkwargs(cmdoptions)
> +d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
>  try:
>  return runcommand(lui, repo, cmd, fullargs, ui, options, d,
>cmdpats, cmdoptions)
> diff -r 95b076f5ddee -r 3728b3d6924f tests/test-check-py3-commands.t
> --- a/tests/test-check-py3-commands.t   Mon Nov 28 05:45:22 2016 +
> +++ b/tests/test-check-py3-commands.t   Tue Dec 13 20:53:40 2016 +0530
> @@ -9,6 +9,6 @@
>>   $PYTHON3 `which hg` $cmd 2>&1 2>&1 | tail -1
>> done
>version
> -  TypeError: Can't convert 'bytes' object to str implicitly
> +  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>debuginstall
>TypeError: Can't convert 'bytes' object to str implicitly
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 7] py3: add warnings in check-code related to py3

2016-12-21 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482340351 -19800
#  Wed Dec 21 22:42:31 2016 +0530
# Node ID e8996b8c2c391ba6594cbeebe0a9e9a268f1ba2b
# Parent  64800628e1ffbe3d99535c2a8b4d0bc48c822a20
py3: add warnings in check-code related to py3

We have our own bytes versions of things like, getopt.getopt, os.sep, os.name,
sys.executable, os.environ and few more for python 3 portability. Its better
to come up with warnings if someone breaks the things which we have fixed.

After this patch, check-code will warn us to use our bytes version.
These checks run on mercurial/ and hgext/ and pycompat.py is excluded.

diff -r 64800628e1ff -r e8996b8c2c39 contrib/check-code.py
--- a/contrib/check-code.py Mon Dec 19 02:54:49 2016 +0530
+++ b/contrib/check-code.py Wed Dec 21 22:42:31 2016 +0530
@@ -456,8 +456,26 @@
   [],
 ]
 
+py3pats = [
+  [
+(r'os\.environ', "use encoding.environ instead (py3)"),
+(r'os\.name', "use pycompat.osname instead (py3)"),
+(r'os\.getcwd', "use pycompat.getcwd instead (py3)"),
+(r'os\.sep', "use pycompat.ossep instead (py3)"),
+(r'os\.pathsep', "use pycompat.ospathsep instead (py3)"),
+(r'os\.altsep', "use pycompat.osaltsep instead (py3)"),
+(r'os\.getenv', "use pycompat.osgetenv instead (py3)"),
+(r'sys\.platform', "use pycompat.sysplatform instead (py3)"),
+(r'getopt\.getopt', "use pycompat.getoptb instead (py3)"),
+  ],
+  # warnings
+  [],
+]
+
 checks = [
 ('python', r'.*\.(py|cgi)$', r'^#!.*python', pyfilters, pypats),
+('python 3', r'.*(hgext|mercurial).*(? sed 's-\\-/-g' | xargs "$check_code" --warnings --per-file=0 || false
+  hgext/fsmonitor/__init__.py:295:
+   > switch_slashes = os.sep == '\\'
+   use pycompat.ossep instead (py3)
+  hgext/fsmonitor/__init__.py:395:
+   > if 'FSMONITOR_LOG_FILE' in os.environ:
+   use encoding.environ instead (py3)
+  hgext/fsmonitor/__init__.py:396:
+   > fn = os.environ['FSMONITOR_LOG_FILE']
+   use encoding.environ instead (py3)
+  hgext/fsmonitor/__init__.py:437:
+   >'HG_PENDING' not in os.environ)
+   use encoding.environ instead (py3)
+  hgext/fsmonitor/__init__.py:548:
+   > if sys.platform == 'darwin':
+   use pycompat.sysplatform instead (py3)
   Skipping i18n/polib.py it has no-che?k-code (glob)
+  mercurial/demandimport.py:309:
+   > if os.environ.get('HGDEMANDIMPORT') != 'disable':
+   use encoding.environ instead (py3)
+  mercurial/encoding.py:54:
+   > environ = os.environ
+   use encoding.environ instead (py3)
+  mercurial/encoding.py:56:
+   > environ = os.environb
+   use encoding.environ instead (py3)
+  mercurial/encoding.py:61:
+   >for k, v in os.environ.items())
+   use encoding.environ instead (py3)
+  mercurial/encoding.py:203:
+   >for k, v in os.environ.items())
+   use encoding.environ instead (py3)
   Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
   Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
+  mercurial/policy.py:45:
+   > policy = os.environ.get('HGMODULEPOLICY', policy)
+   use encoding.environ instead (py3)
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
+  mercurial/win32.py:443:
+   > env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))
+   use pycompat.getcwd instead (py3)
+  [1]
 
 @commands in debugcommands.py should be in alphabetical order.
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 7 of 7] py3: replace sys.executable with pycompat.sysexecutable

2016-12-21 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482173407 -19800
#  Tue Dec 20 00:20:07 2016 +0530
# Node ID 681d2b64c89648c395c2af97062c94d1238c510d
# Parent  11739d0ee458863d90e44c258b9773ca2e0a605a
py3: replace sys.executable with pycompat.sysexecutable

sys.executable returns unicodes on Python 3. This patch replaces occurences of
sys.executable with pycompat.sysexecutable.

diff -r 11739d0ee458 -r 681d2b64c896 mercurial/chgserver.py
--- a/mercurial/chgserver.pyTue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/chgserver.pyTue Dec 20 00:20:07 2016 +0530
@@ -47,7 +47,6 @@
 import re
 import signal
 import struct
-import sys
 import time
 
 from .i18n import _
@@ -59,6 +58,7 @@
 error,
 extensions,
 osutil,
+pycompat,
 util,
 )
 
@@ -122,7 +122,7 @@
 modules.append(__version__)
 except ImportError:
 pass
-files = [sys.executable]
+files = [pycompat.sysexecutable]
 for m in modules:
 try:
 files.append(inspect.getabsfile(m))
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/commands.py
--- a/mercurial/commands.py Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/commands.py Tue Dec 20 00:20:07 2016 +0530
@@ -1889,7 +1889,7 @@
 
 # Python
 fm.write('pythonexe', _("checking Python executable (%s)\n"),
- sys.executable)
+ pycompat.sysexecutable)
 fm.write('pythonver', _("checking Python version (%s)\n"),
  ("%d.%d.%d" % sys.version_info[:3]))
 fm.write('pythonlib', _("checking Python lib (%s)...\n"),
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/i18n.py
--- a/mercurial/i18n.py Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/i18n.py Tue Dec 20 00:20:07 2016 +0530
@@ -19,7 +19,7 @@
 
 # modelled after templater.templatepath:
 if getattr(sys, 'frozen', None) is not None:
-module = sys.executable
+module = pycompat.sysexecutable
 else:
 module = __file__
 
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/sslutil.py
--- a/mercurial/sslutil.py  Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/sslutil.py  Tue Dec 20 00:20:07 2016 +0530
@@ -669,9 +669,9 @@
   cacerts file
 """
 if (pycompat.sysplatform != 'darwin' or
-util.mainfrozen() or not sys.executable):
+util.mainfrozen() or not pycompat.sysexecutable):
 return False
-exe = os.path.realpath(sys.executable).lower()
+exe = os.path.realpath(pycompat.sysexecutable).lower()
 return (exe.startswith('/usr/bin/python') or
 exe.startswith('/system/library/frameworks/python.framework/'))
 
diff -r 11739d0ee458 -r 681d2b64c896 mercurial/util.py
--- a/mercurial/util.py Tue Dec 20 00:02:24 2016 +0530
+++ b/mercurial/util.py Tue Dec 20 00:20:07 2016 +0530
@@ -931,7 +931,7 @@
 # the location of data files matching the source code
 if mainfrozen() and getattr(sys, 'frozen', None) != 'macosx_app':
 # executable version (py2exe) doesn't support __file__
-datapath = os.path.dirname(sys.executable)
+datapath = os.path.dirname(pycompat.sysexecutable)
 else:
 datapath = os.path.dirname(__file__)
 
@@ -957,7 +957,7 @@
 # Env variable set by py2app
 _sethgexecutable(encoding.environ['EXECUTABLEPATH'])
 else:
-_sethgexecutable(sys.executable)
+_sethgexecutable(pycompat.sysexecutable)
 elif os.path.basename(getattr(mainmod, '__file__', '')) == 'hg':
 _sethgexecutable(mainmod.__file__)
 else:
@@ -2299,7 +2299,7 @@
 # Env variable set by py2app
 return [encoding.environ['EXECUTABLEPATH']]
 else:
-return [sys.executable]
+return [pycompat.sysexecutable]
 return gethgcmd()
 
 def rundetached(args, condfn):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 7] py3: use python 3 compatible variables in hgext/fsmontor/__init__.py

2016-12-21 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482343838 -19800
#  Wed Dec 21 23:40:38 2016 +0530
# Node ID 6c3d7bf8e5fef7cff76a359dfe6ba627fa9ed10c
# Parent  e8996b8c2c391ba6594cbeebe0a9e9a268f1ba2b
py3: use python 3 compatible variables in hgext/fsmontor/__init__.py

Earlier this was left thinking that its part of pywatchman package.
This patch replaces variables os.sep, sys.platform and os.envrion with their
py3 compatible ones.

diff -r e8996b8c2c39 -r 6c3d7bf8e5fe hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py   Wed Dec 21 22:42:31 2016 +0530
+++ b/hgext/fsmonitor/__init__.py   Wed Dec 21 23:40:38 2016 +0530
@@ -94,15 +94,16 @@
 import hashlib
 import os
 import stat
-import sys
 
 from mercurial.i18n import _
 from mercurial import (
 context,
+encoding,
 extensions,
 localrepo,
 merge,
 pathutil,
+pycompat,
 scmutil,
 util,
 )
@@ -292,7 +293,7 @@
 if normalize:
 foldmap = dict((normcase(k), k) for k in results)
 
-switch_slashes = os.sep == '\\'
+switch_slashes = pycompat.ossep == '\\'
 # The order of the results is, strictly speaking, undefined.
 # For case changes on a case insensitive filesystem we may receive
 # two entries, one with exists=True and another with exists=False.
@@ -392,8 +393,8 @@
 
 def _cmpsets(l1, l2):
 try:
-if 'FSMONITOR_LOG_FILE' in os.environ:
-fn = os.environ['FSMONITOR_LOG_FILE']
+if 'FSMONITOR_LOG_FILE' in encoding.environ:
+fn = encoding.environ['FSMONITOR_LOG_FILE']
 f = open(fn, 'wb')
 else:
 fn = 'fsmonitorfail.log'
@@ -434,7 +435,7 @@
 updatestate = (parentworking and match.always() and
not isinstance(ctx2, (context.workingcommitctx,
  context.memctx)) and
-   'HG_PENDING' not in os.environ)
+   'HG_PENDING' not in encoding.environ)
 
 try:
 if self._fsmonitorstate.walk_on_invalidate:
@@ -545,7 +546,7 @@
 
 def extsetup(ui):
 wrapfilecache(localrepo.localrepository, 'dirstate', wrapdirstate)
-if sys.platform == 'darwin':
+if pycompat.sysplatform == 'darwin':
 # An assist for avoiding the dangling-symlink fsevents bug
 extensions.wrapfunction(os, 'symlink', wrapsymlink)
 
diff -r e8996b8c2c39 -r 6c3d7bf8e5fe tests/test-check-code.t
--- a/tests/test-check-code.t   Wed Dec 21 22:42:31 2016 +0530
+++ b/tests/test-check-code.t   Wed Dec 21 23:40:38 2016 +0530
@@ -9,21 +9,6 @@
 
   $ hg locate -X contrib/python-zstandard -X hgext/fsmonitor/pywatchman |
   > sed 's-\\-/-g' | xargs "$check_code" --warnings --per-file=0 || false
-  hgext/fsmonitor/__init__.py:295:
-   > switch_slashes = os.sep == '\\'
-   use pycompat.ossep instead (py3)
-  hgext/fsmonitor/__init__.py:395:
-   > if 'FSMONITOR_LOG_FILE' in os.environ:
-   use encoding.environ instead (py3)
-  hgext/fsmonitor/__init__.py:396:
-   > fn = os.environ['FSMONITOR_LOG_FILE']
-   use encoding.environ instead (py3)
-  hgext/fsmonitor/__init__.py:437:
-   >'HG_PENDING' not in os.environ)
-   use encoding.environ instead (py3)
-  hgext/fsmonitor/__init__.py:548:
-   > if sys.platform == 'darwin':
-   use pycompat.sysplatform instead (py3)
   Skipping i18n/polib.py it has no-che?k-code (glob)
   mercurial/demandimport.py:309:
> if os.environ.get('HGDEMANDIMPORT') != 'disable':
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 7] py3: use pycompat.getcwd instead of os.getcwd

2016-12-21 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482351857 -19800
#  Thu Dec 22 01:54:17 2016 +0530
# Node ID 0c2fad895ac20844fe2947fa1a7b59280cc2698c
# Parent  6c3d7bf8e5fef7cff76a359dfe6ba627fa9ed10c
py3: use pycompat.getcwd instead of os.getcwd

diff -r 6c3d7bf8e5fe -r 0c2fad895ac2 mercurial/win32.py
--- a/mercurial/win32.pyWed Dec 21 23:40:38 2016 +0530
+++ b/mercurial/win32.pyThu Dec 22 01:54:17 2016 +0530
@@ -14,7 +14,10 @@
 import random
 import subprocess
 
-from . import encoding
+from . import (
+encoding,
+pycompat,
+)
 
 _kernel32 = ctypes.windll.kernel32
 _advapi32 = ctypes.windll.advapi32
@@ -440,7 +443,7 @@
 
 res = _kernel32.CreateProcessA(
 None, args, None, None, False, _CREATE_NO_WINDOW,
-env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))
+env, pycompat.getcwd(), ctypes.byref(si), ctypes.byref(pi))
 if not res:
 raise ctypes.WinError()
 
diff -r 6c3d7bf8e5fe -r 0c2fad895ac2 tests/test-check-code.t
--- a/tests/test-check-code.t   Wed Dec 21 23:40:38 2016 +0530
+++ b/tests/test-check-code.t   Thu Dec 22 01:54:17 2016 +0530
@@ -31,9 +31,6 @@
> policy = os.environ.get('HGMODULEPOLICY', policy)
use encoding.environ instead (py3)
   Skipping mercurial/statprof.py it has no-che?k-code (glob)
-  mercurial/win32.py:443:
-   > env, os.getcwd(), ctypes.byref(si), ctypes.byref(pi))
-   use pycompat.getcwd instead (py3)
   [1]
 
 @commands in debugcommands.py should be in alphabetical order.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 7] py3: replace os.getenv with pycompat.osgetenv

2016-12-21 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482096289 -19800
#  Mon Dec 19 02:54:49 2016 +0530
# Node ID 64800628e1ffbe3d99535c2a8b4d0bc48c822a20
# Parent  eee84d7c0647a50d4e9828b324e1e37214abd169
py3: replace os.getenv with pycompat.osgetenv

os.getenv deals with unicodes on Python 3, so we have pycompat.osgetenv to
deal with bytes. This patch replaces occurrences on os.getenv with
pycompat.osgetenv

diff -r eee84d7c0647 -r 64800628e1ff hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.pyMon Dec 19 02:35:38 2016 +0530
+++ b/hgext/largefiles/lfutil.pyMon Dec 19 02:54:49 2016 +0530
@@ -74,18 +74,19 @@
 if path:
 return path
 if pycompat.osname == 'nt':
-appdata = os.getenv('LOCALAPPDATA', os.getenv('APPDATA'))
+appdata = pycompat.osgetenv('LOCALAPPDATA',\
+pycompat.osgetenv('APPDATA'))
 if appdata:
 return os.path.join(appdata, longname)
 elif platform.system() == 'Darwin':
-home = os.getenv('HOME')
+home = pycompat.osgetenv('HOME')
 if home:
 return os.path.join(home, 'Library', 'Caches', longname)
 elif pycompat.osname == 'posix':
-path = os.getenv('XDG_CACHE_HOME')
+path = pycompat.osgetenv('XDG_CACHE_HOME')
 if path:
 return os.path.join(path, longname)
-home = os.getenv('HOME')
+home = pycompat.osgetenv('HOME')
 if home:
 return os.path.join(home, '.cache', longname)
 else:
diff -r eee84d7c0647 -r 64800628e1ff mercurial/profiling.py
--- a/mercurial/profiling.pyMon Dec 19 02:35:38 2016 +0530
+++ b/mercurial/profiling.pyMon Dec 19 02:54:49 2016 +0530
@@ -8,12 +8,12 @@
 from __future__ import absolute_import, print_function
 
 import contextlib
-import os
 import time
 
 from .i18n import _
 from . import (
 error,
+pycompat,
 util,
 )
 
@@ -120,7 +120,7 @@
 Profiling is active when the context manager is active. When the context
 manager exits, profiling results will be written to the configured output.
 """
-profiler = os.getenv('HGPROF')
+profiler = pycompat.osgetenv('HGPROF')
 if profiler is None:
 profiler = ui.config('profiling', 'type', default='stat')
 if profiler not in ('ls', 'stat', 'flame'):
diff -r eee84d7c0647 -r 64800628e1ff mercurial/url.py
--- a/mercurial/url.py  Mon Dec 19 02:35:38 2016 +0530
+++ b/mercurial/url.py  Mon Dec 19 02:54:49 2016 +0530
@@ -19,6 +19,7 @@
 error,
 httpconnection as httpconnectionmod,
 keepalive,
+pycompat,
 sslutil,
 util,
 )
@@ -80,7 +81,8 @@
 
 class proxyhandler(urlreq.proxyhandler):
 def __init__(self, ui):
-proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy')
+proxyurl = (ui.config("http_proxy", "host") or
+pycompat.osgetenv('http_proxy'))
 # XXX proxyauthinfo = None
 
 if proxyurl:
@@ -98,7 +100,7 @@
 no_list.extend([p.lower() for
 p in ui.configlist("http_proxy", "no")])
 no_list.extend([p.strip().lower() for
-p in os.getenv("no_proxy", '').split(',')
+p in pycompat.osgetenv("no_proxy", '').split(',')
 if p.strip()])
 # "http_proxy.always" config is for running tests on localhost
 if ui.configbool("http_proxy", "always"):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 7] py3: have bytes version of os.getenv

2016-12-21 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482095138 -19800
#  Mon Dec 19 02:35:38 2016 +0530
# Node ID eee84d7c0647a50d4e9828b324e1e37214abd169
# Parent  e995f00a9e9afda3734e7880df0fc90fd2197a88
py3: have bytes version of os.getenv

os.getenv() on python 3 deals with unicodes. If we want to pass bytes. we have
os.getenvb() which deals with bytes. This patch adds up a pycompat.osgetenv
which deals with bytes on both python 2 and 3.

diff -r e995f00a9e9a -r eee84d7c0647 mercurial/pycompat.py
--- a/mercurial/pycompat.py Mon Dec 19 02:26:41 2016 +0530
+++ b/mercurial/pycompat.py Mon Dec 19 02:35:38 2016 +0530
@@ -45,6 +45,7 @@
 ospathsep = os.pathsep.encode('ascii')
 ossep = os.sep.encode('ascii')
 osaltsep = os.altsep
+osgetenv = os.getenvb
 if osaltsep:
 osaltsep = osaltsep.encode('ascii')
 # os.getcwd() on Python 3 returns string, but it has os.getcwdb() which
@@ -156,6 +157,7 @@
 sysargv = sys.argv
 sysplatform = sys.platform
 getcwd = os.getcwd
+osgetenv = os.getenv
 
 stringio = io.StringIO
 empty = _queue.Empty
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


RE: [PATCH RFC] check-commit: add magic string to bypass check-commit

2016-12-21 Thread David Soria Parra via Mercurial-devel


> -Original Message-
> From: Pierre-Yves David [mailto:pierre-yves.da...@ens-lyon.org]
> 
> I would prefer to have that exclusion logic in 'test-check-commit.t',
> These commit still fails our commit checks, but we skip them from
> automated testing.
> 
> Just add "and not desc('#no-check-commit')" to the revset there

Seems reasonable, note however it changes the behavior as `# no-check-commit`
can appear anywhere when using `desc()` while my implementation searches for it
at the starting of a line.

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


[PATCH v2] tests: add magic string to bypass check-commit

2016-12-21 Thread David Soria Parra
# HG changeset patch
# User David Soria Parra 
# Date 1482356655 28800
#  Wed Dec 21 13:44:15 2016 -0800
# Node ID dba02153520bf599a723a6641a8040c7966d2226
# Parent  392751cbb6c47a43676e324d2f1a4e45f35e624b
tests: add magic string to bypass check-commit

Allow bypassing test-check-commit runs by specifying '# no-check-commit'
in the description. This should be avoided but is useful for upstream
imports such as pywatchman which will cause check-code to fail otherwise.

diff --git a/tests/test-check-commit.t b/tests/test-check-commit.t
--- a/tests/test-check-commit.t
+++ b/tests/test-check-commit.t
@@ -8,7 +8,7 @@
 
   $ cd $TESTDIR/..
 
-  $ for node in `hg log --rev 'not public() and ::.' --template 
'{node|short}\n'`; do
+  $ for node in `hg log --rev 'not public() and ::. and not desc("# 
no-check-commit")' --template '{node|short}\n'`; do
   >hg export $node | contrib/check-commit > ${TESTTMP}/check-commit.out
   >if [ $? -ne 0 ]; then
   >echo "Revision $node does not comply with rules"
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] tests: add magic string to bypass check-commit

2016-12-21 Thread David Soria Parra
# HG changeset patch
# User David Soria Parra 
# Date 1482356655 28800
#  Wed Dec 21 13:44:15 2016 -0800
# Node ID dba02153520bf599a723a6641a8040c7966d2226
# Parent  392751cbb6c47a43676e324d2f1a4e45f35e624b
tests: add magic string to bypass check-commit

Allow bypassing test-check-commit runs by specifying '# no-check-commit'
in the description. This should be avoided but is useful for upstream
imports such as pywatchman which will cause check-code to fail otherwise.

diff --git a/tests/test-check-commit.t b/tests/test-check-commit.t
--- a/tests/test-check-commit.t
+++ b/tests/test-check-commit.t
@@ -8,7 +8,7 @@
 
   $ cd $TESTDIR/..
 
-  $ for node in `hg log --rev 'not public() and ::.' --template 
'{node|short}\n'`; do
+  $ for node in `hg log --rev 'not public() and ::. and not desc("# 
no-check-commit")' --template '{node|short}\n'`; do
   >hg export $node | contrib/check-commit > ${TESTTMP}/check-commit.out
   >if [ $? -ne 0 ]; then
   >echo "Revision $node does not comply with rules"
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 5453] New: fails to fold for two branches

2016-12-21 Thread mercurial-bugs
https://bz.mercurial-scm.org/show_bug.cgi?id=5453

Bug ID: 5453
   Summary: fails to fold for two branches
   Product: Mercurial
   Version: unspecified
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: feature
  Priority: wish
 Component: evolution
  Assignee: bugzi...@mercurial-scm.org
  Reporter: oub.oub@gmail.com
CC: mercurial-de...@selenic.com,
pierre-yves.da...@ens-lyon.org

Here is what I did

hg init
echo feature > new.el
hg add new.el
hg commit -m feature1
echo offical2 >> new.el
hg commit -m feature2
echo feature3 >> new.el
hg commit -m feature3
hg branch feature
echo feature > feature.el
hg add feature.el
hg commit -m feature
echo feature2 >> feature.el
hg commit -m feature2

And then I run 
hg fold --exact 'only(default, feature)'

And I obtain the following errors
** Unknown exception encountered with possibly-broken third-party extension
hggit
** which supports versions 3.7 of Mercurial.
** Please disable hggit and try your action again.
** If that fixes the bug please report it to
https://bitbucket.org/durin42/hg-git/issues
** Python 2.7.6 (default, Jun 22 2015, 18:00:18) [GCC 4.8.2]
** Mercurial Distributed SCM (version 4.0-rc)
** Extensions loaded: evolve, eol, hgk, hggit, fetch, rebase, shelve,
largefiles, purge, histedit, pager, record, color, convert, keyword, strip, mq
Traceback (most recent call last):
  File "/usr/bin/hg", line 45, in 
mercurial.dispatch.run()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 60, in
run
sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 126, in
dispatch
ret = _runcatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 216, in
_runcatch
return callcatch(ui, _runcatchfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 225, in
callcatch
return func()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 205, in
_runcatchfunc
return _dispatch(req)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 901, in
_dispatch
cmdpats, cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 650, in
runcommand
ret = _runcommand(ui, options, cmd, d)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 220, in
closure
return func(*(args + a), **kw)
  File "/usr/lib/python2.7/dist-packages/hgext/color.py", line 521, in colorcmd
return orig(ui_, opts, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 220, in
closure
return func(*(args + a), **kw)
  File "/usr/lib/python2.7/dist-packages/hgext/pager.py", line 160, in pagecmd
return orig(ui, options, cmd, cmdfunc)
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 909, in
_runcommand
return cmdfunc()
  File "/usr/lib/python2.7/dist-packages/mercurial/dispatch.py", line 898, in

d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1037, in
check
return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 220, in
closure
return func(*(args + a), **kw)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1037, in
check
return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/hgext/mq.py", line 3540, in mqcommand
return orig(ui, repo, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1037, in
check
return func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/extensions.py", line 220, in
closure
return func(*(args + a), **kw)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1037, in
check
return func(*args, **kwargs)
  File "/home/oub/ALLES/src/evolve/hgext/evolve.py", line 732, in warnobserrors
ret = orig(ui, repo, *args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/mercurial/util.py", line 1037, in
check
return func(*args, **kwargs)
  File "/home/oub/ALLES/src/evolve/hgext/evolve.py", line 3142, in fold
targetphase = max(c.phase() for c in allctx)
ValueError: max() arg is an empty sequence

-- 
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 4 of 4] chgserver: move wrapchgui to runcommand

2016-12-21 Thread Augie Fackler

> On Dec 20, 2016, at 11:46, Jun Wu  wrote:
> 
> The pager API has 2 levels:
> 
>  - high-level (pagecmd): decide the command of the pager, call low-level
>  - low-level (_runpager): accept a command and run it unconditionally
> 
> I think ui.pager() should be high-level, and chg only wants to replace the
> low-level one.
> 
> Therefore a possible API is:
> 
>  - ui.pager() as the new high-level API which parses config and calls
>low-level method.
>  - ui._runpager(pagercmd) as the low-level API which will be implemented
>differently by chg.
> 
> A possible approach is:
> 
>  1. Move pager._runpager to uimod.ui._runpager
>  2. Override ui._runpager in chgui
>  3. Move part of pagecmd to uimod.ui.pager (or startpager if we plan to
> have an endpager in the future)
>  4. Revisit when to call ui.pager (complex)
> 
> 1 and 2 are easy and related to chg. 3 does not block chg refactoring and is
> simple enough so I could help by the way. 4 is a complex core part of the
> pager plan but I'd like to avoid as it has nothing to do with chg.

This matches my understanding of where we probably have to go for the pager 
work.

I'm not sure if we should plan to make the pager exit-able, but that depends on 
the architecture we use for paging, which I haven't given much thought lately.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 9] py3: replace os.environ with encoding.environ (part 3 of 5)

2016-12-21 Thread Pulkit Goyal
>>  if ui.config("http_proxy", "host"):
>>  for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
>>  try:
>> -if env in os.environ:
>> -del os.environ[env]
>> +if env in encoding.environ:
>> +del encoding.environ[env]
>>  except OSError:
>>  pass
>
> Here we have to pass new environ dict to urllib2 over the global os.environ
> dict. So we'll need to revisit this part later since encoding.environ can be
> a read-only copy of os.environ on Python 3.

We have two possible options,

1.  for env in [u"HTTP_PROXY", u"http_proxy", u"no_proxy"]:
 try:
if env in os.environ:
del os.environ[env]

2. for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
 try:
if py3:
if env in os.environb:
del os.environb[env]
else:
if env in os.environ:
del os.environ[env]

IIUC encoding.environ everytimes goes into encoding.py, check those
conditions and returns a dictionary by reading os.environ or
os.environb. Or is it like every time we are reading(getting by
calling encoding.environ) the same dictionary.

If first argument is correct than any of these will work because
os.environ and os.environb are synchronised in python 3.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 4] color: drop use of the 'global' keyword for '_style'

2016-12-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1479490159 -3600
#  Fri Nov 18 18:29:19 2016 +0100
# Node ID a2f55e5d78ca779bd031a5ab6cd32167f4a6ffdf
# Parent  0038b17608085d0bc611dc7b0c9d1b97a1ea05e4
# EXP-Topic color
color: drop use of the 'global' keyword for '_style'

Using 'global' is usually a bad sign. Here it is used so that one can empty the
content of a dict at the global scope. We '_style.clear()' and drop the global.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -545,10 +545,9 @@ def debugcolor(ui, repo, **opts):
 return _debugdisplaycolor(ui)
 
 def _debugdisplaycolor(ui):
-global _styles
-oldstyle = _styles
+oldstyle = _styles.copy()
 try:
-_styles = {}
+_styles.clear()
 for effect in _effects.keys():
 _styles[effect] = effect
 if _terminfo_params:
@@ -564,7 +563,8 @@ def _debugdisplaycolor(ui):
 for colorname, label in items:
 ui.write(('%s\n') % colorname, label=label)
 finally:
-_styles = oldstyle
+_styles.clear()
+_styles.update(oldstyle)
 
 def _debugdisplaystyle(ui):
 ui.write(_('available style:\n'))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 4] color: move hgext.color._styles to mercurial.color.style

2016-12-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1479488976 -3600
#  Fri Nov 18 18:09:36 2016 +0100
# Node ID 764600c7f44086f0d6bbbaf31a668093999190ce
# Parent  a2f55e5d78ca779bd031a5ab6cd32167f4a6ffdf
# EXP-Topic color
color: move hgext.color._styles to mercurial.color.style

This is small first step to start moving the color infrastructure into core. The
current code of the color extensions is full of strange and debatable things,
we'll clean it up in the process as having things into core help the cleaning.

Moving _style was the simplest sensible move that is possible. It will also help
cleaning up the extension setup process in a later changesets.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -169,6 +169,7 @@ import os
 from mercurial.i18n import _
 from mercurial import (
 cmdutil,
+color,
 commands,
 dispatch,
 extensions,
@@ -322,61 +323,6 @@ try:
 except ImportError:
 _terminfo_params = {}
 
-_styles = {'grep.match': 'red bold',
-   'grep.linenumber': 'green',
-   'grep.rev': 'green',
-   'grep.change': 'green',
-   'grep.sep': 'cyan',
-   'grep.filename': 'magenta',
-   'grep.user': 'magenta',
-   'grep.date': 'magenta',
-   'bookmarks.active': 'green',
-   'branches.active': 'none',
-   'branches.closed': 'black bold',
-   'branches.current': 'green',
-   'branches.inactive': 'none',
-   'diff.changed': 'white',
-   'diff.deleted': 'red',
-   'diff.diffline': 'bold',
-   'diff.extended': 'cyan bold',
-   'diff.file_a': 'red bold',
-   'diff.file_b': 'green bold',
-   'diff.hunk': 'magenta',
-   'diff.inserted': 'green',
-   'diff.tab': '',
-   'diff.trailingwhitespace': 'bold red_background',
-   'changeset.public' : '',
-   'changeset.draft' : '',
-   'changeset.secret' : '',
-   'diffstat.deleted': 'red',
-   'diffstat.inserted': 'green',
-   'histedit.remaining': 'red bold',
-   'ui.prompt': 'yellow',
-   'log.changeset': 'yellow',
-   'patchbomb.finalsummary': '',
-   'patchbomb.from': 'magenta',
-   'patchbomb.to': 'cyan',
-   'patchbomb.subject': 'green',
-   'patchbomb.diffstats': '',
-   'rebase.rebased': 'blue',
-   'rebase.remaining': 'red bold',
-   'resolve.resolved': 'green bold',
-   'resolve.unresolved': 'red bold',
-   'shelve.age': 'cyan',
-   'shelve.newest': 'green bold',
-   'shelve.name': 'blue bold',
-   'status.added': 'green bold',
-   'status.clean': 'none',
-   'status.copied': 'none',
-   'status.deleted': 'cyan bold underline',
-   'status.ignored': 'black bold',
-   'status.modified': 'blue bold',
-   'status.removed': 'red bold',
-   'status.unknown': 'magenta bold underline',
-   'tags.normal': 'green',
-   'tags.local': 'black bold'}
-
-
 def _effect_str(effect):
 '''Helper function for render_effects().'''
 
@@ -414,7 +360,7 @@ def render_effects(text, effects):
 
 def extstyles():
 for name, ext in extensions.extensions():
-_styles.update(getattr(ext, 'colortable', {}))
+color._styles.update(getattr(ext, 'colortable', {}))
 
 def valideffect(effect):
 'Determine if the effect is valid or not.'
@@ -439,7 +385,7 @@ def configstyles(ui):
 ui.warn(_("ignoring unknown color/effect %r "
   "(configured in color.%s)\n")
 % (e, status))
-_styles[status] = ' '.join(good)
+color._styles[status] = ' '.join(good)
 
 class colorui(uimod.ui):
 _colormode = 'ansi'
@@ -492,7 +438,7 @@ class colorui(uimod.ui):
 
 effects = []
 for l in label.split():
-s = _styles.get(l, '')
+s = color._styles.get(l, '')
 if s:
 effects.append(s)
 elif valideffect(l):
@@ -545,31 +491,31 @@ def debugcolor(ui, repo, **opts):
 return _debugdisplaycolor(ui)
 
 def _debugdisplaycolor(ui):
-oldstyle = _styles.copy()
+oldstyle = color._styles.copy()
 try:
-_styles.clear()
+color._styles.clear()
 for effect in _effects.keys():
-_styles[effect] = effect
+color._styles[effect] = effect
 if _terminfo_params:
 for k, v in ui.configitems('color'):
 if k.startswith('color.'):
-_styles[k] = k[6:]
+color._styles[k] = k[6:]
 elif k.startswith('terminfo.'):
-_styles[k] = k[9:]
+color._styles[k] = k[9:]
 ui.write(_('available colors:\n'))
 # sort label with a '_' after the other 

[PATCH 4 of 4] color: load 'colortable' from extension using an 'extraloader'

2016-12-21 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1479489495 -3600
#  Fri Nov 18 18:18:15 2016 +0100
# Node ID ea3cd4faf533dcf3323cbb2a11468a30ea065af3
# Parent  764600c7f44086f0d6bbbaf31a668093999190ce
# EXP-Topic color
color: load 'colortable' from extension using an 'extraloader'

Now that we have the '_style' dictionary in core, we can use the clean and
standard 'extraloader' mechanism to load extension's 'colortable'.
color.loadcolortable

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -358,10 +358,6 @@ def render_effects(text, effects):
 stop = _effect_str('none')
 return ''.join([start, text, stop])
 
-def extstyles():
-for name, ext in extensions.extensions():
-color._styles.update(getattr(ext, 'colortable', {}))
-
 def valideffect(effect):
 'Determine if the effect is valid or not.'
 good = False
@@ -459,7 +455,6 @@ def uisetup(ui):
 mode = _modesetup(ui_, opts['color'])
 colorui._colormode = mode
 if mode and mode != 'debug':
-extstyles()
 configstyles(ui_)
 return orig(ui_, opts, cmd, cmdfunc)
 def colorgit(orig, gitsub, commands, env=None, stream=False, cwd=None):
diff --git a/mercurial/color.py b/mercurial/color.py
--- a/mercurial/color.py
+++ b/mercurial/color.py
@@ -60,3 +60,6 @@ from __future__ import absolute_import
'status.unknown': 'magenta bold underline',
'tags.normal': 'green',
'tags.local': 'black bold'}
+
+def loadcolortable(ui, extname, colortable):
+_styles.update(colortable)
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -25,6 +25,7 @@ from .i18n import _
 
 from . import (
 cmdutil,
+color,
 commands,
 demandimport,
 encoding,
@@ -730,6 +731,7 @@ def _cmdattr(ui, cmd, func, attr):
 #   extraobj) arguments
 extraloaders = [
 ('cmdtable', commands, 'loadcmdtable'),
+('colortable', color, 'loadcolortable'),
 ('filesetpredicate', fileset, 'loadpredicate'),
 ('revsetpredicate', revset, 'loadpredicate'),
 ('templatefilter', templatefilters, 'loadfilter'),
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4] chgserver: move wrapchgui to runcommand

2016-12-21 Thread Jun Wu
Excerpts from Yuya Nishihara's message of 2016-12-21 23:15:28 +0900:
> On Tue, 20 Dec 2016 14:03:04 +, Jun Wu wrote:
> > So uisetup is still necessary to wrap _runpager. The _wrapui change is
> > unnecessary if we use your proposal. In that case, both Patch 2 and 4 can be
> > dropped and Patch 1 and 3 are useful.
> 
> I've queued 1 and 3, thanks.

Actually, patch 1 is unnecessary if we go with the "ui._runpager" approach.
Maybe someone can drop it without adding too many markers.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@30636: 11 new changesets

2016-12-21 Thread Mercurial Commits
11 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/438532c99b54
changeset:   30626:438532c99b54
user:Pierre-Yves David 
date:Mon Dec 19 04:31:13 2016 +0100
summary: changegroup: simplify 'allsupportedversions' logic

https://www.mercurial-scm.org/repo/hg/rev/7ace5304fec5
changeset:   30627:7ace5304fec5
user:Pierre-Yves David 
date:Mon Dec 19 04:29:33 2016 +0100
summary: changegroup: pass 'repo' to allsupportedversions

https://www.mercurial-scm.org/repo/hg/rev/a001cd7296a5
changeset:   30628:a001cd7296a5
user:Pierre-Yves David 
date:Mon Dec 19 04:25:18 2016 +0100
summary: changegroup: simplify logic around enabling changegroup 03

https://www.mercurial-scm.org/repo/hg/rev/e92776c00ffd
changeset:   30629:e92776c00ffd
user:David Soria Parra 
date:Tue Dec 20 09:23:50 2016 -0800
summary: convert: use return value in parse_view() instead of manipulating 
state

https://www.mercurial-scm.org/repo/hg/rev/3830f8806094
changeset:   30630:3830f8806094
user:David Soria Parra 
date:Tue Dec 20 09:23:50 2016 -0800
summary: convert: move localname state to function scope

https://www.mercurial-scm.org/repo/hg/rev/c2be48e56d59
changeset:   30631:c2be48e56d59
user:David Soria Parra 
date:Tue Dec 20 09:23:50 2016 -0800
summary: convert: return calculated values from parse() instead of 
manpulating state

https://www.mercurial-scm.org/repo/hg/rev/1d0e4832e616
changeset:   30632:1d0e4832e616
user:David Soria Parra 
date:Tue Dec 20 09:23:50 2016 -0800
summary: convert: parse perforce data on-demand

https://www.mercurial-scm.org/repo/hg/rev/fd244e047ec0
changeset:   30633:fd244e047ec0
user:David Soria Parra 
date:Tue Dec 20 20:28:41 2016 -0800
summary: tests: exclude bundled pywatchman from check-code test

https://www.mercurial-scm.org/repo/hg/rev/ad15646dc61c
changeset:   30634:ad15646dc61c
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Dec 18 01:34:41 2016 +0530
summary: py3: replace os.environ with encoding.environ (part 1 of 5)

https://www.mercurial-scm.org/repo/hg/rev/a150173da1c1
changeset:   30635:a150173da1c1
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Dec 18 01:46:39 2016 +0530
summary: py3: replace os.environ with encoding.environ (part 2 of 5)

https://www.mercurial-scm.org/repo/hg/rev/f1c9fafcbf46
changeset:   30636:f1c9fafcbf46
bookmark:@
tag: tip
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Dec 18 01:54:36 2016 +0530
summary: py3: replace os.environ with encoding.environ (part 3 of 5)

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


Re: [PATCH 3 of 9] py3: replace os.environ with encoding.environ (part 3 of 5)

2016-12-21 Thread Yuya Nishihara
On Tue, 20 Dec 2016 19:33:49 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pul...@gmail.com>
> # Date 1482006276 -19800
> #  Sun Dec 18 01:54:36 2016 +0530
> # Node ID 9cea8eb14d9e7fbf9be2fa6a67c94e6832d57c11
> # Parent  c1a8b0e2a088a8cd365f7aa6a3f5d609fc57a92f
> py3: replace os.environ with encoding.environ (part 3 of 5)

> --- a/mercurial/url.pySun Dec 18 01:46:39 2016 +0530
> +++ b/mercurial/url.pySun Dec 18 01:54:36 2016 +0530
> @@ -15,6 +15,7 @@
>  
>  from .i18n import _
>  from . import (
> +encoding,
>  error,
>  httpconnection as httpconnectionmod,
>  keepalive,
> @@ -118,8 +119,8 @@
>  if ui.config("http_proxy", "host"):
>  for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
>  try:
> -if env in os.environ:
> -del os.environ[env]
> +if env in encoding.environ:
> +del encoding.environ[env]
>  except OSError:
>  pass

Here we have to pass new environ dict to urllib2 over the global os.environ
dict. So we'll need to revisit this part later since encoding.environ can be
a read-only copy of os.environ on Python 3.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] convert: config option for git rename limit

2016-12-21 Thread Pierre-Yves David



On 12/18/2016 09:54 PM, Gregory Szorc wrote:

# HG changeset patch
# User Gregory Szorc 
# Date 1482094400 28800
#  Sun Dec 18 12:53:20 2016 -0800
# Node ID 34f99a6983df082fc56f50e8aab9dd5f1bbe6676
# Parent  935092e525b0ee5656d0830162a1c2adf8248de3
convert: config option for git rename limit

By default, Git applies rename and copy detection to 400 files. The
diff.renamelimit config option and -l argument to diff commands can
override this.


Looks reasonable, pushed.

Cheers,

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


Re: Future of copy metadata

2016-12-21 Thread Marcin Kasperski

> Mercurial currently stores file copy/rename metadata as a "header" in
> filelog revision data. (…) This metadata means copies/renames can be
> followed without expensive run-time "similarity" detection, which is
> great, especially for large repositories.

… and is also great as a way to preserve the fact of copy/rename in case
the author also edited the file (maybe noticeably) before commiting.

> if copy metadata isn't correct from the beginning, it is wrong
> forever.  That's a pretty painful constraint. 
> (…) be computed at run-time and cached if performance dictates.

Why not have both (stacked)? Keep preserving and using copy metadata as
it is, but extend it at the runtime with dynamically detected
copies/renames? In other words, have commands like hg log --follow get
copy metadata by taking a sum of statically saved filelog data, and
dynamically detected renames calculated on demand.

Such approach seems experiment/proofofconcept-friendly, and also
naturally allows one to swap algorithms depending on the current
context.


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


mercurial@30625: 9 new changesets

2016-12-21 Thread Mercurial Commits
9 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/32a07b8a9f77
changeset:   30617:32a07b8a9f77
user:Yuya Nishihara 
date:Sun Dec 18 16:20:04 2016 +0900
summary: convert: remove unused-but-set variable introduced in db9e883566e8

https://www.mercurial-scm.org/repo/hg/rev/201b44c8875c
changeset:   30618:201b44c8875c
user:Yuya Nishihara 
date:Sun Oct 23 17:47:00 2016 +0900
summary: ui: do not translate empty configsource() to 'none' (API)

https://www.mercurial-scm.org/repo/hg/rev/88efb4fb1975
changeset:   30619:88efb4fb1975
user:Jun Wu 
date:Mon Dec 19 22:07:41 2016 +
summary: chgserver: truncate base address at "." for hash address

https://www.mercurial-scm.org/repo/hg/rev/937c52f06709
changeset:   30620:937c52f06709
user:Jun Wu 
date:Mon Dec 19 22:09:49 2016 +
summary: chg: start server at a unique address

https://www.mercurial-scm.org/repo/hg/rev/d7875bfbfccb
changeset:   30621:d7875bfbfccb
user:Jun Wu 
date:Mon Dec 19 22:15:00 2016 +
summary: chg: remove locks

https://www.mercurial-scm.org/repo/hg/rev/ce36fa9b140c
changeset:   30622:ce36fa9b140c
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sat Dec 17 23:55:25 2016 +0530
summary: py3: make sure encoding.encoding is a bytes variable

https://www.mercurial-scm.org/repo/hg/rev/c6026c20a3ce
changeset:   30623:c6026c20a3ce
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Dec 18 00:44:21 2016 +0530
summary: py3: have a bytes version of os.altsep

https://www.mercurial-scm.org/repo/hg/rev/a82a6eee2613
changeset:   30624:a82a6eee2613
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Dec 18 00:52:05 2016 +0530
summary: py3: have a bytes version of sys.platform

https://www.mercurial-scm.org/repo/hg/rev/bcf4a975f93d
changeset:   30625:bcf4a975f93d
bookmark:@
tag: tip
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Dec 18 01:17:12 2016 +0530
summary: py3: replace os.altsep with pycompat.altsep

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


Re: [PATCH 4 of 4] chgserver: move wrapchgui to runcommand

2016-12-21 Thread Yuya Nishihara
On Tue, 20 Dec 2016 14:03:04 +, Jun Wu wrote:
> So uisetup is still necessary to wrap _runpager. The _wrapui change is
> unnecessary if we use your proposal. In that case, both Patch 2 and 4 can be
> dropped and Patch 1 and 3 are useful.

I've queued 1 and 3, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4] chgserver: move wrapchgui to runcommand

2016-12-21 Thread Yuya Nishihara
On Tue, 20 Dec 2016 16:46:38 +, Jun Wu wrote:
> Excerpts from Yuya Nishihara's message of 2016-12-20 23:29:17 +0900:
> > On Tue, 20 Dec 2016 14:03:04 +, Jun Wu wrote:
> > > Excerpts from Yuya Nishihara's message of 2016-12-20 21:47:23 +0900:
> > > > BTW, is there any reason we have to delay the uisetup() call? I think 
> > > > we can
> > > > just set req.ui in place of req.uisetup:
> > > > 
> > > >   class chgui(uimod.ui):
> > > >   ...
> > > >   req = dispatch.request(ui=chgui.load())
> > > 
> > > It's useful if runcommand needs to wrap on top of the side effects of 
> > > other
> > > extensions (ex. pager). In my WIP patch, chgcmdserver.uisetup looks like:
> > > 
> > > def _uisetup(self, ui):
> > > _wrapui(ui, self._csystem)
> > > try:
> > > pager = extensions.find('pager')
> > > except KeyError:
> > > pass
> > > else:
> > > if util.safehasattr(pager, '_runpager'):
> > > extensions.wrapfunction(pager, '_runpager', 
> > > self._runpager)
> > > 
> > > def _runpager(self, orig, ui, pagercmd):
> > > self._csystem.write(pagercmd, type='pager')
> > > while True:
> > > cmd = self.client.readline()[:-1]
> > > _log('pager subcommand: %s' % cmd)
> > > if cmd == 'attachio':
> > > self.attachio(ui)
> > > elif cmd == '':
> > > break
> > > else:
> > > raise error.Abort(_('unexpected command %s') % cmd)
> > > 
> > > _runpager is coupled with chgcmdserver.
> > 
> > Could it be implemented without req.uisetup() if we had ui.pager() function?
> > 
> > https://www.mercurial-scm.org/wiki/PagerInCorePlan 
> > 
> > I believe we'll need to refactor the pager handling to fix a couple of pager
> > issues (e.g. issue5377.) So I'm not enthusiastic about this _runpager() 
> > change.
> 
> I was aware of the pager refactoring. If we can figure out the final APIs,
> and decouple the complex pager refactoring so the part needed by chg is
> small, I can do that.
> 
> The pager API has 2 levels:
> 
>   - high-level (pagecmd): decide the command of the pager, call low-level
>   - low-level (_runpager): accept a command and run it unconditionally
> 
> I think ui.pager() should be high-level, and chg only wants to replace the
> low-level one.
> 
> Therefore a possible API is:
> 
>   - ui.pager() as the new high-level API which parses config and calls
> low-level method.
>   - ui._runpager(pagercmd) as the low-level API which will be implemented
> differently by chg.
> 
> A possible approach is:
> 
>   1. Move pager._runpager to uimod.ui._runpager
>   2. Override ui._runpager in chgui
>   3. Move part of pagecmd to uimod.ui.pager (or startpager if we plan to
>  have an endpager in the future)
>   4. Revisit when to call ui.pager (complex)
> 
> 1 and 2 are easy and related to chg. 3 does not block chg refactoring and is
> simple enough so I could help by the way. 4 is a complex core part of the
> pager plan but I'd like to avoid as it has nothing to do with chg.

Sounds reasonable to me. I had something similar in mind, which would only
implement the low-level API:

 1. add ui._runpager() -> _runpager()
 2. s/_runpager()/ui._runpager()/
 3. override ui._runpager() by chgui
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 9] py3: replace os.environ with encoding.environ (part 2 of 5)

2016-12-21 Thread Pulkit Goyal
>> You do not need the \ here because you are an open '[' so python knows
>> there is more coming. There was an handful of these, I fixed them
>> inflight.
>>
>> If there is not open '([{' to get that effect, we usually favor adding
>> '(' around the expression than adding '\'.
>>
>> (also we tend to rely on temporary variable when the line becomes too
>> long).

Okay will take care of it the next time.
>>
>>>  envhash = _hashlist(sorted(envitems))
>>>  return sectionhash[:6] + envhash[:6]
>>>
>>> @@ -177,7 +179,7 @@
>>>  if not ui.formatted():
>>>  return
>>>
>>> -p = ui.config("pager", "pager", os.environ.get("PAGER"))
>>> +p = ui.config("pager", "pager", encoding.environ.get("PAGER"))
>>>  usepager = False
>>>  always = util.parsebool(options['pager'])
>>>  auto = options['pager'] == 'auto'
>>> @@ -237,7 +239,7 @@
>>>  if val is True:
>>>  return '1'
>>>  return str(val)
>>> -env = os.environ.copy()
>>> +env = encoding.environ.copy()
>>>  if environ:
>>>  env.update((k, py2shell(v)) for k, v in
>>> environ.iteritems())
>>>  env['HG'] = util.hgexecutable()
>>> @@ -515,8 +517,8 @@
>>>  except ValueError:
>>>  raise ValueError('unexpected value in setenv request')
>>>  _log('setenv: %r\n' % sorted(newenv.keys()))
>>> -os.environ.clear()
>>> -os.environ.update(newenv)
>>> +encoding.environ.clear()
>>> +encoding.environ.update(newenv)
>>>
>>>  capabilities = commandserver.server.capabilities.copy()
>>>  capabilities.update({'attachio': attachio,
>>> @@ -626,8 +628,8 @@
>>>  def chgunixservice(ui, repo, opts):
>>>  # CHGINTERNALMARK is temporarily set by chg client to detect if
>>> chg will
>>>  # start another chg. drop it to avoid possible side effects.
>>> -if 'CHGINTERNALMARK' in os.environ:
>>> -del os.environ['CHGINTERNALMARK']
>>> +if 'CHGINTERNALMARK' in encoding.environ:
>>> +del encoding.environ['CHGINTERNALMARK']
>>>
>>>  if repo:
>>>  # one chgserver can serve multiple repos. drop repo information
>>> diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/sshserver.py
>>> --- a/mercurial/sshserver.pySun Dec 18 01:34:41 2016 +0530
>>> +++ b/mercurial/sshserver.pySun Dec 18 01:46:39 2016 +0530
>>> @@ -8,11 +8,11 @@
>>>
>>>  from __future__ import absolute_import
>>>
>>> -import os
>>>  import sys
>>>
>>>  from .i18n import _
>>>  from . import (
>>> +encoding,
>>>  error,
>>>  hook,
>>>  util,
>>> @@ -131,5 +131,5 @@
>>>  return cmd != ''
>>>
>>>  def _client(self):
>>> -client = os.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
>>> +client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
>>>  return 'remote:ssh:' + client
>>> diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/subrepo.py
>>> --- a/mercurial/subrepo.pySun Dec 18 01:34:41 2016 +0530
>>> +++ b/mercurial/subrepo.pySun Dec 18 01:46:39 2016 +0530
>>> @@ -24,6 +24,7 @@
>>>  from . import (
>>>  cmdutil,
>>>  config,
>>> +encoding,
>>>  error,
>>>  exchange,
>>>  filemerge,
>>> @@ -1102,7 +1103,7 @@
>>>  path = self.wvfs.reljoin(self._ctx.repo().origroot,
>>>   self._path, filename)
>>>  cmd.append(path)
>>> -env = dict(os.environ)
>>> +env = dict(encoding.environ)
>>>  # Avoid localized output, preserve current locale for
>>> everything else.
>>>  lc_all = env.get('LC_ALL')
>>>  if lc_all:
>>> @@ -1398,7 +1399,7 @@
>>>  """
>>>  self.ui.debug('%s: git %s\n' % (self._relpath, '
>>> '.join(commands)))
>>>  if env is None:
>>> -env = os.environ.copy()
>>> +env = encoding.environ.copy()
>>>  # disable localization for Git output (issue5176)
>>>  env['LC_ALL'] = 'C'
>>>  # fix for Git CVE-2015-7545
>>> @@ -1633,7 +1634,7 @@
>>>  if self._gitmissing():
>>>  raise error.Abort(_("subrepo %s is missing") %
>>> self._relpath)
>>>  cmd = ['commit', '-a', '-m', text]
>>> -env = os.environ.copy()
>>> +env = encoding.environ.copy()
>>>  if user:
>>>  cmd += ['--author', user]
>>>  if date:
>>> diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/worker.py
>>> --- a/mercurial/worker.pySun Dec 18 01:34:41 2016 +0530
>>> +++ b/mercurial/worker.pySun Dec 18 01:46:39 2016 +0530
>>> @@ -14,6 +14,7 @@
>>>
>>>  from .i18n import _
>>>  from . import (
>>> +encoding,
>>>  error,
>>>  scmutil,
>>>  util,
>>> @@ -32,7 +33,7 @@
>>>
>>>  # windows
>>>  try:
>>> -n = int(os.environ['NUMBER_OF_PROCESSORS'])
>>> +n = int(encoding.environ['NUMBER_OF_PROCESSORS'])
>>>  if n > 0:
>>>  return n
>>>  except (KeyError, 

Re: [PATCH 9 of 9] py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)

2016-12-21 Thread Pierre-Yves David

On 12/20/2016 03:03 PM, Pulkit Goyal wrote:

# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482094601 -19800
#  Mon Dec 19 02:26:41 2016 +0530
# Node ID e0752031ef003151141020f68a2a902080db157b
# Parent  068e2e6fe20712a2624c5b2050aedeb68ab619c2
py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)


These are pushed with a couple of inflight fixes, thanks.


diff -r 068e2e6fe207 -r e0752031ef00 hgext/win32mbcs.py
--- a/hgext/win32mbcs.pyMon Dec 19 02:15:24 2016 +0530
+++ b/hgext/win32mbcs.pyMon Dec 19 02:26:41 2016 +0530
@@ -169,7 +169,7 @@
 def extsetup(ui):
 # TODO: decide use of config section for this extension
 if ((not os.path.supports_unicode_filenames) and
-(sys.platform != 'cygwin')):
+(pycompat.sysplatform != 'cygwin')):
 ui.warn(_("[win32mbcs] cannot activate on this platform.\n"))
 return
 # determine encoding for filename
diff -r 068e2e6fe207 -r e0752031ef00 mercurial/posix.py
--- a/mercurial/posix.pyMon Dec 19 02:15:24 2016 +0530
+++ b/mercurial/posix.pyMon Dec 19 02:26:41 2016 +0530
@@ -80,7 +80,7 @@
 def parsepatchoutput(output_line):
 """parses the output produced by patch and returns the filename"""
 pf = output_line[14:]
-if os.sys.platform == 'OpenVMS':
+if pycompat.sysplatform == 'OpenVMS':
 if pf[0] == '`':
 pf = pf[1:-1] # Remove the quotes
 else:
@@ -404,7 +404,7 @@

 _needsshellquote = None
 def shellquote(s):
-if os.sys.platform == 'OpenVMS':
+if pycompat.sysplatform == 'OpenVMS':
 return '"%s"' % s
 global _needsshellquote
 if _needsshellquote is None:
@@ -423,7 +423,7 @@

 def testpid(pid):
 '''return False if pid dead, True if running or not sure'''
-if os.sys.platform == 'OpenVMS':
+if pycompat.sysplatform == 'OpenVMS':
 return True
 try:
 os.kill(pid, 0)
diff -r 068e2e6fe207 -r e0752031ef00 mercurial/pure/osutil.py
--- a/mercurial/pure/osutil.py  Mon Dec 19 02:15:24 2016 +0530
+++ b/mercurial/pure/osutil.py  Mon Dec 19 02:26:41 2016 +0530
@@ -12,7 +12,6 @@
 import os
 import socket
 import stat as statmod
-import sys

 from . import (
 policy,
@@ -70,14 +69,14 @@
 return result

 ffi = None
-if modulepolicy not in policynocffi and sys.platform == 'darwin':
+if modulepolicy not in policynocffi and pycompat.sysplatform == 'darwin':
 try:
 from _osutil_cffi import ffi, lib
 except ImportError:
 if modulepolicy == 'cffi': # strict cffi import
 raise

-if sys.platform == 'darwin' and ffi is not None:
+if pycompat.sysplatform == 'darwin' and ffi is not None:
 listdir_batch_size = 4096
 # tweakable number, only affects performance, which chunks
 # of bytes do we get back from getattrlistbulk
@@ -165,7 +164,7 @@
 _SCM_RIGHTS = 0x01
 _socklen_t = ctypes.c_uint

-if sys.platform == 'linux2':
+if pycompat.sysplatform.startswith('linux'):
 # socket.h says "the type should be socklen_t but the definition of
 # the kernel is incompatible with this."
 _cmsg_len_t = ctypes.c_size_t
diff -r 068e2e6fe207 -r e0752031ef00 mercurial/util.py
--- a/mercurial/util.py Mon Dec 19 02:15:24 2016 +0530
+++ b/mercurial/util.py Mon Dec 19 02:26:41 2016 +0530
@@ -795,7 +795,7 @@
 cmd = cmd.replace('INFILE', inname)
 cmd = cmd.replace('OUTFILE', outname)
 code = os.system(cmd)
-if sys.platform == 'OpenVMS' and code & 1:
+if pycompat.sysplatform == 'OpenVMS' and code & 1:
 code = 0
 if code:
 raise Abort(_("command '%s' failed: %s") %
@@ -998,7 +998,7 @@
 return str(val)
 origcmd = cmd
 cmd = quotecommand(cmd)
-if sys.platform == 'plan9' and (sys.version_info[0] == 2
+if pycompat.sysplatform == 'plan9' and (sys.version_info[0] == 2
 and sys.version_info[1] < 7):
 # subprocess kludge to work around issues in half-baked Python
 # ports, notably bichued/python:
@@ -1020,7 +1020,7 @@
 out.write(line)
 proc.wait()
 rc = proc.returncode
-if sys.platform == 'OpenVMS' and rc & 1:
+if pycompat.sysplatform == 'OpenVMS' and rc & 1:
 rc = 0
 if rc and onerr:
 errmsg = '%s %s' % (os.path.basename(origcmd.split(None, 1)[0]),
@@ -1383,7 +1383,7 @@

 def gui():
 '''Are we running in a GUI?'''
-if sys.platform == 'darwin':
+if pycompat.sysplatform == 'darwin':
 if 'SSH_CONNECTION' in encoding.environ:
 # handle SSH access to a box where the user is logged in
 return False
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel



--
Pierre-Yves David
___
Mercurial-devel mailing list

Re: [PATCH 2 of 9] py3: replace os.environ with encoding.environ (part 2 of 5)

2016-12-21 Thread Pierre-Yves David



On 12/20/2016 03:03 PM, Pulkit Goyal wrote:

# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1482005799 -19800
#  Sun Dec 18 01:46:39 2016 +0530
# Node ID c1a8b0e2a088a8cd365f7aa6a3f5d609fc57a92f
# Parent  961ff24b8c2f9d71ff8f5d6539f760e78d88d07a
py3: replace os.environ with encoding.environ (part 2 of 5)

diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/chgserver.py
--- a/mercurial/chgserver.pySun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/chgserver.pySun Dec 18 01:46:39 2016 +0530
@@ -55,6 +55,7 @@
 from . import (
 cmdutil,
 commandserver,
+encoding,
 error,
 extensions,
 osutil,
@@ -102,7 +103,8 @@
 for section in _configsections:
 sectionitems.append(ui.configitems(section))
 sectionhash = _hashlist(sectionitems)
-envitems = [(k, v) for k, v in os.environ.iteritems() if _envre.match(k)]
+envitems = [(k, v) for k, v in encoding.environ.iteritems()\
+if _envre.match(k)]


You do not need the \ here because you are an open '[' so python knows 
there is more coming. There was an handful of these, I fixed them inflight.


If there is not open '([{' to get that effect, we usually favor adding 
'(' around the expression than adding '\'.


(also we tend to rely on temporary variable when the line becomes too long).


 envhash = _hashlist(sorted(envitems))
 return sectionhash[:6] + envhash[:6]

@@ -177,7 +179,7 @@
 if not ui.formatted():
 return

-p = ui.config("pager", "pager", os.environ.get("PAGER"))
+p = ui.config("pager", "pager", encoding.environ.get("PAGER"))
 usepager = False
 always = util.parsebool(options['pager'])
 auto = options['pager'] == 'auto'
@@ -237,7 +239,7 @@
 if val is True:
 return '1'
 return str(val)
-env = os.environ.copy()
+env = encoding.environ.copy()
 if environ:
 env.update((k, py2shell(v)) for k, v in environ.iteritems())
 env['HG'] = util.hgexecutable()
@@ -515,8 +517,8 @@
 except ValueError:
 raise ValueError('unexpected value in setenv request')
 _log('setenv: %r\n' % sorted(newenv.keys()))
-os.environ.clear()
-os.environ.update(newenv)
+encoding.environ.clear()
+encoding.environ.update(newenv)

 capabilities = commandserver.server.capabilities.copy()
 capabilities.update({'attachio': attachio,
@@ -626,8 +628,8 @@
 def chgunixservice(ui, repo, opts):
 # CHGINTERNALMARK is temporarily set by chg client to detect if chg will
 # start another chg. drop it to avoid possible side effects.
-if 'CHGINTERNALMARK' in os.environ:
-del os.environ['CHGINTERNALMARK']
+if 'CHGINTERNALMARK' in encoding.environ:
+del encoding.environ['CHGINTERNALMARK']

 if repo:
 # one chgserver can serve multiple repos. drop repo information
diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/sshserver.py
--- a/mercurial/sshserver.pySun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/sshserver.pySun Dec 18 01:46:39 2016 +0530
@@ -8,11 +8,11 @@

 from __future__ import absolute_import

-import os
 import sys

 from .i18n import _
 from . import (
+encoding,
 error,
 hook,
 util,
@@ -131,5 +131,5 @@
 return cmd != ''

 def _client(self):
-client = os.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
+client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
 return 'remote:ssh:' + client
diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/subrepo.py
--- a/mercurial/subrepo.py  Sun Dec 18 01:34:41 2016 +0530
+++ b/mercurial/subrepo.py  Sun Dec 18 01:46:39 2016 +0530
@@ -24,6 +24,7 @@
 from . import (
 cmdutil,
 config,
+encoding,
 error,
 exchange,
 filemerge,
@@ -1102,7 +1103,7 @@
 path = self.wvfs.reljoin(self._ctx.repo().origroot,
  self._path, filename)
 cmd.append(path)
-env = dict(os.environ)
+env = dict(encoding.environ)
 # Avoid localized output, preserve current locale for everything else.
 lc_all = env.get('LC_ALL')
 if lc_all:
@@ -1398,7 +1399,7 @@
 """
 self.ui.debug('%s: git %s\n' % (self._relpath, ' '.join(commands)))
 if env is None:
-env = os.environ.copy()
+env = encoding.environ.copy()
 # disable localization for Git output (issue5176)
 env['LC_ALL'] = 'C'
 # fix for Git CVE-2015-7545
@@ -1633,7 +1634,7 @@
 if self._gitmissing():
 raise error.Abort(_("subrepo %s is missing") % self._relpath)
 cmd = ['commit', '-a', '-m', text]
-env = os.environ.copy()
+env = encoding.environ.copy()
 if user:
 cmd += ['--author', user]
 if date:
diff -r 961ff24b8c2f -r c1a8b0e2a088 mercurial/worker.py
--- 

Re: [PATCH] tests: exclude bundled pywatchman from check-code test

2016-12-21 Thread Pierre-Yves David



On 12/21/2016 05:29 AM, David Soria Parra wrote:

# HG changeset patch
# User David Soria Parra 
# Date 1482294521 28800
#  Tue Dec 20 20:28:41 2016 -0800
# Node ID 26a5b7f91ec50d20782816b83841bd8087478eb0
# Parent  b090cdf0e161af0ac6768cb404cc0e51bb0baf00
tests: exclude bundled pywatchman from check-code test

pywatchman is imported from upstream and therefore fails to pass
linting. We have added 'no-check-code' manually to every file in the
past. This is cumbersome and modifies upstream sources.


Sure, pushed, thanks.


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
@@ -7,13 +7,8 @@
 New errors are not allowed. Warnings are strongly discouraged.
 (The writing "no-che?k-code" is for not skipping this file when checking.)

-  $ hg locate -X contrib/python-zstandard | sed 's-\\-/-g' |
-  >   xargs "$check_code" --warnings --per-file=0 || false
-  Skipping hgext/fsmonitor/pywatchman/__init__.py it has no-che?k-code (glob)
-  Skipping hgext/fsmonitor/pywatchman/bser.c it has no-che?k-code (glob)
-  Skipping hgext/fsmonitor/pywatchman/capabilities.py it has no-che?k-code 
(glob)
-  Skipping hgext/fsmonitor/pywatchman/msc_stdint.h it has no-che?k-code (glob)
-  Skipping hgext/fsmonitor/pywatchman/pybser.py it has no-che?k-code (glob)
+  $ hg locate -X contrib/python-zstandard -X hgext/fsmonitor/pywatchman |
+  > sed 's-\\-/-g' | xargs "$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)


Cheers,

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


Re: [PATCH RFC] check-commit: add magic string to bypass check-commit

2016-12-21 Thread Pierre-Yves David



On 12/21/2016 12:36 PM, Pierre-Yves David wrote:



On 12/21/2016 05:05 AM, David Soria Parra wrote:

# HG changeset patch
# User David Soria Parra 
# Date 1482293000 28800
#  Tue Dec 20 20:03:20 2016 -0800
# Node ID ff1014e78d5a3084eda379ec51b1c0a1fc4f5b2a
# Parent  11deeb8980886f1bd45c56e8ac3ab662b4fdb252
check-commit: add magic string to bypass check-commit

Allow bypassing check-commit runs by specifying '# no-check-commit' at
the
beginning of a line. This should be avoided but is useful for upstream
imports
such as pywatchman which will cause check-code to fail otherwise.


I would prefer to have that exclusion logic in 'test-check-commit.t',
These commit still fails our commit checks, but we skip them from
automated testing.


But, to be clear, I'm all for this feature otherwise !


Just add "and not desc('#no-check-commit')" to the revset there
https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-check-commit.t#l11



diff --git a/contrib/check-commit b/contrib/check-commit
--- a/contrib/check-commit
+++ b/contrib/check-commit
@@ -25,6 +25,7 @@
 afterheader = commitheader + r"(?!#)"
 beforepatch = afterheader + r"(?!\n(?!@@))"

+bypass = r"^# no-check-commit"
 errors = [
 (beforepatch + r".*[(]bc[)]", "(BC) needs to be uppercase"),
 (beforepatch + r".*[(]issue \d\d\d",
@@ -59,6 +60,9 @@
 exitcode = 0
 printed = node is None
 hits = []
+if re.search(bypass, commit, re.MULTILINE):
+return 0
+
 for exp, msg in errors:
 for m in re.finditer(exp, commit):
 end = m.end()


Cheers,



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


Re: [PATCH RFC] check-commit: add magic string to bypass check-commit

2016-12-21 Thread Pierre-Yves David



On 12/21/2016 05:05 AM, David Soria Parra wrote:

# HG changeset patch
# User David Soria Parra 
# Date 1482293000 28800
#  Tue Dec 20 20:03:20 2016 -0800
# Node ID ff1014e78d5a3084eda379ec51b1c0a1fc4f5b2a
# Parent  11deeb8980886f1bd45c56e8ac3ab662b4fdb252
check-commit: add magic string to bypass check-commit

Allow bypassing check-commit runs by specifying '# no-check-commit' at the
beginning of a line. This should be avoided but is useful for upstream imports
such as pywatchman which will cause check-code to fail otherwise.


I would prefer to have that exclusion logic in 'test-check-commit.t', 
These commit still fails our commit checks, but we skip them from 
automated testing.


Just add "and not desc('#no-check-commit')" to the revset there
https://www.mercurial-scm.org/repo/hg/file/tip/tests/test-check-commit.t#l11


diff --git a/contrib/check-commit b/contrib/check-commit
--- a/contrib/check-commit
+++ b/contrib/check-commit
@@ -25,6 +25,7 @@
 afterheader = commitheader + r"(?!#)"
 beforepatch = afterheader + r"(?!\n(?!@@))"

+bypass = r"^# no-check-commit"
 errors = [
 (beforepatch + r".*[(]bc[)]", "(BC) needs to be uppercase"),
 (beforepatch + r".*[(]issue \d\d\d",
@@ -59,6 +60,9 @@
 exitcode = 0
 printed = node is None
 hits = []
+if re.search(bypass, commit, re.MULTILINE):
+return 0
+
 for exp, msg in errors:
 for m in re.finditer(exp, commit):
 end = m.end()


Cheers,

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