[PATCH 1 of 4] paper: remove unused templates

2016-09-21 Thread Anton Shestakov
# HG changeset patch
# User Anton Shestakov 
# Date 1474521539 -28800
#  Thu Sep 22 13:18:59 2016 +0800
# Node ID 266c2195651e534736aa7706db56f8556fcb1ec5
# Parent  5271ae66615207f39cc41d78f4541bc6f8ca6ff6
paper: remove unused templates

diff --git a/mercurial/templates/paper/map b/mercurial/templates/paper/map
--- a/mercurial/templates/paper/map
+++ b/mercurial/templates/paper/map
@@ -118,12 +118,6 @@ comparisonline = '
 {rightlinenumber} 
{rightline|escape}
   '
 
-changelogparent = '
-  
-parent {rev}:
-{node|short}
-  '
-
 changesetparent = '{node|short}
 '
 
 changesetparentdiff = '
@@ -215,22 +209,12 @@ filediffparent = '
 parent {rev}:
 {node|short}
   '
-filelogparent = '
-  
-parent {rev}:
-{node|short}
-  '
 filediffchild = '
   
 child {rev}:
 {node|short}
   
   '
-filelogchild = '
-  
-child {rev}:
-{node|short}
-  '
 
 indexentry = '
   
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 3 v2] profiling: allow nested usage of maybeprofile

2016-09-21 Thread Yuya Nishihara
On Wed, 21 Sep 2016 18:07:57 +, Arun Kulshreshtha wrote:
> On 9/21/16, 7:41 AM, "Yuya Nishihara"  wrote:
> > maybeprofile() can be called in threads. If we need to prevent nesting, 
> we'll
> > have to save the flag in TLS.
> 
> That said, I'm not sure if nested maybeprofile() can be noop. Last time, 
> Greg
> tried to make statprof stackable, which would imply maybeprofile() 
> designed
> to be nested.
> 
> Hm, right now it seems like if you stack profilers, you’ll get multiple 
> profiling statistics printouts at the end of command execution, which is hard 
> to read. But this this behavior is actually desirable, then we’ll need to 
> deal with this situation differently.

Perhaps we can move both maybeprofile() calls to _dispatch() without thinking
about how nested profilers behave.

--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -774,7 +774,8 @@ def _dispatch(req):
 # Check abbreviation/ambiguity of shell alias.
 shellaliasfn = _checkshellalias(lui, ui, args)
 if shellaliasfn:
-return shellaliasfn()
+with profiling.maybeprofile(lui):
+return shellaliasfn()
 
 # check for fallback encoding
 fallback = lui.config('ui', 'fallbackencoding')
@@ -844,6 +845,10 @@ def _dispatch(req):
 elif not cmd:
 return commands.help_(ui, 'shortlist')
 
+with profiling.maybeprofile(lui):
+return _dispatchcommand(...)
+
+def _dispatchcommand(...):
 repo = None
 cmdpats = args[:]
 if not _cmdattr(ui, cmd, func, 'norepo'):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Bug 5375] New: hg import crash

2016-09-21 Thread bugzilla
https://bz.mercurial-scm.org/show_bug.cgi?id=5375

Bug ID: 5375
   Summary: hg import crash
   Product: Mercurial
   Version: default branch
  Hardware: PC
OS: Linux
Status: UNCONFIRMED
  Severity: bug
  Priority: wish
 Component: Mercurial
  Assignee: bugzi...@selenic.com
  Reporter: r...@fb.com
CC: mercurial-de...@selenic.com

This crashes hg:

echo -e "diff --git a/a b/b\nrename from a\nrename to b" | hg import -

Stacktrace:

+  applying patch from stdin
+  a not tracked!
+  ** unknown exception encountered, please report by visiting
+  ** https://mercurial-scm.org/wiki/BugTracker
+  ** Python 2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red
Hat 4.8.5-4)]
+  ** Mercurial Distributed SCM (version 3.9+200-e2b35a4ff9c3)
+  ** Extensions loaded:
+  Traceback (most recent call last):
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/hg", line 45, in

+  mercurial.dispatch.run()
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line 60,
in run
+  sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
126, in dispatch
+  ret = _runcatch(req)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
216, in _runcatch
+  return callcatch(ui, _runcatchfunc)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
225, in callcatch
+  return func()
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
205, in _runcatchfunc
+  return _dispatch(req)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
897, in _dispatch
+  cmdpats, cmdoptions)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
650, in runcommand
+  ret = _runcommand(ui, options, cmd, d)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
906, in _runcommand
+  return cmdfunc()
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/dispatch.py", line
894, in 
+  d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/util.py",
line 1035, in check
+  return func(*args, **kwargs)
+File
"/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/commands.py", line
4963, in import_
+  msgs, hg.clean)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/cmdutil.py",
line 998, in tryimportone
+  files=files, eolmode=None, similarity=sim / 100.0)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/patch.py",
line 2099, in patch
+  similarity)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/patch.py",
line 2072, in internalpatch
+  return patchbackend(ui, backend, patchobj, strip, prefix, files,
eolmode)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/patch.py",
line 2057, in patchbackend
+  eolmode=eolmode)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/patch.py",
line 1908, in applydiff
+  prefix=prefix, eolmode=eolmode)
+File "/data/users/rmcelroy/facebook-hg-rpms/hg-crew/mercurial/patch.py",
line 1954, in _applydiff
+  assert data is not None
+  AssertionError
+  [1]

-- 
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 3 of 3 v3] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Arun Kulshreshtha



On 9/21/16, 2:05 PM, "Arun Kulshreshtha"  wrote:




On 9/21/16, 11:08 AM, "Augie Fackler"  wrote:


> On Sep 21, 2016, at 13:50, Pierre-Yves David 
 wrote:
> 
> 
> 
> On 09/21/2016 07:31 PM, Augie Fackler wrote:
>> On Tue, Sep 20, 2016 at 01:35:22PM -0700, Arun Kulshreshtha wrote:
>>> # HG changeset patch
>>> # User Arun Kulshreshtha 
>>> # Date 1474318006 25200
>>> #  Mon Sep 19 13:46:46 2016 -0700
>>> # Node ID f157d9becfe724d624e0f3328febe58c5694d950
>>> # Parent  0bb030bb1ce94c5514b671a3900ba207ebb19269
>>> dispatch: make hg --profile wrap reposetup
>> 
>> This makes sense to me. Queued.
>> 
>> (I shiver a little bit at threadlocals, but what can you do? Sigh.)
> 
> Yuya raised multiples valid question when reviewing V2 and it is 
unclear they have all been addressed especially since the discussion where 
still going on in V2 after V3 was sent).
> Did you checked the status of this series with Yuya ?

No, because I saw a v3 and discarded the entire v2 discussion, assuming 
v3 resolved the things discussed in v2.

> 
> Cheers,
> 
> -- 
> Pierre-Yves David


Is it possible to undo the accept? To repeat, Yuya made further comments on 
v2
after I had already sent out v3 addressing his first set of comments. This 
version 
doesn’t address the latest feedback so it shouldn’t be published yet.

Sorry about the confusion.

Never mind, looks like this was resolved over IRC.



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


Re: [PATCH 3 of 3 v3] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Augie Fackler

> On Sep 21, 2016, at 17:05, Arun Kulshreshtha  wrote:
> 
> 
> 
> 
> On 9/21/16, 11:08 AM, "Augie Fackler"  wrote:
> 
> 
>> On Sep 21, 2016, at 13:50, Pierre-Yves David 
>>  wrote:
>> 
>> 
>> 
>> On 09/21/2016 07:31 PM, Augie Fackler wrote:
>>> On Tue, Sep 20, 2016 at 01:35:22PM -0700, Arun Kulshreshtha wrote:
 # HG changeset patch
 # User Arun Kulshreshtha 
 # Date 1474318006 25200
 #  Mon Sep 19 13:46:46 2016 -0700
 # Node ID f157d9becfe724d624e0f3328febe58c5694d950
 # Parent  0bb030bb1ce94c5514b671a3900ba207ebb19269
 dispatch: make hg --profile wrap reposetup
>>> 
>>> This makes sense to me. Queued.
>>> 
>>> (I shiver a little bit at threadlocals, but what can you do? Sigh.)
>> 
>> Yuya raised multiples valid question when reviewing V2 and it is unclear 
>> they have all been addressed especially since the discussion where still 
>> going on in V2 after V3 was sent).
>> Did you checked the status of this series with Yuya ?
> 
>No, because I saw a v3 and discarded the entire v2 discussion, assuming v3 
> resolved the things discussed in v2.
> 
>> 
>> Cheers,
>> 
>> -- 
>> Pierre-Yves David
> 
> 
> Is it possible to undo the accept? To repeat, Yuya made further comments on v2
> after I had already sent out v3 addressing his first set of comments. This 
> version 
> doesn’t address the latest feedback so it shouldn’t be published yet.
> 
> Sorry about the confusion.

Ugh, I thought I had done that, but it turns out obsolete markers and bookmarks 
play poorly in a way I didn't know about. It's fixed now.

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


Re: [PATCH 3 of 3 v3] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Arun Kulshreshtha



On 9/21/16, 11:08 AM, "Augie Fackler"  wrote:


> On Sep 21, 2016, at 13:50, Pierre-Yves David 
 wrote:
> 
> 
> 
> On 09/21/2016 07:31 PM, Augie Fackler wrote:
>> On Tue, Sep 20, 2016 at 01:35:22PM -0700, Arun Kulshreshtha wrote:
>>> # HG changeset patch
>>> # User Arun Kulshreshtha 
>>> # Date 1474318006 25200
>>> #  Mon Sep 19 13:46:46 2016 -0700
>>> # Node ID f157d9becfe724d624e0f3328febe58c5694d950
>>> # Parent  0bb030bb1ce94c5514b671a3900ba207ebb19269
>>> dispatch: make hg --profile wrap reposetup
>> 
>> This makes sense to me. Queued.
>> 
>> (I shiver a little bit at threadlocals, but what can you do? Sigh.)
> 
> Yuya raised multiples valid question when reviewing V2 and it is unclear 
they have all been addressed especially since the discussion where still going 
on in V2 after V3 was sent).
> Did you checked the status of this series with Yuya ?

No, because I saw a v3 and discarded the entire v2 discussion, assuming v3 
resolved the things discussed in v2.

> 
> Cheers,
> 
> -- 
> Pierre-Yves David


Is it possible to undo the accept? To repeat, Yuya made further comments on v2
after I had already sent out v3 addressing his first set of comments. This 
version 
doesn’t address the latest feedback so it shouldn’t be published yet.

Sorry about the confusion.


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


Re: [PATCH 3 of 3 v2] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Durham Goode



On 9/21/16 1:07 PM, Arun Kulshreshtha wrote:



On 9/21/16, 7:34 AM, "Yuya Nishihara"  wrote:

 On Tue, 20 Sep 2016 18:30:49 +, Arun Kulshreshtha wrote:
 > On 9/20/16, 6:01 AM, "Yuya Nishihara"  wrote:
 >
 > On Mon, 19 Sep 2016 16:13:58 -0700, Arun Kulshreshtha wrote:
 > > # HG changeset patch
 > > # User Arun Kulshreshtha 
 > > # Date 1474318006 25200
 > > #  Mon Sep 19 13:46:46 2016 -0700
 > > # Node ID 20af15cac045b249aece42cb71b671302b6c314c
 > > # Parent  6f33cc84cdd6c9ab38d32784505b6fb53bf3eba9
 > > dispatch: make hg --profile wrap reposetup
 > >
 > > Add profiling to _dispatch so that reposetup is included in the 
profiler
 > > output. All existing usage of the profiling context manager has 
been preserved,
 > > so the existing behavior of profiling enabled after reposetup will 
not be
 > > affected.
 > >
 > > diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
 > > --- a/mercurial/dispatch.py
 > > +++ b/mercurial/dispatch.py
 > > @@ -844,7 +844,7 @@
 > >  elif not cmd:
 > >  return commands.help_(ui, 'shortlist')
 > >
 > > -if True:
 > > +with profiling.maybeprofile(ui):
 > >  repo = None
 > >  cmdpats = args[:]
 > >  if not _cmdattr(ui, cmd, func, 'norepo'):
 >
 > Any reason to not remove maybeprofile() from _runcommand() ? Can it 
be enabled
 > after reposetup() ?
 >
 > Yes, if it is configured in the repo-specific settings (.hg/hgrc), for 
example, then it would be missed if
 > maybeprofile were removed from _runcommand().
 
 .hg/hgrc should be loaded to 'lui'. Can you check if maybeprofile(lui) works?
 
Alright, I’ll see if I can get that to work.


 > Additionally, we’d need to wrap other callsites of
 > _runcommand(), such as _checkshellalias(), to maintain the existing 
behavior.
 
 Good point. Given that we want to start profiling as early as possible, I think

 it's better to test profiling.enabled before extensions.loadall(lui), and 
test
 it again after parsing command options.

CC’ing Durham on this. I considered doing this, but during our (offline) 
discussion about this, it seemed
like it was undesirable to profile uisetup() for each extension, which is why I 
placed maybeprofile() after
extensions.loadall(). However, if we do indeed want to start profiling as early 
as possible, then I’ll try enabling
profiling as early as possible in _dispatch() and remove the other callsites.
The only reason I hesitated to wrap uisetup and extsetup is that 
extensions may modify the profile logic (like we have a statprofext 
extension that configures statprof), so wrapping early may make that 
impossible.

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


Re: [PATCH 3 of 3 v2] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Arun Kulshreshtha



On 9/21/16, 7:34 AM, "Yuya Nishihara"  wrote:

On Tue, 20 Sep 2016 18:30:49 +, Arun Kulshreshtha wrote:
> On 9/20/16, 6:01 AM, "Yuya Nishihara"  wrote:
> 
> On Mon, 19 Sep 2016 16:13:58 -0700, Arun Kulshreshtha wrote:
> > # HG changeset patch
> > # User Arun Kulshreshtha 
> > # Date 1474318006 25200
> > #  Mon Sep 19 13:46:46 2016 -0700
> > # Node ID 20af15cac045b249aece42cb71b671302b6c314c
> > # Parent  6f33cc84cdd6c9ab38d32784505b6fb53bf3eba9
> > dispatch: make hg --profile wrap reposetup
> > 
> > Add profiling to _dispatch so that reposetup is included in the 
profiler
> > output. All existing usage of the profiling context manager has 
been preserved,
> > so the existing behavior of profiling enabled after reposetup will 
not be
> > affected.
> > 
> > diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> > --- a/mercurial/dispatch.py
> > +++ b/mercurial/dispatch.py
> > @@ -844,7 +844,7 @@
> >  elif not cmd:
> >  return commands.help_(ui, 'shortlist')
> >  
> > -if True:
> > +with profiling.maybeprofile(ui):
> >  repo = None
> >  cmdpats = args[:]
> >  if not _cmdattr(ui, cmd, func, 'norepo'):
> 
> Any reason to not remove maybeprofile() from _runcommand() ? Can it 
be enabled
> after reposetup() ?
> 
> Yes, if it is configured in the repo-specific settings (.hg/hgrc), for 
example, then it would be missed if
> maybeprofile were removed from _runcommand().

.hg/hgrc should be loaded to 'lui'. Can you check if maybeprofile(lui) 
works?

Alright, I’ll see if I can get that to work.

> Additionally, we’d need to wrap other callsites of
> _runcommand(), such as _checkshellalias(), to maintain the existing 
behavior.

Good point. Given that we want to start profiling as early as possible, I 
think
it's better to test profiling.enabled before extensions.loadall(lui), and 
test
it again after parsing command options.

CC’ing Durham on this. I considered doing this, but during our (offline) 
discussion about this, it seemed 
like it was undesirable to profile uisetup() for each extension, which is why I 
placed maybeprofile() after 
extensions.loadall(). However, if we do indeed want to start profiling as early 
as possible, then I’ll try enabling 
profiling as early as possible in _dispatch() and remove the other callsites.



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


Re: [PATCH 3 of 3 v3] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread timeless
Siddharth Agarwal wrote:
> As a general thing I don't think we should be spending time trying to fix
> this implementation of demandimport on Python 3 at all.

This isn't really about python3, it's just about foreign code that
expects a certain object to look a certain way, but because of
demandimport it gets a demandimport object stub instead of an
exception -- in python3 it would have at least gotten a stub for a
real object. -- I don't know if the code works in py3 but that's a
different adventure, and I'm happy to let a python3 demandimport
solution worry about it.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 v3] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread Siddharth Agarwal

On 9/21/16 12:09, timeless wrote:

# HG changeset patch
# User timeless 
# Date 1474429683 0
#  Wed Sep 21 03:48:03 2016 +
# Node ID 0070696439eab002f6dd32bcb40eb671daff800a
# Parent  adb54fd7d90f0ca607432ed7ae884da55ec427de
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
0070696439ea
demandimport: reject contextlib._GeneratorContextManager on Py < 3.2


As a general thing I don't think we should be spending time trying to 
fix this implementation of demandimport on Python 3 at all. I would much 
rather we use an implementation based on the new importlib stuff, like 
the one I sent to the list a while back. (Hopefully I can get it in 
during the sprint.)


- Siddharth



decorator expects:
  from contextlib import _GeneratorContextManager
to throw an exception on python < 3.2 (issue5373).

We tell demandimport to throw it.

diff -r adb54fd7d90f -r 0070696439ea mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 18:58:54 2016 +
+++ b/mercurial/demandimport.py Wed Sep 21 03:48:03 2016 +
@@ -313,6 +313,12 @@
  if os.name != 'nt':
  reject('distutils', 'msvc9compiler', ImportError, 'No module named 
_winreg')
  
+# decorator imported by ipython from pygments does an import which isn't

+# friendly to demandimport.
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+reject('contextlib', '_GeneratorContextManager',
+   ImportError, 'cannot import name _GeneratorContextManager')
+
  def isenabled():
  return builtins.__import__ == _demandimport
  
diff -r adb54fd7d90f -r 0070696439ea tests/test-demandimport.py

--- a/tests/test-demandimport.pyWed Sep 21 18:58:54 2016 +
+++ b/tests/test-demandimport.pyWed Sep 21 03:48:03 2016 +
@@ -71,6 +71,15 @@
  except ImportError:
  pass
  
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:

+try:
+from contextlib import _GeneratorContextManager
+print('contextlib._GeneratorContextManager needs to be an '
+  'immediate importerror on python <3.2')
+_GeneratorContextManager.__doc__
+except ImportError:
+pass
+
  demandimport.disable()
  os.environ['HGDEMANDIMPORT'] = 'disable'
  # this enable call should not actually enable demandimport!
___
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 2 of 3 v3] demandimport: replace distutils.msvc9compiler ignore with reject

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474484334 0
#  Wed Sep 21 18:58:54 2016 +
# Node ID adb54fd7d90f0ca607432ed7ae884da55ec427de
# Parent  33884775ee4b22109085387b0317aa17db73c483
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
adb54fd7d90f
demandimport: replace distutils.msvc9compiler ignore with reject

diff -r 33884775ee4b -r adb54fd7d90f mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 18:59:07 2016 +
+++ b/mercurial/demandimport.py Wed Sep 21 18:58:54 2016 +
@@ -296,8 +296,6 @@
 'rfc822',
 'mimetools',
 'sqlalchemy.events', # has import-time side effects (issue5085)
-# setuptools 8 expects this module to explode early when not on windows
-'distutils.msvc9compiler',
 ]
 
 rejects = {}
@@ -310,6 +308,11 @@
 if not mod in rejects:
 rejects[mod] = {}
 rejects[mod][prop] = [cls, msg]
+
+# setuptools 8 expects this module to explode early when not on windows
+if os.name != 'nt':
+reject('distutils', 'msvc9compiler', ImportError, 'No module named 
_winreg')
+
 def isenabled():
 return builtins.__import__ == _demandimport
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 3 v3] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474429683 0
#  Wed Sep 21 03:48:03 2016 +
# Node ID 0070696439eab002f6dd32bcb40eb671daff800a
# Parent  adb54fd7d90f0ca607432ed7ae884da55ec427de
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
0070696439ea
demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

decorator expects:
 from contextlib import _GeneratorContextManager
to throw an exception on python < 3.2 (issue5373).

We tell demandimport to throw it.

diff -r adb54fd7d90f -r 0070696439ea mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 18:58:54 2016 +
+++ b/mercurial/demandimport.py Wed Sep 21 03:48:03 2016 +
@@ -313,6 +313,12 @@
 if os.name != 'nt':
 reject('distutils', 'msvc9compiler', ImportError, 'No module named 
_winreg')
 
+# decorator imported by ipython from pygments does an import which isn't
+# friendly to demandimport.
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+reject('contextlib', '_GeneratorContextManager',
+   ImportError, 'cannot import name _GeneratorContextManager')
+
 def isenabled():
 return builtins.__import__ == _demandimport
 
diff -r adb54fd7d90f -r 0070696439ea tests/test-demandimport.py
--- a/tests/test-demandimport.pyWed Sep 21 18:58:54 2016 +
+++ b/tests/test-demandimport.pyWed Sep 21 03:48:03 2016 +
@@ -71,6 +71,15 @@
 except ImportError:
 pass
 
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+try:
+from contextlib import _GeneratorContextManager
+print('contextlib._GeneratorContextManager needs to be an '
+  'immediate importerror on python <3.2')
+_GeneratorContextManager.__doc__
+except ImportError:
+pass
+
 demandimport.disable()
 os.environ['HGDEMANDIMPORT'] = 'disable'
 # this enable call should not actually enable demandimport!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3 v3] demandimport: suppport rejecting modules based on requested properties

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474484347 0
#  Wed Sep 21 18:59:07 2016 +
# Node ID 33884775ee4b22109085387b0317aa17db73c483
# Parent  982fe7cdb28bb263a96b1bc2c9c3b8aedb025ab6
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
33884775ee4b
demandimport: suppport rejecting modules based on requested properties

Some code uses:
try:
 from Foo import Bar
except ImportError:
 from Foo import Bar2

demandimport exposes Bar as an unloaded module without checking to
see whether or not it really exists this enables it to improve loading
speed.

Unfortunately, any code that expects to get an ImportError won't get
one.

This code enables callers to tell demandimport about the shape of some
libraries to enable it to replicate the exception that callers expect.

without demandimport:
>>> from contextlib import _GeneratorContextManager
Traceback (most recent call last):
  File "", line 1, in 
ImportError: cannot import name _GeneratorContextManager

with demandimport without reject:
>>> from __future__ import absolute_import
>>> from mercurial import demandimport
>>> demandimport.enable()
>>> from contextlib import _GeneratorContextManager
>>> _GeneratorContextManager


with demandimport and reject:
>>> from __future__ import absolute_import
>>> from mercurial import demandimport
>>> demandimport.enable()
>>> demandimport.reject("contextlib", "_GeneratorContextManager", ImportError, 
>>> "cannot import name _GeneratorContextManager")
>>> from contextlib import _GeneratorContextManager
Traceback (most recent call last):
  File "", line 1, in 
  File "mercurial/demandimport.py", line 260, in _demandimport
processfromlist(mod, name, fromlist)
  File "mercurial/demandimport.py", line 235, in processfromlist
raise cls(msg)
ImportError: cannot import name _GeneratorContextManager

diff -r 982fe7cdb28b -r 33884775ee4b mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 03:39:37 2016 +
+++ b/mercurial/demandimport.py Wed Sep 21 18:59:07 2016 +
@@ -158,6 +158,17 @@
 _pypy = '__pypy__' in sys.builtin_module_names
 
 def _demandimport(name, globals=None, locals=None, fromlist=None, level=level):
+def checksubimports(name, fromlist):
+# for each item in fromlist, if a module property
+# is registered for rejection, then raise the specified exception
+if not name in rejects:
+return
+reject = rejects[name]
+for x in fromlist:
+if x in reject:
+cls, msg = reject[x]
+raise cls(msg)
+
 if not locals or name in ignore or fromlist == ('*',):
 # these cases we can't really delay
 return _hgextimport(_import, name, globals, locals, fromlist, level)
@@ -165,6 +176,7 @@
 # import a [as b]
 if '.' in name: # a.b
 base, rest = name.split('.', 1)
+checksubimports(base, [rest])
 # email.__init__ loading email.mime
 if globals and globals.get('__name__', None) == base:
 return _import(name, globals, locals, fromlist, level)
@@ -220,6 +232,7 @@
 mod = getattr(mod, comp)
 return mod
 
+checksubimports(name, fromlist)
 if level >= 0:
 if name:
 # "from a import b" or "from .a import b" style
@@ -287,6 +300,16 @@
 'distutils.msvc9compiler',
 ]
 
+rejects = {}
+
+def reject(mod, prop, cls, msg):
+"""inform demandimport that a module does not have a property
+
+arguments are the class and message to raise when code tries to
+import it."""
+if not mod in rejects:
+rejects[mod] = {}
+rejects[mod][prop] = [cls, msg]
 def isenabled():
 return builtins.__import__ == _demandimport
 
diff -r 982fe7cdb28b -r 33884775ee4b tests/test-demandimport.py
--- a/tests/test-demandimport.pyWed Sep 21 03:39:37 2016 +
+++ b/tests/test-demandimport.pyWed Sep 21 18:59:07 2016 +
@@ -63,6 +63,14 @@
 print("re.stderr =", f(re.stderr))
 print("re =", f(re))
 
+demandimport.reject('chunk', 'Chunk', ImportError, 'boo')
+try:
+from chunk import Chunk
+print('reject should prevent chunk from loading for Chunk')
+Chunk.getname
+except ImportError:
+pass
+
 demandimport.disable()
 os.environ['HGDEMANDIMPORT'] = 'disable'
 # this enable call should not actually enable demandimport!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 9 V4] manifest: add manifestlog.get to obtain subdirectory instances

2016-09-21 Thread Durham Goode

On 9/21/16 11:56 AM, Martin von Zweigbergk wrote:

On Tue, Sep 20, 2016 at 4:47 PM, Durham Goode  wrote:

# HG changeset patch
# User Durham Goode 
# Date 1474399441 25200
#  Tue Sep 20 12:24:01 2016 -0700
# Node ID 52a206d772021194ab4356aeba2c73650851a624
# Parent  8cf5f24c100e58ece712703d0e4bb0746bc3087e
manifest: add manifestlog.get to obtain subdirectory instances

Previously manifestlog only allowed obtaining root level manifests. Future
patches will need direct access to subdirectory manifests as part of changegroup
creation, so let's add a get() function that knows how to deal with
subdirectories.

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1033,20 +1033,34 @@ class manifestlog(object):
  """Retrieves the manifest instance for the given node. Throws a 
KeyError
  if not found.
  """
-if node in self._mancache:
-cachemf = self._mancache[node]
-# The old manifest may put non-ctx manifests in the cache, so skip
-# those since they don't implement the full api.
-if (isinstance(cachemf, manifestctx) or
-isinstance(cachemf, treemanifestctx)):
-return cachemf
+return self.get('', node)

-if self._treeinmem:
-m = treemanifestctx(self._revlog, '', node)
+def get(self, dir, node):
+"""Retrieves the manifest instance for the given node. Throws a 
KeyError
+if not found.

nit: Does it really throw KeyError? __getitem__ also doesn't seem to.
Interesting point.  It used to, when manifestctx would read from the 
revlog during the constructor, but since we moved that out, it probably 
doesn't now (but probably should).  I'll make the manifestctx and 
treemanifestctx constructors at least check that the node exists in the 
revlog before returning, and throw KeyError if they don't.

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


Re: [PATCH 5 of 9 V4] manifest: add manifestlog.get to obtain subdirectory instances

2016-09-21 Thread Martin von Zweigbergk via Mercurial-devel
On Tue, Sep 20, 2016 at 4:47 PM, Durham Goode  wrote:
> # HG changeset patch
> # User Durham Goode 
> # Date 1474399441 25200
> #  Tue Sep 20 12:24:01 2016 -0700
> # Node ID 52a206d772021194ab4356aeba2c73650851a624
> # Parent  8cf5f24c100e58ece712703d0e4bb0746bc3087e
> manifest: add manifestlog.get to obtain subdirectory instances
>
> Previously manifestlog only allowed obtaining root level manifests. Future
> patches will need direct access to subdirectory manifests as part of 
> changegroup
> creation, so let's add a get() function that knows how to deal with
> subdirectories.
>
> diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> --- a/mercurial/manifest.py
> +++ b/mercurial/manifest.py
> @@ -1033,20 +1033,34 @@ class manifestlog(object):
>  """Retrieves the manifest instance for the given node. Throws a 
> KeyError
>  if not found.
>  """
> -if node in self._mancache:
> -cachemf = self._mancache[node]
> -# The old manifest may put non-ctx manifests in the cache, so 
> skip
> -# those since they don't implement the full api.
> -if (isinstance(cachemf, manifestctx) or
> -isinstance(cachemf, treemanifestctx)):
> -return cachemf
> +return self.get('', node)
>
> -if self._treeinmem:
> -m = treemanifestctx(self._revlog, '', node)
> +def get(self, dir, node):
> +"""Retrieves the manifest instance for the given node. Throws a 
> KeyError
> +if not found.

nit: Does it really throw KeyError? __getitem__ also doesn't seem to.

> +"""
> +if dir:
> +if self._revlog._treeondisk:
> +m = treemanifestctx(self._revlog.dirlog(dir), dir, node)
> +else:
> +raise error.Abort(
> +_("cannot ask for manifest directory '%s' in a flat "
> +  "manifest") % dir)
>  else:
> -m = manifestctx(self._revlog, node)
> -if node != revlog.nullid:
> -self._mancache[node] = m
> +if node in self._mancache:
> +cachemf = self._mancache[node]
> +# The old manifest may put non-ctx manifests in the cache, so
> +# skip those since they don't implement the full api.
> +if (isinstance(cachemf, manifestctx) or
> +isinstance(cachemf, treemanifestctx)):
> +return cachemf
> +
> +if self._treeinmem:
> +m = treemanifestctx(self._revlog, '', node)
> +else:
> +m = manifestctx(self._revlog, node)
> +if node != revlog.nullid:
> +self._mancache[node] = m
>  return m
>
>  def add(self, m, transaction, link, p1, p2, added, removed):
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 v2] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread timeless
please hold off on v2. I'd like to try a v3 that handles
distutils.msvc9compiler -- it turns out that processfromlist might
really be too late and that I may have to really split out the
iteration of fromlist into two places.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 5] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread timeless
Yuya Nishihara wrote:
> Can't we simply ignore 'contextlib' ?

I had a patch that did that. It felt gross (it clearly wasn't very elegant)

> Since contextlib is imported by demandimport.py, there's no benefit to delay
> importing contextlib.

So, demandimport could just return a given module if it's already
loaded w/o wrapping things,
but it's possible for a module to be loaded w/o its submodules being loaded.

We don't want to automatically load all submodules (that would more or
less bypass demandimport, and thus defeat its purpose).

I think that other modules have similarly unfriendly code, and that it
thus makes sense to offer this feature.

After looking through our list of ignores, I think that it should be
possible to make distutils.msvc9compiler work with my general approach
(although the specific implementation I have in v1 and v2 doesn't
work, so I'll need a v3).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3 v2] demandimport: refactor processfromlist to ensure consistent handling

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474429251 0
#  Wed Sep 21 03:40:51 2016 +
# Node ID 32a4cb17f935c570817249721401e0d62033987d
# Parent  982fe7cdb28bb263a96b1bc2c9c3b8aedb025ab6
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
32a4cb17f935
demandimport: refactor processfromlist to ensure consistent handling

The next changeset will add a slow path for modules where certain
properties should be treated as not present.

In order to ensure that the codepath is handled the same for
absolute_import and relative import, this code should be in a single
location.

diff -r 982fe7cdb28b -r 32a4cb17f935 mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 03:39:37 2016 +
+++ b/mercurial/demandimport.py Wed Sep 21 03:40:51 2016 +
@@ -220,6 +220,12 @@
 mod = getattr(mod, comp)
 return mod
 
+def processfromlist(mod, name, fromlist):
+# call processfromitem for each item in fromlist
+if True:
+for x in fromlist:
+processfromitem(mod, x)
+
 if level >= 0:
 if name:
 # "from a import b" or "from .a import b" style
@@ -242,8 +248,7 @@
 mod = _hgextimport(_origimport, name, globals, locals,
level=level)
 
-for x in fromlist:
-processfromitem(mod, x)
+processfromlist(mod, name, fromlist)
 
 return mod
 
@@ -251,9 +256,7 @@
 # party modules. So handle level == -1.
 mod = _hgextimport(_origimport, name, globals, locals)
 mod = chainmodules(mod, name)
-
-for x in fromlist:
-processfromitem(mod, x)
+processfromlist(mod, name, fromlist)
 
 return mod
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 3 v2] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474429683 0
#  Wed Sep 21 03:48:03 2016 +
# Node ID b2d5ad899bbb3c6eace4547b975c84f155066f0b
# Parent  20111b4d031e63596b93e162af9b8ca3ff1c98af
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
b2d5ad899bbb
demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

decorator expects:
 from contextlib import _GeneratorContextManager
to throw an exception on python < 3.2 (issue5373).

We tell demandimport to throw it.

diff -r 20111b4d031e -r b2d5ad899bbb mercurial/demandimport.py
--- a/mercurial/demandimport.py Wed Sep 21 03:47:35 2016 +
+++ b/mercurial/demandimport.py Wed Sep 21 03:48:03 2016 +
@@ -309,6 +309,13 @@
 if not mod in rejects:
 rejects[mod] = {}
 rejects[mod][prop] = [cls, msg]
+
+# decorator imported by ipython from pygments does an import which isn't
+# friendly to demandimport.
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+reject('contextlib', '_GeneratorContextManager',
+   ImportError, 'cannot import name _GeneratorContextManager')
+
 def isenabled():
 return builtins.__import__ == _demandimport
 
diff -r 20111b4d031e -r b2d5ad899bbb tests/test-demandimport.py
--- a/tests/test-demandimport.pyWed Sep 21 03:47:35 2016 +
+++ b/tests/test-demandimport.pyWed Sep 21 03:48:03 2016 +
@@ -71,6 +71,15 @@
 except ImportError:
 pass
 
+if sys.version_info[0] < 3 or sys.version_info[1] < 2:
+try:
+from contextlib import _GeneratorContextManager
+print('contextlib._GeneratorContextManager needs to be an '
+  'immediate importerror on python <3.2')
+_GeneratorContextManager.__doc__
+except ImportError:
+pass
+
 demandimport.disable()
 os.environ['HGDEMANDIMPORT'] = 'disable'
 # this enable call should not actually enable demandimport!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 3 v2] profiling: allow nested usage of maybeprofile

2016-09-21 Thread Arun Kulshreshtha
On 9/21/16, 7:41 AM, "Yuya Nishihara"  wrote:

On Tue, 20 Sep 2016 21:49:26 +0900, Yuya Nishihara wrote:
> On Mon, 19 Sep 2016 16:13:56 -0700, Arun Kulshreshtha wrote:
> > # HG changeset patch
> > # User Arun Kulshreshtha 
> > # Date 1474324901 25200
> > #  Mon Sep 19 15:41:41 2016 -0700
> > # Node ID 679c90104cc1fc92099ede6bd359f6ab5b10640d
> > # Parent  285a8c3e53f2183438f0cdbc238e4ab851d0d110
> > profiling: allow nested usage of maybeprofile
> > 
> > Add a check to the maybeprofile context manager to ensure that profiling
> > is only enabled once in nested invocations of this context manager.
> > 
> > Updated in v2 of this patch to reset itself once the root invocation
> > has exited. While not currently used, this ensures that maybeprofile
> > can be used in multiple (non-nested) places in a single run.
> > 
> > diff --git a/mercurial/profiling.py b/mercurial/profiling.py
> > --- a/mercurial/profiling.py
> > +++ b/mercurial/profiling.py
> > @@ -157,8 +157,15 @@
> >  just use a single code path for calling into code you may want to 
profile
> >  and this function determines whether to start profiling.
> >  """
> > -if ui.configbool('profiling', 'enabled'):
> > +
> > +# Guard against nested invocations of this context manager.
> > +# Profiling should only be started in the outermost invocation.
> > +alreadyenabled = getattr(maybeprofile, 'enabled', False)
> > +
> > +if ui.configbool('profiling', 'enabled') and not alreadyenabled:
> > +maybeprofile.enabled = True
> >  with profile(ui):
> >  yield
> > +maybeprofile.enabled = False
> 
> maybeprofile() can be called in threads. If we need to prevent nesting, 
we'll
> have to save the flag in TLS.

That said, I'm not sure if nested maybeprofile() can be noop. Last time, 
Greg
tried to make statprof stackable, which would imply maybeprofile() designed
to be nested.

Hm, right now it seems like if you stack profilers, you’ll get multiple 
profiling statistics printouts at the end of command execution, which is hard 
to read. But this this behavior is actually desirable, then we’ll need to deal 
with this situation differently.


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


Re: [PATCH 3 of 3 v3] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Arun Kulshreshtha
V3 doesn’t address all of the feedback on V2, since Yuya sent some additional 
comments after I’d already sent out V3. So this isn’t ready to land yet.


On 9/21/16, 10:50 AM, "Pierre-Yves David"  
wrote:



On 09/21/2016 07:31 PM, Augie Fackler wrote:
> On Tue, Sep 20, 2016 at 01:35:22PM -0700, Arun Kulshreshtha wrote:
>> # HG changeset patch
>> # User Arun Kulshreshtha 
>> # Date 1474318006 25200
>> #  Mon Sep 19 13:46:46 2016 -0700
>> # Node ID f157d9becfe724d624e0f3328febe58c5694d950
>> # Parent  0bb030bb1ce94c5514b671a3900ba207ebb19269
>> dispatch: make hg --profile wrap reposetup
>
> This makes sense to me. Queued.
>
> (I shiver a little bit at threadlocals, but what can you do? Sigh.)

Yuya raised multiples valid question when reviewing V2 and it is unclear 
they have all been addressed especially since the discussion where still 
going on in V2 after V3 was sent).
Did you checked the status of this series with Yuya ?

Cheers,

-- 
Pierre-Yves David



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


Re: [PATCH 3 of 3 v3] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Pierre-Yves David



On 09/21/2016 07:31 PM, Augie Fackler wrote:

On Tue, Sep 20, 2016 at 01:35:22PM -0700, Arun Kulshreshtha wrote:

# HG changeset patch
# User Arun Kulshreshtha 
# Date 1474318006 25200
#  Mon Sep 19 13:46:46 2016 -0700
# Node ID f157d9becfe724d624e0f3328febe58c5694d950
# Parent  0bb030bb1ce94c5514b671a3900ba207ebb19269
dispatch: make hg --profile wrap reposetup


This makes sense to me. Queued.

(I shiver a little bit at threadlocals, but what can you do? Sigh.)


Yuya raised multiples valid question when reviewing V2 and it is unclear 
they have all been addressed especially since the discussion where still 
going on in V2 after V3 was sent).

Did you checked the status of this series with Yuya ?

Cheers,

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


Re: [PATCH 3 of 3] help: add sections for revsets

2016-09-21 Thread Augie Fackler
On Wed, Sep 21, 2016 at 05:25:11PM +, timeless wrote:
> # HG changeset patch
> # User timeless 
> # Date 1474478613 0
> #  Wed Sep 21 17:23:33 2016 +
> # Node ID 692f1e17fb708d83e6022fc1ef1fb69366d7ee45
> # Parent  2ed8375eb6ca1fe2f00fac49f1b9c79d705a522a
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
> 692f1e17fb70
> help: add sections for revsets

Queued these, thanks.

>
> diff -r 2ed8375eb6ca -r 692f1e17fb70 mercurial/help/revsets.txt
> --- a/mercurial/help/revsets.txt  Wed Sep 21 17:23:05 2016 +
> +++ b/mercurial/help/revsets.txt  Wed Sep 21 17:23:33 2016 +
> @@ -12,11 +12,17 @@
>  e.g., ``\n`` is interpreted as a newline. To prevent them from being
>  interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
>
> +Prefix
> +==
> +
>  There is a single prefix operator:
>
>  ``not x``
>Changesets not in x. Short form is ``! x``.
>
> +Infix
> +=
> +
>  These are the supported infix operators:
>
>  ``x::y``
> @@ -71,16 +77,24 @@
>  in this case. This matches against all of "issue 1234", "issue:1234",
>  "issue1234" and "bug(1234)".
>
> +Postfix
> +===
> +
>  There is a single postfix operator:
>
>  ``x^``
>Equivalent to ``x^1``, the first parent of each changeset in x.
>
> +Predicates
> +==
>
>  The following predicates are supported:
>
>  .. predicatesmarker
>
> +Aliases
> +===
> +
>  New predicates (known as "aliases") can be defined, using any combination of
>  existing predicates or other aliases. An alias definition looks like::
>
> @@ -102,6 +116,8 @@
>  defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
>  exactly equivalent to ``reverse(sort(0:tip, author))``.
>
> +Equivalents
> +===
>
>  Command line equivalents for :hg:`log`::
>
> @@ -114,6 +130,9 @@
>-P x  ->  !::x
>-l x  ->  limit(expr, x)
>
> +Examples
> +
> +
>  Some sample queries:
>
>  - Changesets on the default branch::
> ___
> 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 3 of 3] help: add sections for revsets

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474478613 0
#  Wed Sep 21 17:23:33 2016 +
# Node ID 692f1e17fb708d83e6022fc1ef1fb69366d7ee45
# Parent  2ed8375eb6ca1fe2f00fac49f1b9c79d705a522a
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
692f1e17fb70
help: add sections for revsets

diff -r 2ed8375eb6ca -r 692f1e17fb70 mercurial/help/revsets.txt
--- a/mercurial/help/revsets.txtWed Sep 21 17:23:05 2016 +
+++ b/mercurial/help/revsets.txtWed Sep 21 17:23:33 2016 +
@@ -12,11 +12,17 @@
 e.g., ``\n`` is interpreted as a newline. To prevent them from being
 interpreted, strings can be prefixed with ``r``, e.g. ``r'...'``.
 
+Prefix
+==
+
 There is a single prefix operator:
 
 ``not x``
   Changesets not in x. Short form is ``! x``.
 
+Infix
+=
+
 These are the supported infix operators:
 
 ``x::y``
@@ -71,16 +77,24 @@
 in this case. This matches against all of "issue 1234", "issue:1234",
 "issue1234" and "bug(1234)".
 
+Postfix
+===
+
 There is a single postfix operator:
 
 ``x^``
   Equivalent to ``x^1``, the first parent of each changeset in x.
 
+Predicates
+==
 
 The following predicates are supported:
 
 .. predicatesmarker
 
+Aliases
+===
+
 New predicates (known as "aliases") can be defined, using any combination of
 existing predicates or other aliases. An alias definition looks like::
 
@@ -102,6 +116,8 @@
 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
 exactly equivalent to ``reverse(sort(0:tip, author))``.
 
+Equivalents
+===
 
 Command line equivalents for :hg:`log`::
 
@@ -114,6 +130,9 @@
   -P x  ->  !::x
   -l x  ->  limit(expr, x)
 
+Examples
+
+
 Some sample queries:
 
 - Changesets on the default branch::
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 3] help: clarify quotes are needed for filesets.size expressions

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474475617 0
#  Wed Sep 21 16:33:37 2016 +
# Node ID 40410e96c0a2de344edd5a25a7d996731124ee45
# Parent  285a8c3e53f2183438f0cdbc238e4ab851d0d110
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
40410e96c0a2
help: clarify quotes are needed for filesets.size expressions

diff -r 285a8c3e53f2 -r 40410e96c0a2 mercurial/fileset.py
--- a/mercurial/fileset.py  Tue May 03 13:36:12 2016 +0900
+++ b/mercurial/fileset.py  Wed Sep 21 16:33:37 2016 +
@@ -345,10 +345,10 @@
 def size(mctx, x):
 """File size matches the given expression. Examples:
 
-- 1k (files from 1024 to 2047 bytes)
-- < 20k (files less than 20480 bytes)
-- >= .5MB (files at least 524288 bytes)
-- 4k - 1MB (files from 4096 bytes to 1048576 bytes)
+- size('1k') - files from 1024 to 2047 bytes
+- size('< 20k') - files less than 20480 bytes
+- size('>= .5MB') - files at least 524288 bytes
+- size('4k - 1MB') - files from 4096 bytes to 1048576 bytes
 """
 
 # i18n: "size" is a keyword
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 3] help: move revsets.## documentation into infix section

2016-09-21 Thread timeless
# HG changeset patch
# User timeless 
# Date 1474478585 0
#  Wed Sep 21 17:23:05 2016 +
# Node ID 2ed8375eb6ca1fe2f00fac49f1b9c79d705a522a
# Parent  40410e96c0a2de344edd5a25a7d996731124ee45
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
2ed8375eb6ca
help: move revsets.## documentation into infix section

diff -r 40410e96c0a2 -r 2ed8375eb6ca mercurial/help/revsets.txt
--- a/mercurial/help/revsets.txtWed Sep 21 16:33:37 2016 +
+++ b/mercurial/help/revsets.txtWed Sep 21 17:23:05 2016 +
@@ -55,6 +55,22 @@
 ``x~n``
   The nth first ancestor of x; ``x~0`` is x; ``x~3`` is ``x^^^``.
 
+``x ## y``
+  Concatenate strings and identifiers into one string.
+
+  All other prefix, infix and postfix operators have lower priority than
+  ``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
+
+  For example::
+
+[revsetalias]
+issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
+
+``issue(1234)`` is equivalent to
+``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
+in this case. This matches against all of "issue 1234", "issue:1234",
+"issue1234" and "bug(1234)".
+
 There is a single postfix operator:
 
 ``x^``
@@ -86,18 +102,6 @@
 defines three aliases, ``h``, ``d``, and ``rs``. ``rs(0:tip, author)`` is
 exactly equivalent to ``reverse(sort(0:tip, author))``.
 
-An infix operator ``##`` can concatenate strings and identifiers into
-one string. For example::
-
-  [revsetalias]
-  issue(a1) = grep(r'\bissue[ :]?' ## a1 ## r'\b|\bbug\(' ## a1 ## r'\)')
-
-``issue(1234)`` is equivalent to ``grep(r'\bissue[ :]?1234\b|\bbug\(1234\)')``
-in this case. This matches against all of "issue 1234", "issue:1234",
-"issue1234" and "bug(1234)".
-
-All other prefix, infix and postfix operators have lower priority than
-``##``. For example, ``a1 ## a2~2`` is equivalent to ``(a1 ## a2)~2``.
 
 Command line equivalents for :hg:`log`::
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@29962: 16 new changesets

2016-09-21 Thread Mercurial Commits
16 new changesets in mercurial:

http://selenic.com/repo/hg//rev/e1f0ec0b7d2d
changeset:   29947:e1f0ec0b7d2d
user:Augie Fackler 
date:Tue Sep 13 22:57:57 2016 -0400
summary: flags: allow specifying --no-boolean-flag on the command line (BC)

http://selenic.com/repo/hg//rev/e40343ce9c4c
changeset:   29948:e40343ce9c4c
user:Augie Fackler 
date:Tue Aug 30 15:55:07 2016 -0400
summary: diffopts: notice a negated boolean flag in diffopts

http://selenic.com/repo/hg//rev/e7cacb45c4be
changeset:   29949:e7cacb45c4be
user:Mathias De Maré 
date:Mon Aug 29 17:19:09 2016 +0200
summary: formatter: introduce isplain() to replace (the inverse of) 
__nonzero__() (API)

http://selenic.com/repo/hg//rev/80fef5251099
changeset:   29950:80fef5251099
user:Mathias De Maré 
date:Mon Aug 29 07:07:15 2016 +0200
summary: config: add template support

http://selenic.com/repo/hg//rev/e7acbe538baf
changeset:   29951:e7acbe538baf
user:Martin von Zweigbergk 
date:Thu Sep 15 10:18:56 2016 -0700
summary: strip: simplify some repeated conditions

http://selenic.com/repo/hg//rev/44ef21621ad7
changeset:   29952:44ef21621ad7
user:Martin von Zweigbergk 
date:Thu Sep 15 09:45:29 2016 -0700
summary: strip: report both bundle files in case of exception (issue5368)

http://selenic.com/repo/hg//rev/94ebf56db04e
changeset:   29953:94ebf56db04e
user:Martin von Zweigbergk 
date:Mon Sep 19 09:14:32 2016 -0700
summary: strip: clarify that user action is required to recover temp bundle

http://selenic.com/repo/hg//rev/769aee32fae0
changeset:   29954:769aee32fae0
user:Martin von Zweigbergk 
date:Mon Sep 19 09:14:35 2016 -0700
summary: strip: don't use "full" and "partial" to describe bundles

http://selenic.com/repo/hg//rev/1b5931604a5a
changeset:   29955:1b5931604a5a
user:Yuya Nishihara 
date:Tue May 03 14:18:28 2016 +0900
summary: revset: add option to make matcher takes the ordering of the input 
set

http://selenic.com/repo/hg//rev/fa5e4f58dfbc
changeset:   29956:fa5e4f58dfbc
user:Yuya Nishihara 
date:Tue May 03 14:24:00 2016 +0900
summary: log: drop hack to fix order of revset (issue5100)

http://selenic.com/repo/hg//rev/7d053ba73178
changeset:   29957:7d053ba73178
user:Nathan Goldbaum 
date:Tue Sep 20 10:03:50 2016 -0500
summary: crecord: add an event that scrolls the selected line to the top of 
the screen

http://selenic.com/repo/hg//rev/37a36c05dcc3
changeset:   29958:37a36c05dcc3
user:Augie Fackler 
date:Mon Sep 19 17:14:43 2016 -0400
summary: copy: document current behavior of 'hg cp --after'

http://selenic.com/repo/hg//rev/483003c27938
changeset:   29959:483003c27938
user:Durham Goode 
date:Tue Sep 20 12:24:01 2016 -0700
summary: manifest: move treeinmem onto manifestlog

http://selenic.com/repo/hg//rev/da75bc36202c
changeset:   29960:da75bc36202c
user:Durham Goode 
date:Tue Sep 20 12:24:01 2016 -0700
summary: manifest: remove dependency on treeinmem from manifest.add

http://selenic.com/repo/hg//rev/774a15b129e8
changeset:   29961:774a15b129e8
user:Durham Goode 
date:Tue Sep 20 12:24:01 2016 -0700
summary: manifest: move manifest.add onto manifestrevlog

http://selenic.com/repo/hg//rev/6b5a9a01f29d
changeset:   29962:6b5a9a01f29d
bookmark:@
tag: tip
user:Durham Goode 
date:Tue Sep 20 12:24:01 2016 -0700
summary: manifest: add manifestlog.add

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


Re: [PATCH 17 of 17] tests: favor single quotes for wrapping hg help

2016-09-21 Thread Martin von Zweigbergk via Mercurial-devel
I've pushed the cleaned-up series. What I fixed:

* Made concatenated string literals spanning multiple lines is
consistent quoting across lines
* Changed quotes around "hg -v" to single quotes where it was on the
same line as an already changed quote

On Wed, Sep 21, 2016 at 6:34 AM, Martin von Zweigbergk
 wrote:
> I have a version of this series locally with some cleanups that I talked to
> timeless about on IRC. I feel asleep before tests had finished running, but
> I'll do your version of it and replace it by mine when I get to work in a
> few hours. Sorry, should have at least remembered to update this thread
> yesterday.
>
>
> On Wed, Sep 21, 2016, 04:29 Pierre-Yves David
>  wrote:
>>
>> On 09/21/2016 02:19 AM, timeless wrote:
>> > # HG changeset patch
>> > # User timeless 
>> > # Date 1474415360 0
>> > #  Tue Sep 20 23:49:20 2016 +
>> > # Node ID 07306ec6e0c4e0accdaf3efee348361f36910295
>> > # Parent  0f8eca5689fad5be2cef54141c8185b8bd5639f3
>> > # Available At https://bitbucket.org/timeless/mercurial-crew
>> > #  hg pull https://bitbucket.org/timeless/mercurial-crew -r
>> > 07306ec6e0c4
>> > tests: favor single quotes for wrapping hg help ...
>>
>> Pushed this, Thanks for the extensive clean up.
>>
>> Cheers,
>>
>> --
>> Pierre-Yves David
>> ___
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 5 of 5] demandimport: reject contextlib._GeneratorContextManager on Py < 3.2

2016-09-21 Thread Yuya Nishihara
On Wed, 21 Sep 2016 03:59:35 +, timeless wrote:
> # HG changeset patch
> # User timeless 
> # Date 1474429683 0
> #  Wed Sep 21 03:48:03 2016 +
> # Node ID e07c3d398573f74a2e382deb06462bdc15ed437f
> # Parent  894cc47eb82a85d167f5717c9fe0a31392e5bb97
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
> e07c3d398573
> demandimport: reject contextlib._GeneratorContextManager on Py < 3.2
> 
> issue5373
> 
> diff -r 894cc47eb82a -r e07c3d398573 mercurial/demandimport.py
> --- a/mercurial/demandimport.py   Wed Sep 21 03:47:35 2016 +
> +++ b/mercurial/demandimport.py   Wed Sep 21 03:48:03 2016 +
> @@ -306,6 +306,13 @@
>  if not mod in rejects:
>  rejects[mod] = {}
>  rejects[mod][prop] = [cls, msg]
> +
> +# decorator imported by ipython from pygments does an import which isn't
> +# friendly to demandimport.
> +if sys.version_info[0] < 3 or sys.version_info[1] < 2:
> +reject('contextlib', '_GeneratorContextManager',
> +   ImportError, 'cannot import name _GeneratorContextManager')

Can't we simply ignore 'contextlib' ?

Since contextlib is imported by demandimport.py, there's no benefit to delay
importing contextlib.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 3 v2] profiling: allow nested usage of maybeprofile

2016-09-21 Thread Yuya Nishihara
On Tue, 20 Sep 2016 21:49:26 +0900, Yuya Nishihara wrote:
> On Mon, 19 Sep 2016 16:13:56 -0700, Arun Kulshreshtha wrote:
> > # HG changeset patch
> > # User Arun Kulshreshtha 
> > # Date 1474324901 25200
> > #  Mon Sep 19 15:41:41 2016 -0700
> > # Node ID 679c90104cc1fc92099ede6bd359f6ab5b10640d
> > # Parent  285a8c3e53f2183438f0cdbc238e4ab851d0d110
> > profiling: allow nested usage of maybeprofile
> > 
> > Add a check to the maybeprofile context manager to ensure that profiling
> > is only enabled once in nested invocations of this context manager.
> > 
> > Updated in v2 of this patch to reset itself once the root invocation
> > has exited. While not currently used, this ensures that maybeprofile
> > can be used in multiple (non-nested) places in a single run.
> > 
> > diff --git a/mercurial/profiling.py b/mercurial/profiling.py
> > --- a/mercurial/profiling.py
> > +++ b/mercurial/profiling.py
> > @@ -157,8 +157,15 @@
> >  just use a single code path for calling into code you may want to 
> > profile
> >  and this function determines whether to start profiling.
> >  """
> > -if ui.configbool('profiling', 'enabled'):
> > +
> > +# Guard against nested invocations of this context manager.
> > +# Profiling should only be started in the outermost invocation.
> > +alreadyenabled = getattr(maybeprofile, 'enabled', False)
> > +
> > +if ui.configbool('profiling', 'enabled') and not alreadyenabled:
> > +maybeprofile.enabled = True
> >  with profile(ui):
> >  yield
> > +maybeprofile.enabled = False
> 
> maybeprofile() can be called in threads. If we need to prevent nesting, we'll
> have to save the flag in TLS.

That said, I'm not sure if nested maybeprofile() can be noop. Last time, Greg
tried to make statprof stackable, which would imply maybeprofile() designed
to be nested.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 v2] dispatch: make hg --profile wrap reposetup

2016-09-21 Thread Yuya Nishihara
On Tue, 20 Sep 2016 18:30:49 +, Arun Kulshreshtha wrote:
> On 9/20/16, 6:01 AM, "Yuya Nishihara"  y...@tcha.org> wrote:
> 
> On Mon, 19 Sep 2016 16:13:58 -0700, Arun Kulshreshtha wrote:
> > # HG changeset patch
> > # User Arun Kulshreshtha 
> > # Date 1474318006 25200
> > #  Mon Sep 19 13:46:46 2016 -0700
> > # Node ID 20af15cac045b249aece42cb71b671302b6c314c
> > # Parent  6f33cc84cdd6c9ab38d32784505b6fb53bf3eba9
> > dispatch: make hg --profile wrap reposetup
> > 
> > Add profiling to _dispatch so that reposetup is included in the profiler
> > output. All existing usage of the profiling context manager has been 
> preserved,
> > so the existing behavior of profiling enabled after reposetup will not 
> be
> > affected.
> > 
> > diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> > --- a/mercurial/dispatch.py
> > +++ b/mercurial/dispatch.py
> > @@ -844,7 +844,7 @@
> >  elif not cmd:
> >  return commands.help_(ui, 'shortlist')
> >  
> > -if True:
> > +with profiling.maybeprofile(ui):
> >  repo = None
> >  cmdpats = args[:]
> >  if not _cmdattr(ui, cmd, func, 'norepo'):
> 
> Any reason to not remove maybeprofile() from _runcommand() ? Can it be 
> enabled
> after reposetup() ?
> 
> Yes, if it is configured in the repo-specific settings (.hg/hgrc), for 
> example, then it would be missed if
> maybeprofile were removed from _runcommand().

.hg/hgrc should be loaded to 'lui'. Can you check if maybeprofile(lui) works?

> Additionally, we’d need to wrap other callsites of
> _runcommand(), such as _checkshellalias(), to maintain the existing behavior.

Good point. Given that we want to start profiling as early as possible, I think
it's better to test profiling.enabled before extensions.loadall(lui), and test
it again after parsing command options.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 5] gitweb: remove unused template "changelogchild"

2016-09-21 Thread Anton Shestakov
# HG changeset patch
# User Anton Shestakov 
# Date 1474461346 -28800
#  Wed Sep 21 20:35:46 2016 +0800
# Node ID 8e374684fdd1f5ff9ba92ad39c0e61bba813f9df
# Parent  4745840178853f07f186762d984a6ea53189be07
gitweb: remove unused template "changelogchild"

diff --git a/mercurial/templates/gitweb/map b/mercurial/templates/gitweb/map
--- a/mercurial/templates/gitweb/map
+++ b/mercurial/templates/gitweb/map
@@ -182,11 +182,6 @@ fileannotateparent = '
   
 
   '
-changelogchild = '
-  
-child {rev}:
-{node|short}
-  '
 changesetchild = '
   
 child {rev}
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 5] monoblue: tweak branch table's last row's cell colspan on summary page

2016-09-21 Thread Anton Shestakov
# HG changeset patch
# User Anton Shestakov 
# Date 1474460375 -28800
#  Wed Sep 21 20:19:35 2016 +0800
# Node ID 4745840178853f07f186762d984a6ea53189be07
# Parent  bfa565cda4197eb67186cf25957b4712ecaa73d1
monoblue: tweak branch table's last row's cell colspan on summary page

This table only has 3 columns, so max sensible colspan is 3.

diff --git a/mercurial/templates/monoblue/summary.tmpl 
b/mercurial/templates/monoblue/summary.tmpl
--- a/mercurial/templates/monoblue/summary.tmpl
+++ b/mercurial/templates/monoblue/summary.tmpl
@@ -71,7 +71,7 @@
 
 {branches%branchentry}
 
-  ...
+  ...
 
 
 {footer}
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 17 of 17] tests: favor single quotes for wrapping hg help

2016-09-21 Thread Martin von Zweigbergk via Mercurial-devel
I have a version of this series locally with some cleanups that I talked to
timeless about on IRC. I feel asleep before tests had finished running, but
I'll do your version of it and replace it by mine when I get to work in a
few hours. Sorry, should have at least remembered to update this thread
yesterday.

On Wed, Sep 21, 2016, 04:29 Pierre-Yves David <
pierre-yves.da...@ens-lyon.org> wrote:

> On 09/21/2016 02:19 AM, timeless wrote:
> > # HG changeset patch
> > # User timeless 
> > # Date 1474415360 0
> > #  Tue Sep 20 23:49:20 2016 +
> > # Node ID 07306ec6e0c4e0accdaf3efee348361f36910295
> > # Parent  0f8eca5689fad5be2cef54141c8185b8bd5639f3
> > # Available At https://bitbucket.org/timeless/mercurial-crew
> > #  hg pull https://bitbucket.org/timeless/mercurial-crew -r
> 07306ec6e0c4
> > tests: favor single quotes for wrapping hg help ...
>
> Pushed this, Thanks for the extensive clean up.
>
> Cheers,
>
> --
> Pierre-Yves David
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 7] manifest: use specific opener to avoid file stat ambiguity around truncation

2016-09-21 Thread Pierre-Yves David



On 09/21/2016 08:57 AM, FUJIWARA Katsunori wrote:

At Tue, 20 Sep 2016 18:14:32 +0200,
Pierre-Yves David wrote:


On 09/16/2016 10:51 PM, FUJIWARA Katsunori wrote:

# HG changeset patch
# User FUJIWARA Katsunori 
# Date 1474057496 -32400
#  Sat Sep 17 05:24:56 2016 +0900
# Node ID 55bd90d63ad3a76fd4d27d5eabb3fe9a7fa0642b
# Parent  71b6b49f8a7ab6c894028b9153290f4bbf0f54f6
manifest: use specific opener to avoid file stat ambiguity around truncation

If steps below occurs at "the same time in sec", all of mtime, ctime
and size are same between (1) and (3).

  1. append data to 00manifest.i (and close transaction)
  2. discard appended data by truncation (strip or rollback)
  3. append same size but different data to 00manifest.i again

Therefore, cache validation doesn't work after (3) as expected.

To avoid such file stat ambiguity around truncation, this patch uses
specific opener, which forces checkambig=True at writing 00manifest.i
changes out.

Hooking vfs.__call__() is the only way to centralize changes into
manifest.py, because all logic to actually write in-memory changes out
is implemented in revlog layer.

In fact, reusing already wrapped self.opener for dirlogcache entries
like as below is a little redundant, because storecache-ed properties
of localrepository doesn't refer file stat of non-root 00manifest.i
files (= ambiguity of such files doesn't cause any issue).

if dir not in self._dirlogcache:
self._dirlogcache[dir] = manifestrevlog(self.opener, dir,
self._dirlogcache)

But wrapped opener never checks ambiguity of file stat for non-root
00manifest.i files, because "path == '00manifest.i'" condition in
wrapper.__call__() is always False for such files. Therefore, this
patch simply reuses wrapped self.opener for non-root 00manifest.i
files.

Even after this patch, avoiding file stat ambiguity of 00manifest.i
around truncation isn't yet completed, because truncation side isn't
aware of this issue.

This is a part of ExactCacheValidationPlan.

https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -892,6 +892,28 @@ class treemanifest(object):
 subp1, subp2 = subp2, subp1
 writesubtree(subm, subp1, subp2)

+def _checkambigopener(opener):
+"""build an opener to add checkambig=True at changing 00manifest.i
+"""
+class wrapper(opener.__class__):
+def __call__(self, path, mode="r", text=False, atomictemp=False,
+ notindexed=False, backgroundclose=False, checkambig=False,
+  **kwargs):
+if path == '00manifest.i' and mode not in ('r', 'rb'):
+# check file stat ambiguity at closing forcibly
+checkambig = True
+supercall = super(wrapper, self).__call__
+return supercall(path, mode,
+ text=text,
+ atomictemp=atomictemp,
+ notindexed=notindexed,
+ backgroundclose=backgroundclose,
+ checkambig=checkambig,
+ **kwargs)
+opener.__class__ = wrapper


This wrapper logic is a bit scary here. Could we  had the necessary
minimal hooks in revlog to allow manifest and changelog to hooks in ?
That would seems more robust/clean than wrapping core from core.


How about adding optional argument "checkambig" to revlog.__init__(),
of which default value is False ?\


Given that multiple subclass uses it it seems to make sense to go this 
way. It seems simple enough. The revlog class has other small 'extension 
point' for subclass so there is precedence.


Cheers,

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


Re: [PATCH 2 of 5] tests: clarify demandimport disabled state

2016-09-21 Thread Pierre-Yves David

On 09/21/2016 05:59 AM, timeless wrote:

# HG changeset patch
# User timeless 
# Date 1474429177 0
#  Wed Sep 21 03:39:37 2016 +
# Node ID 982fe7cdb28bb263a96b1bc2c9c3b8aedb025ab6
# Parent  24d85146985b7d2fef3c27b97d4be983e57ae5c7
# Available At https://bitbucket.org/timeless/mercurial-crew
#  hg pull https://bitbucket.org/timeless/mercurial-crew -r 
982fe7cdb28b
tests: clarify demandimport disabled state


I've pushed the first two as obviously correct. Can you add some longer 
description and docstring to the other 3 so that I can get a grasp of 
what is going on.


Cheers,

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


Re: [PATCH] templates: add built-in fileset() function

2016-09-21 Thread FUJIWARA Katsunori
At Tue, 20 Sep 2016 15:57:41 +,
Hannes Oldenburg wrote:
> 
> # HG changeset patch
> # User Hannes Oldenburg 
> # Date 1474379333 0
> #  Tue Sep 20 13:48:53 2016 +
> # Node ID cf2156395bff0e3fc4a6604b8aa45b5b7829ba98
> # Parent  285a8c3e53f2183438f0cdbc238e4ab851d0d110
> templates: add built-in fileset() function
> 
> We already support multiple primitive for listing files, which were
> affected by the current changeset.
> This patch adds fileset() which runs a fileset query with the current
> changeset.
> 
> diff -r 285a8c3e53f2 -r cf2156395bff mercurial/help/templates.txt
> --- a/mercurial/help/templates.txtTue May 03 13:36:12 2016 +0900
> +++ b/mercurial/help/templates.txtTue Sep 20 13:48:53 2016 +
> @@ -95,6 +95,10 @@
>  
> $ hg log -r 0 --template "files: {join(files, ', ')}\n"
>  
> +- Join the list of files with .py ending Filesets
> +
> +   $ hg log -r 0 --template "pythonfiles: {join(fileset('**.py'), ', ')}\n"
> +
>  - Separate non-empty arguments by a " "::
>  
> $ hg log -r 0 --template "{separate(' ', node, bookmarks, tags}\n"
> diff -r 285a8c3e53f2 -r cf2156395bff mercurial/templater.py
> --- a/mercurial/templater.py  Tue May 03 13:36:12 2016 +0900
> +++ b/mercurial/templater.py  Tue Sep 20 13:48:53 2016 +
> @@ -699,6 +699,24 @@
>  tzoffset = util.makedate()[1]
>  return (date[0], tzoffset)
>  
> +@templatefunc('fileset(query)')
> +def fileset(context, mapping, args):
> +"""Execute a fileset set query with the current changeset. See
> +:hg:`help fileset`."""
> +if not len(args) == 1:
> +# i18n: "revset" is a keyword

nitpicking: "fileset" is a keyword

> +raise error.ParseError(_("fileset expects no arguments"))
> +
> +raw = evalstring(context, mapping, args[0])
> +ctx = mapping['ctx']
> +filesetcache = mapping['cache'].setdefault("filesetcache", {})
> +if raw in filesetcache:
> +files  = filesetcache[raw]
> +else:
> +files = ctx.getfileset(raw)
> +filesetcache[raw] = files

fileset query should be evaluated for each templated changesets, but
mapping['cache'] is shared between those changesets.

Therefore, fileset() template function returns unexpected result for
the second or later changesets in templating.

IMHO, 'revcache' instead of 'cache' seems appropriate for this
purpose.

> +return templatekw.showlist("file", files, **mapping)
> +
>  @templatefunc('revset(query[, formatargs...])')
>  def revset(context, mapping, args):
>  """Execute a revision set query. See
> diff -r 285a8c3e53f2 -r cf2156395bff tests/test-command-template.t
> --- a/tests/test-command-template.t   Tue May 03 13:36:12 2016 +0900
> +++ b/tests/test-command-template.t   Tue Sep 20 13:48:53 2016 +
> @@ -3501,6 +3501,12 @@
>5:13207e5a10d9fd28ec424934298e176197f2c67f,
>4:bbe44766e73d5f11ed2177f1838de10c53ef3e74
>  
> +Test fileset function
> +
> +  $ hg log -r 0 -T "{rev}\n{join(fileset('*'), '\n')}\n"
> +  0
> +  a

Applying fileset query on all templated changesets is useful to detect
unintentional behavior described before.

For example, if template "{rev}\n{join(fileset('*'), '\n')}\n" is
applied in this test context, expected result is:

   2
   a
   aa
   b
   1
   a
   0
   a

but sharing the result of fileset query between changesets causes:

   2
   a
   aa
   b
   1
   a
   aa
   b
   0
   a
   aa
   b

>  Test active bookmark templating
>  
>$ hg book foo
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

--
[FUJIWARA Katsunori] fo...@lares.dti.ne.jp
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 7] manifest: use specific opener to avoid file stat ambiguity around truncation

2016-09-21 Thread FUJIWARA Katsunori
At Tue, 20 Sep 2016 18:14:32 +0200,
Pierre-Yves David wrote:
> 
> On 09/16/2016 10:51 PM, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori 
> > # Date 1474057496 -32400
> > #  Sat Sep 17 05:24:56 2016 +0900
> > # Node ID 55bd90d63ad3a76fd4d27d5eabb3fe9a7fa0642b
> > # Parent  71b6b49f8a7ab6c894028b9153290f4bbf0f54f6
> > manifest: use specific opener to avoid file stat ambiguity around truncation
> >
> > If steps below occurs at "the same time in sec", all of mtime, ctime
> > and size are same between (1) and (3).
> >
> >   1. append data to 00manifest.i (and close transaction)
> >   2. discard appended data by truncation (strip or rollback)
> >   3. append same size but different data to 00manifest.i again
> >
> > Therefore, cache validation doesn't work after (3) as expected.
> >
> > To avoid such file stat ambiguity around truncation, this patch uses
> > specific opener, which forces checkambig=True at writing 00manifest.i
> > changes out.
> >
> > Hooking vfs.__call__() is the only way to centralize changes into
> > manifest.py, because all logic to actually write in-memory changes out
> > is implemented in revlog layer.
> >
> > In fact, reusing already wrapped self.opener for dirlogcache entries
> > like as below is a little redundant, because storecache-ed properties
> > of localrepository doesn't refer file stat of non-root 00manifest.i
> > files (= ambiguity of such files doesn't cause any issue).
> >
> > if dir not in self._dirlogcache:
> > self._dirlogcache[dir] = manifestrevlog(self.opener, dir,
> > self._dirlogcache)
> >
> > But wrapped opener never checks ambiguity of file stat for non-root
> > 00manifest.i files, because "path == '00manifest.i'" condition in
> > wrapper.__call__() is always False for such files. Therefore, this
> > patch simply reuses wrapped self.opener for non-root 00manifest.i
> > files.
> >
> > Even after this patch, avoiding file stat ambiguity of 00manifest.i
> > around truncation isn't yet completed, because truncation side isn't
> > aware of this issue.
> >
> > This is a part of ExactCacheValidationPlan.
> >
> > https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
> >
> > diff --git a/mercurial/manifest.py b/mercurial/manifest.py
> > --- a/mercurial/manifest.py
> > +++ b/mercurial/manifest.py
> > @@ -892,6 +892,28 @@ class treemanifest(object):
> >  subp1, subp2 = subp2, subp1
> >  writesubtree(subm, subp1, subp2)
> >
> > +def _checkambigopener(opener):
> > +"""build an opener to add checkambig=True at changing 00manifest.i
> > +"""
> > +class wrapper(opener.__class__):
> > +def __call__(self, path, mode="r", text=False, atomictemp=False,
> > + notindexed=False, backgroundclose=False, 
> > checkambig=False,
> > +  **kwargs):
> > +if path == '00manifest.i' and mode not in ('r', 'rb'):
> > +# check file stat ambiguity at closing forcibly
> > +checkambig = True
> > +supercall = super(wrapper, self).__call__
> > +return supercall(path, mode,
> > + text=text,
> > + atomictemp=atomictemp,
> > + notindexed=notindexed,
> > + backgroundclose=backgroundclose,
> > + checkambig=checkambig,
> > + **kwargs)
> > +opener.__class__ = wrapper
> 
> This wrapper logic is a bit scary here. Could we  had the necessary 
> minimal hooks in revlog to allow manifest and changelog to hooks in ? 
> That would seems more robust/clean than wrapping core from core.

How about adding optional argument "checkambig" to revlog.__init__(),
of which default value is False ?


> > +
> > +return opener
> > +
> >  class manifestrevlog(revlog.revlog):
> >  '''A revlog that stores manifest texts. This is responsible for 
> > caching the
> >  full-text manifest contents.
> > @@ -927,6 +949,13 @@ class manifestrevlog(revlog.revlog):
> >  else:
> >  self._dirlogcache = {'': self}
> >
> > +# If "dir" isn't empty, this "opener" is reused one via
> > +# "self.opener" of another manifestrevlog. Therefore,
> > +# wrapping opener is needed only at once for root
> > +# 00manifest.i file, to avoid multiple (= redundant)
> > +# wrapping.
> > +opener = _checkambigopener(opener)
> > +
> >  super(manifestrevlog, self).__init__(opener, indexfile)
> >
> >  @property
> > ___
> > Mercurial-devel mailing list
> > Mercurial-devel@mercurial-scm.org
> > https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
> >
> 
> -- 
> Pierre-Yves David
> 


Re: [PATCH 3 of 7] vfs: use checkambigatclosing in checkambig=True but atomictemp=False case

2016-09-21 Thread FUJIWARA Katsunori

At Tue, 20 Sep 2016 18:12:58 +0200,
Pierre-Yves David wrote:
> 
> On 09/16/2016 10:51 PM, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori 
> > # Date 1474057495 -32400
> > #  Sat Sep 17 05:24:55 2016 +0900
> > # Node ID 71b6b49f8a7ab6c894028b9153290f4bbf0f54f6
> > # Parent  ad999fb789fcb86b11c98334ab98b31a17ee2d25
> > vfs: use checkambigatclosing in checkambig=True but atomictemp=False case
> >
> > In Mercurial source tree, opening a file in "a"/"a+" mode like below
> > doesn't specify atomictemp=True for vfs, and this avoids file stat
> > ambiguity check by atomictempfile.
> >
> >   - writing changes out in revlog layer uses "a+" mode
> >   - truncation in repair.strip() uses "a" mode
> >   - truncation in transaction._playback() uses "a" mode
> >
> > If steps below occurs at "the same time in sec", all of mtime, ctime
> > and size are same between (1) and (3).
> >
> >   1. append data to revlog-style file (and close transaction)
> >   2. discard appended data by truncation (strip or rollback)
> >   3. append same size but different data to revlog-style file again
> >
> > Therefore, cache validation doesn't work after (3) as expected.
> >
> > This patch uses checkambigatclosing in checkambig=True but
> > atomictemp=False case, to check (and get rid of) file stat ambiguity
> > at closing.
> >
> > This is a part of ExactCacheValidationPlan.
> >
> > https://www.mercurial-scm.org/wiki/ExactCacheValidationPlan
> >
> > diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
> > --- a/mercurial/scmutil.py
> > +++ b/mercurial/scmutil.py
> > @@ -587,6 +587,10 @@ class vfs(abstractvfs):
> >  if nlink == 0:
> >  self._fixfilemode(f)
> >
> > +if checkambig:
> > +assert mode not in ('r', 'rb'), "valid only at writing"
> > +fp = checkambigatclosing(fp)
> 
> It sound a bit too much like a real logic check with assert. Instead we 
> should probably either:
> - have a hard check with an abort.
> - ignore the bad state with a devel warning (probably the best).

OK, I'll send revised one with the latter.


> Cheers,
> 
> -- 
> Pierre-Yves David
> 

--
[FUJIWARA Katsunori] fo...@lares.dti.ne.jp
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel