[PATCH] run-tests: disable color on Windows

2017-07-14 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1500094356 14400
#  Sat Jul 15 00:52:36 2017 -0400
# Node ID 00e59d5ca0a7c5610695250a7955615ef49138ee
# Parent  c2549b5ffd77029d78ef92d8fb5cd5b5bdbbb254
run-tests: disable color on Windows

More Windows sadness.  Maybe someone can figure out how to make win32 color
work, but I think we avoid importing stuff from the mercurial package in this
module.  On the plus side, this conditionalizes away a test failure.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -89,13 +89,16 @@
 processlock = threading.Lock()
 
 with_color = False
-try: # is pygments installed
-import pygments
-import pygments.lexers as lexers
-import pygments.formatters as formatters
-with_color = True
-except ImportError:
-pass
+
+# ANSI color is unsupported prior to Windows 10
+if os.name != 'nt':
+try: # is pygments installed
+import pygments
+import pygments.lexers as lexers
+import pygments.formatters as formatters
+with_color = True
+except ImportError:
+pass
 
 if not sys.stderr.isatty(): # check if the terminal is capable
 with_color = False
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -121,6 +121,7 @@
 
 test diff colorisation
 
+#if no-windows
   $ rt test-failure.t --color always
   
   \x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc)
@@ -155,6 +156,7 @@
   Failed test-failure.t: output changed
   # Ran 1 tests, 0 skipped, 1 failed.
   python hash seed: * (glob)
+#endif
 
 basic failing test
   $ cat > test-failure.t << EOF
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH V2] context: name files relative to cwd in warning messages

2017-07-14 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1499748029 14400
#  Tue Jul 11 00:40:29 2017 -0400
# Node ID c2549b5ffd77029d78ef92d8fb5cd5b5bdbbb254
# Parent  0407a51b9d8c3ade36b6495f44897c7a70e20975
context: name files relative to cwd in warning messages

I was several directories deep in the kernel tree, ran `hg add`, and got the
warning about the size of one of the files.  I noticed that it suggested undoing
the add with a specific revert command.  The problem is, it would have failed
since the path printed was relative to the repo root instead of cwd.  While
here, I just fixed the other messages too.  As an added benefit, these messages
now look the same as the verbose/inexact messages for the corresponding command.

I don't think most of these messages are reachable (typically the corresponding
cmdutil function does the check).  I wasn't able to figure out why the keyword
tests were failing when using pathto()- I couldn't cause an absolute path to be
used by manipulating the --cwd flag on a regular add.  (I did notice that
keyword is adding the file without holding wlock.)

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -33,6 +33,7 @@
 mdiff,
 obsolete as obsmod,
 patch,
+pathutil,
 phases,
 pycompat,
 repoview,
@@ -1518,17 +1519,20 @@
 (missing and self.deleted()))
 
 def add(self, list, prefix=""):
-join = lambda f: os.path.join(prefix, f)
 with self._repo.wlock():
 ui, ds = self._repo.ui, self._repo.dirstate
+uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
 rejected = []
 lstat = self._repo.wvfs.lstat
 for f in list:
-scmutil.checkportable(ui, join(f))
+# ds.pathto() returns an absolute file when this is invoked 
from
+# the keyword extension.  That gets flagged as non-portable on
+# Windows, since it contains the drive letter and colon.
+scmutil.checkportable(ui, os.path.join(prefix, f))
 try:
 st = lstat(f)
 except OSError:
-ui.warn(_("%s does not exist!\n") % join(f))
+ui.warn(_("%s does not exist!\n") % uipath(f))
 rejected.append(f)
 continue
 if st.st_size > 1000:
@@ -1536,13 +1540,13 @@
   "to manage this file\n"
   "(use 'hg revert %s' to cancel the "
   "pending addition)\n")
-  % (f, 3 * st.st_size // 100, join(f)))
+  % (f, 3 * st.st_size // 100, uipath(f)))
 if not (stat.S_ISREG(st.st_mode) or stat.S_ISLNK(st.st_mode)):
 ui.warn(_("%s not added: only files and symlinks "
-  "supported currently\n") % join(f))
+  "supported currently\n") % uipath(f))
 rejected.append(f)
 elif ds[f] in 'amn':
-ui.warn(_("%s already tracked!\n") % join(f))
+ui.warn(_("%s already tracked!\n") % uipath(f))
 elif ds[f] == 'r':
 ds.normallookup(f)
 else:
@@ -1550,12 +1554,13 @@
 return rejected
 
 def forget(self, files, prefix=""):
-join = lambda f: os.path.join(prefix, f)
 with self._repo.wlock():
+ds = self._repo.dirstate
+uipath = lambda f: ds.pathto(pathutil.join(prefix, f))
 rejected = []
 for f in files:
 if f not in self._repo.dirstate:
-self._repo.ui.warn(_("%s not tracked!\n") % join(f))
+self._repo.ui.warn(_("%s not tracked!\n") % uipath(f))
 rejected.append(f)
 elif self._repo.dirstate[f] != 'a':
 self._repo.dirstate.remove(f)
@@ -1566,9 +1571,10 @@
 def undelete(self, list):
 pctxs = self.parents()
 with self._repo.wlock():
+ds = self._repo.dirstate
 for f in list:
 if self._repo.dirstate[f] != 'r':
-self._repo.ui.warn(_("%s not removed!\n") % f)
+self._repo.ui.warn(_("%s not removed!\n") % ds.pathto(f))
 else:
 fctx = f in pctxs[0] and pctxs[0][f] or pctxs[1][f]
 t = fctx.data()
@@ -1581,11 +1587,13 @@
 except OSError as err:
 if err.errno != errno.ENOENT:
 raise
-self._repo.ui.warn(_("%s does not exist!\n") % dest)
+self._repo.ui.warn(_("%s does not exist!\n")
+   % self._repo.dirstate.pathto(dest))
 return
 if not 

Re: [PATCH 2 of 2] commandserver: use selector2

2017-07-14 Thread Jun Wu
Excerpts from Yuya Nishihara's message of 2017-07-15 12:37:39 +0900:
> On Fri, 14 Jul 2017 20:27:27 -0700, Jun Wu wrote:
> > # HG changeset patch
> > # User Jun Wu 
> > # Date 1500089181 25200
> > #  Fri Jul 14 20:26:21 2017 -0700
> > # Node ID a6545c15171810059596259f60574011184c3412
> > # Parent  5664763de82b48ca6882bbb624d01d467b4920d0
> > # Available At https://bitbucket.org/quark-zju/hg-draft 
> > #  hg pull https://bitbucket.org/quark-zju/hg-draft  -r 
> > a6545c151718
> > commandserver: use selector2
> > 
> > Previously, commandserver was using select.select. That could have issue if
> > _sock.fileno() >= FD_SETSIZE (usually 1024), which raises:
> > 
> >   ValueError: filedescriptor out of range in select()
> 
> Can we get around it without vendoring selector2, by using poll() for example?

poll is not available on OS X, which we need to support.

I tried to write some lightweight wrapper around them, then discovered I
was basically reinventing things. SocketServer has too many issues and is
over complicated for our usecase, but the Python 3 "selectors" interface
looks not that bad. So I think it's okay to reuse a mature library.

If it still looks too complicated, I think we can remove some selectors,
like removing JythonSelectSelector, epoll, devpoll.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@33479: 3 new changesets

2017-07-14 Thread Mercurial Commits
3 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/cc4632679cf9
changeset:   33477:cc4632679cf9
user:Martin von Zweigbergk 
date:Fri Jul 14 10:48:08 2017 -0700
summary: tests: fix an incorrect description in test-ignore.t

https://www.mercurial-scm.org/repo/hg/rev/cf15c3cc304c
changeset:   33478:cf15c3cc304c
user:Durham Goode 
date:Fri Jul 14 10:57:36 2017 -0700
summary: match: make base matcher return True for visitdir

https://www.mercurial-scm.org/repo/hg/rev/8b48dad66be4
changeset:   33479:8b48dad66be4
bookmark:@
tag: tip
user:Jun Wu 
date:Sat Jun 03 21:56:23 2017 -0700
summary: obsstore: keep self._data updated with _addmarkers

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


[Differential] [Closed] D83: match: make base matcher return True for visitdir

2017-07-14 Thread durham (Durham Goode)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcf15c3cc304c: match: make base matcher return True for 
visitdir (authored by durham).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D83?vs=149=175

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

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

Index: mercurial/match.py
===
--- mercurial/match.py
+++ mercurial/match.py
@@ -305,7 +305,7 @@
 This function's behavior is undefined if it has returned False for
 one of the dir's parent directories.
 '''
-return False
+return True
 
 def always(self):
 '''Matcher will match everything and .files() will be empty --


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Closed] D82: tests: fix an incorrect description in test-ignore.t

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGcc4632679cf9: tests: fix an incorrect description in 
test-ignore.t (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D82?vs=148=174

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

AFFECTED FILES
  tests/test-hgignore.t

CHANGE DETAILS

Index: tests/test-hgignore.t
===
--- tests/test-hgignore.t
+++ tests/test-hgignore.t
@@ -82,7 +82,7 @@
   $ rm 'baz\#wat'
 #endif
 
-Check it does not ignore the current directory '.':
+Check that '^\.' does not ignore the root directory:
 
   $ echo "^\." > .hgignore
   $ hg status


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH] templates: add substring and string length operations

2017-07-14 Thread Martin von Zweigbergk via Mercurial-devel
On Jul 14, 2017 8:19 PM, "Yuya Nishihara"  wrote:

On Fri, 14 Jul 2017 19:50:34 -0700, Rodrigo Damazio wrote:
> > On Fri, 14 Jul 2017 16:27:49 -0700, Rodrigo Damazio via Mercurial-devel
> > > +@templatefunc('substr(text, start[, end])')
> >
> > I think substr() generally takes offset and length, not start:end range.
>
> Yes, I considered that the start:end (like Python has) was more powerful
> because it allows negative numbers to reference the end, whereas offset
and
> length needs to be calculated in those cases. Would you like me to switch?

start and offset can be negative anyway, though length can't. The name
'substr()' seems confusing if it takes start:end. Can you find another name
or switch it to take length?


Maybe Python calls it slicing? So slice() might be okay.

___
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 2 of 2] commandserver: use selector2

2017-07-14 Thread Yuya Nishihara
On Fri, 14 Jul 2017 20:27:27 -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1500089181 25200
> #  Fri Jul 14 20:26:21 2017 -0700
> # Node ID a6545c15171810059596259f60574011184c3412
> # Parent  5664763de82b48ca6882bbb624d01d467b4920d0
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #  hg pull https://bitbucket.org/quark-zju/hg-draft -r 
> a6545c151718
> commandserver: use selector2
> 
> Previously, commandserver was using select.select. That could have issue if
> _sock.fileno() >= FD_SETSIZE (usually 1024), which raises:
> 
>   ValueError: filedescriptor out of range in select()

Can we get around it without vendoring selector2, by using poll() for example?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [POLL] Mass renaming options for consistency + guidelines

2017-07-14 Thread Yuya Nishihara
On Fri, 14 Jul 2017 11:33:29 -0400, Augie Fackler wrote:
> 
> > On Jul 13, 2017, at 11:53, David Demelier  wrote:
> > 
> > Le 13 juil. 2017 5:37 PM, "Augie Fackler"  a écrit :
> > 
> > > On Jul 13, 2017, at 05:15, David Demelier  
> > > wrote:
> > >
> > > Hello,
> > >
> > > I'm one of the creator of the ConfigConsolidationPlan [0].
> > >
> > > In Mercurial there was a big issue regarding the options continuously 
> > > added without any guideline into the hgrc file. This leads to massive 
> > > inconsistency like :
> > >
> > >allowpull
> > >allow_push
> > >assume-tty
> > >
> > > In the process of renaming those options without breaking existing user 
> > > installations, we have added a configitems registry + aliases. The 
> > > aliases offers a way to select the same option with a different section 
> > > name (e.g. ui.username also search for ui.user).
> > >
> > > I'll start renaming options once a convention has been chosen correctly, 
> > > I've proposed (seconded by Pierre-Yves) to use hyphens between words as 
> > > it's common in projects [2].
> > 
> > When you say "renaming" you just mean renaming the documented name of the 
> > option, but still respecting the legacy name, right?
> > 
> > 
> > Yes, exactly.
> 
> Dashes seem like the only good choice to me, usability-wise.

I prefer not doing mass renaming that would generate lots of "deprecated"
config names in use around user hgrc and web documents. But if I had to
choose one, I would vote for dashes/hyphens.

FWIW, many of the existing config names are readable for me, even though
I'm not German.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 2] commandserver: use selector2

2017-07-14 Thread Jun Wu
# HG changeset patch
# User Jun Wu 
# Date 1500089181 25200
#  Fri Jul 14 20:26:21 2017 -0700
# Node ID a6545c15171810059596259f60574011184c3412
# Parent  5664763de82b48ca6882bbb624d01d467b4920d0
# Available At https://bitbucket.org/quark-zju/hg-draft
#  hg pull https://bitbucket.org/quark-zju/hg-draft -r a6545c151718
commandserver: use selector2

Previously, commandserver was using select.select. That could have issue if
_sock.fileno() >= FD_SETSIZE (usually 1024), which raises:

  ValueError: filedescriptor out of range in select()

We got that in production today, although it's the code opening that many
files to blame, it seems better for commandserver to work in this case.
There are multiple way to "solve" it, like preserving a fd with a small
number and swap it with sock using dup2(). But upgrading to a modern
selector supported by the system seems to be the most correct way.

diff --git a/mercurial/commandserver.py b/mercurial/commandserver.py
--- a/mercurial/commandserver.py
+++ b/mercurial/commandserver.py
@@ -23,4 +23,5 @@ from . import (
 error,
 pycompat,
+selectors2,
 util,
 )
@@ -477,4 +478,6 @@ class unixforkingservice(object):
 exiting = False
 h = self._servicehandler
+selector = selectors2.DefaultSelector()
+selector.register(self._sock, selectors2.EVENT_READ)
 while True:
 if not exiting and h.shouldexit():
@@ -487,5 +490,5 @@ class unixforkingservice(object):
 exiting = True
 try:
-ready = select.select([self._sock], [], [], h.pollinterval)[0]
+ready = selector.select(timeout=h.pollinterval)
 if not ready:
 # only exit if we completed all queued requests
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] selector2: vendor selector2 library

2017-07-14 Thread Jun Wu
# HG changeset patch
# User Jun Wu 
# Date 1500088786 25200
#  Fri Jul 14 20:19:46 2017 -0700
# Node ID 5664763de82b48ca6882bbb624d01d467b4920d0
# Parent  0407a51b9d8c3ade36b6495f44897c7a70e20975
# Available At https://bitbucket.org/quark-zju/hg-draft
#  hg pull https://bitbucket.org/quark-zju/hg-draft -r 5664763de82b
selector2: vendor selector2 library

This library was a backport of the Python 3 "selectors" library. It is
useful to provide a better selector interface for Python2, to address some
issues of the plain old select.select, mentioned in the next patch.

The code [1] was ported using the MIT license, with some minor modifications
to make our test happy:

  1. "# no-check-code" was added since it's foreign code.
  2. "from __future__ import absolute_import" was added.
  3. "from collections import namedtuple, Mapping" changed to avoid direct
 symbol import.

[1]: 
https://github.com/SethMichaelLarson/selectors2/blob/d27dbd2fdc48331fb76ed431f44b6e6956de7f82/selectors2.py

diff --git a/mercurial/selectors2.py b/mercurial/selectors2.py
new file mode 100644
--- /dev/null
+++ b/mercurial/selectors2.py
@@ -0,0 +1,744 @@
+""" Back-ported, durable, and portable selectors """
+
+# MIT License
+#
+# Copyright (c) 2017 Seth Michael Larson
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in 
all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# no-check-code
+
+from __future__ import absolute_import
+
+import collections
+import errno
+import math
+import platform
+import select
+import socket
+import sys
+import time
+
+namedtuple = collections.namedtuple
+Mapping = collections.Mapping
+
+try:
+monotonic = time.monotonic
+except AttributeError:
+monotonic = time.time
+
+__author__ = 'Seth Michael Larson'
+__email__ = 'sethmichaellar...@protonmail.com'
+__version__ = '2.0.0'
+__license__ = 'MIT'
+__url__ = 'https://www.github.com/SethMichaelLarson/selectors2'
+
+__all__ = ['EVENT_READ',
+   'EVENT_WRITE',
+   'SelectorKey',
+   'DefaultSelector',
+   'BaseSelector']
+
+EVENT_READ = (1 << 0)
+EVENT_WRITE = (1 << 1)
+_DEFAULT_SELECTOR = None
+_SYSCALL_SENTINEL = object()  # Sentinel in case a system call returns None.
+_ERROR_TYPES = (OSError, IOError, socket.error)
+
+
+SelectorKey = namedtuple('SelectorKey', ['fileobj', 'fd', 'events', 'data'])
+
+
+class _SelectorMapping(Mapping):
+""" Mapping of file objects to selector keys """
+
+def __init__(self, selector):
+self._selector = selector
+
+def __len__(self):
+return len(self._selector._fd_to_key)
+
+def __getitem__(self, fileobj):
+try:
+fd = self._selector._fileobj_lookup(fileobj)
+return self._selector._fd_to_key[fd]
+except KeyError:
+raise KeyError("{0!r} is not registered.".format(fileobj))
+
+def __iter__(self):
+return iter(self._selector._fd_to_key)
+
+
+def _fileobj_to_fd(fileobj):
+""" Return a file descriptor from a file object. If
+given an integer will simply return that integer back. """
+if isinstance(fileobj, int):
+fd = fileobj
+else:
+try:
+fd = int(fileobj.fileno())
+except (AttributeError, TypeError, ValueError):
+raise ValueError("Invalid file object: {0!r}".format(fileobj))
+if fd < 0:
+raise ValueError("Invalid file descriptor: {0}".format(fd))
+return fd
+
+
+class BaseSelector(object):
+""" Abstract Selector class
+
+A selector supports registering file objects to be monitored
+for specific I/O events.
+
+A file object is a file descriptor or any object with a
+`fileno()` method. An arbitrary object can be attached to the
+file object which can be used for example to store context info,
+a callback, etc.
+
+A selector can use various implementations (select(), poll(), epoll(),
+and kqueue()) depending on the platform. The 'DefaultSelector' class uses
+the most efficient implementation for 

Re: [PATCH] templates: add substring and string length operations

2017-07-14 Thread Rodrigo Damazio via Mercurial-devel
Thanks for the review.
We're seeing some weirdness in our script to use gmail's backends directly
- I sent v2 but it apparently never got to the list, so I'll probably try
to switch to Phabricator for v2/v3.

On Fri, Jul 14, 2017 at 7:27 PM, Yuya Nishihara  wrote:

> On Fri, 14 Jul 2017 16:27:49 -0700, Rodrigo Damazio via Mercurial-devel
> wrote:
> > On Fri, Jul 14, 2017 at 3:48 PM, Rodrigo Damazio Bovendorp <
> > rdama...@google.com> wrote:
> > > # HG changeset patch
> > > # User Rodrigo Damazio Bovendorp 
> > > # Date 1500072378 25200
> > > #  Fri Jul 14 15:46:18 2017 -0700
> > > # Node ID 0ccebbd04efbd672fc71df7f52ec243057cbed7d
> > > # Parent  c0d8de2724ce6240d2a4241aff78ce2ee92359c2
> > > templates: add substring and string length operations
>
> > > +@templatefilter('strlen')
> > > +def stringlen(text):
> > > +"""Any text. Turns the value into its length."""
> > > +return len(text)
>
> You can use "str|count" instead.
>

Ah, didn't see that one - I'll remove this then.

> > +@templatefunc('substr(text, start[, end])')
>
> I think substr() generally takes offset and length, not start:end range.
>

Yes, I considered that the start:end (like Python has) was more powerful
because it allows negative numbers to reference the end, whereas offset and
length needs to be calculated in those cases. Would you like me to switch?


smime.p7s
Description: S/MIME Cryptographic Signature
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH v3] releasenotes: add custom admonitions support for release notes

2017-07-14 Thread Yuya Nishihara
On Sun, 09 Jul 2017 19:04:33 +0200, Rishabh Madan wrote:
> # HG changeset patch
> # User Rishabh Madan 
> # Date 1499619850 -7200
> #  Sun Jul 09 19:04:10 2017 +0200
> # Node ID 5f22d3d43d36d46cea98c86b2a49eee2d323fd9e
> # Parent  4672db164c986da4442bd864cd044512d975c3f2
> releasenotes: add custom admonitions support for release notes

Do you have time to make V4 in this weekend? If you don't, I'll queue this
version as it seems good enough.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH V2] codemod: register core configitems using a script

2017-07-14 Thread Martin von Zweigbergk via Mercurial-devel
On Fri, Jul 14, 2017 at 2:23 PM, Jun Wu  wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1500067360 25200
> #  Fri Jul 14 14:22:40 2017 -0700
> # Node ID 4ba8b3e871116249d7a99062a08955446e896047
> # Parent  80e1331a7fe970f3e56fde9044949d72d3afdf30
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #  hg pull https://bitbucket.org/quark-zju/hg-draft -r 
> 4ba8b3e87111
> codemod: register core configitems using a script

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


Re: Community video chats?

2017-07-14 Thread Augie Fackler
Yes, that's right.

On Jul 14, 2017 7:40 PM, "Sean Farley"  wrote:

>
> Augie Fackler  writes:
>
> >> On Jul 13, 2017, at 04:17, Boris Feld  wrote:
> >>
> >> On Tue, 2017-07-11 at 16:08 -0400, Augie Fackler wrote:
>  On Jul 11, 2017, at 15:47, Phillip Cohen 
>  wrote:
> 
>  Great, glad there's interest.
> 
>  How would Thursday at 10am PST / 1pm EST  / 6pm UTC work? This is
>  early enough for London to join, but not too early that California
>  won't. Friday mornings are less desirable (because that's Friday
>  evening in London) but Monday and Tuesday morning could work as
>  well.
> >>>
> >>> I can't do 1300-1500 America/New_York on Thursdays. Pretty much any
> >>> other time in the week would work. Maybe shoot for Tuesdays?
> >>>
> >>
> >> I'm also interested, 6pm UTC (5pm or 7pm could works too) on every day
> >> except Tuesdays would works for me with a preference for Thursday.
> >
> > I've blocked off 1300-1430 America/New_York on the 19th for a test run
> of this.
>
> That's 10am-11:30am for us in San Francisco, right? If so, then I've
> also put this in my calendar.
>
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Community video chats?

2017-07-14 Thread Sean Farley

Augie Fackler  writes:

>> On Jul 13, 2017, at 04:17, Boris Feld  wrote:
>> 
>> On Tue, 2017-07-11 at 16:08 -0400, Augie Fackler wrote:
 On Jul 11, 2017, at 15:47, Phillip Cohen 
 wrote:
 
 Great, glad there's interest.
 
 How would Thursday at 10am PST / 1pm EST  / 6pm UTC work? This is
 early enough for London to join, but not too early that California
 won't. Friday mornings are less desirable (because that's Friday
 evening in London) but Monday and Tuesday morning could work as
 well.
>>> 
>>> I can't do 1300-1500 America/New_York on Thursdays. Pretty much any
>>> other time in the week would work. Maybe shoot for Tuesdays?
>>> 
>> 
>> I'm also interested, 6pm UTC (5pm or 7pm could works too) on every day
>> except Tuesdays would works for me with a preference for Thursday.
>
> I've blocked off 1300-1430 America/New_York on the 19th for a test run of 
> this.

That's 10am-11:30am for us in San Francisco, right? If so, then I've
also put this in my calendar.


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


Re: Experimenting with Phabricator for reviews

2017-07-14 Thread Sean Farley

Jun Wu  writes:

> Excerpts from Sean Farley's message of 2017-07-14 16:26:34 -0700:
>> Huh? But that's the thing, isn't it? Previously, comments about code
>> review are on the list. One can peruse them at leisure or archive /
>> skip, etc. What you're saying, if I'm not mistaken, is that some
>> comments (no matter the content) will no longer be on the list. That
>> makes perusing them now split into two locations.
>
> I think what I suggested is to move those emails to another list. So if
> people want to read them in an email client, they will still be able to.

Ah, yes, I was confused about your /dev/null comment. I see now; sorry
for the confusion.

Though, I'm not thrilled about the idea of another list but that's
another discussion.


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


Re: Experimenting with Phabricator for reviews

2017-07-14 Thread Jun Wu
Excerpts from Sean Farley's message of 2017-07-14 16:26:34 -0700:
> Huh? But that's the thing, isn't it? Previously, comments about code
> review are on the list. One can peruse them at leisure or archive /
> skip, etc. What you're saying, if I'm not mistaken, is that some
> comments (no matter the content) will no longer be on the list. That
> makes perusing them now split into two locations.

I think what I suggested is to move those emails to another list. So if
people want to read them in an email client, they will still be able to.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] templates: add substring and string length operations

2017-07-14 Thread Rodrigo Damazio via Mercurial-devel
Hmm hold off, there's an issue here.

On Fri, Jul 14, 2017 at 3:48 PM, Rodrigo Damazio Bovendorp <
rdama...@google.com> wrote:

> # HG changeset patch
> # User Rodrigo Damazio Bovendorp 
> # Date 1500072378 25200
> #  Fri Jul 14 15:46:18 2017 -0700
> # Node ID 0ccebbd04efbd672fc71df7f52ec243057cbed7d
> # Parent  c0d8de2724ce6240d2a4241aff78ce2ee92359c2
> templates: add substring and string length operations
>
> This will allow substr(text, start, end) and strlen(text) in templates,
> permitting various text formatting, such as making a (non-graphing) log
> line be
> limited to terminal width ("substr(desc, 0, termwidth)")
>
> diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
> --- a/mercurial/templatefilters.py
> +++ b/mercurial/templatefilters.py
> @@ -362,6 +362,11 @@
>  return ""
>  return pycompat.bytestr(thing)
>
> +@templatefilter('strlen')
> +def stringlen(text):
> +"""Any text. Turns the value into its length."""
> +return len(text)
> +
>  @templatefilter('stripdir')
>  def stripdir(text):
>  """Treat the text as path and strip a directory level, if
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -1015,6 +1015,25 @@
>  # i18n: "sub" is a keyword
>  raise error.ParseError(_("sub got an invalid replacement: %s") %
> rpl)
>
> +@templatefunc('substr(text, start[, end])')
> +def substring(context, mapping, args):
> +"""Returns a substring of the given text. Negative indices reference
> the end
> +of the string."""
> +if len(args) < 2 or len(args) > 3:
> +  raise error.ParseError(_("substring takes 2 or 3 arguments"))
> +
> +text = evalstring(context, mapping, args[0])
> +textlen = len(text)
> +start = evalinteger(context, mapping, args[1],
> +  _("start expects an integer index"))
> +end = -1
> +if len(args) > 2:
> +  end = evalinteger(context, mapping, args[2],
> +_("end expects an integer index"))
> +
> +# Python's [] already handles start and end boundary conditions.
> +return text[start:end]
> +
>  @templatefunc('startswith(pattern, text)')
>  def startswith(context, mapping, args):
>  """Returns the value from the "text" argument
> diff --git a/tests/test-command-template.t b/tests/test-command-template.t
> --- a/tests/test-command-template.t
> +++ b/tests/test-command-template.t
> @@ -4011,6 +4011,35 @@
>o  line 1
>   line 2
>
> +Test stringlen and substring
> +Full desc is "Modify, add, remove, rename".
> +String idxs:  012345678901
> +Reverse string idxs:  10987654321
> +
> +  $ hg log -R a -r . --template '{desc|strlen}\n'
> +  27
> +  $ hg log -R a -r . --template '{substr(desc, 5, 10)}\n'
> +  y, ad
> +  $ hg log -R a -r . --template '{substr(desc, 5, -10)}\n'
> +  y, add, remo
> +  $ hg log -R a -r . --template '{substr(desc, 5, strlen(desc) - 10)}\n'
> +  y, add, remo
> +  $ hg log -R a -r . --template '{substr(desc, -10, -3)}\n'
> +  ve, ren
> +
> +Test substr with invalid indices
> +
> +  $ hg log -R a -r . --template '{substr(desc, 5, 200)}\n'
> +  y, add, remove, rename
> +  $ hg log -R a -r . --template '{substr(desc, 10, 5)}\n'
> +
> +  $ hg log -R a -r . --template '{substr(desc, 100, 200)}\n'
> +
> +  $ hg log -R a -r . --template '{substr(desc, -100, -50)}\n'
> +
> +  $ hg log -R a -r . --template '{substr(desc, -50, -100)}\n'
> +
> +
>  Test bad template with better error message
>
>$ hg log -Gv -R a --template '{desc|user()}'
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Experimenting with Phabricator for reviews

2017-07-14 Thread Sean Farley

Jun Wu  writes:

> Excerpts from Sean Farley's message of 2017-07-14 16:10:02 -0700:
>>
>> Jun Wu  writes:
>>
>> > Excerpts from Augie Fackler's message of 2017-07-14 12:09:10 -0400:
>> >> If there's a way to get just "new review" messages from phabricator
>> >> into the list, let's do that. I _do not_ want us to stop notifying the
>> >> list of phabricator reviews, because then people that don't watch
>> >> phabricator have no visibility into changes happening there, and we
>> >> split our community.
>> >
>> > My feeling is that both people who care about, and who don't care about
>> > Phabricator will want to send those emails to /dev/null. Reasons:
>> >
>> >   - For people not using Phabricator, they surely don't care about the
>> > notifications and want to nuke them.
>>
>> This is just plain wrong. For people like Danek and my coworkers (and
>> others, I'm sure), there is value to seeing the discussion and code
>> review comments. Even if it's just to skim and get a gist of things.
>
> Sorry if I was unclear. The category refers to those who completely don't
> care about Phabricator, including comments posting there.

Huh? But that's the thing, isn't it? Previously, comments about code
review are on the list. One can peruse them at leisure or archive /
skip, etc. What you're saying, if I'm not mistaken, is that some
comments (no matter the content) will no longer be on the list. That
makes perusing them now split into two locations.


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


Re: Experimenting with Phabricator for reviews

2017-07-14 Thread Jun Wu
Excerpts from Sean Farley's message of 2017-07-14 16:10:02 -0700:
> 
> Jun Wu  writes:
> 
> > Excerpts from Augie Fackler's message of 2017-07-14 12:09:10 -0400:
> >> If there's a way to get just "new review" messages from phabricator
> >> into the list, let's do that. I _do not_ want us to stop notifying the
> >> list of phabricator reviews, because then people that don't watch
> >> phabricator have no visibility into changes happening there, and we
> >> split our community.
> >
> > My feeling is that both people who care about, and who don't care about
> > Phabricator will want to send those emails to /dev/null. Reasons:
> >
> >   - For people not using Phabricator, they surely don't care about the
> > notifications and want to nuke them.
> 
> This is just plain wrong. For people like Danek and my coworkers (and
> others, I'm sure), there is value to seeing the discussion and code
> review comments. Even if it's just to skim and get a gist of things.

Sorry if I was unclear. The category refers to those who completely don't
care about Phabricator, including comments posting there.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Experimenting with Phabricator for reviews

2017-07-14 Thread Sean Farley

Danek Duvall  writes:

> Gregory Szorc wrote:
>
>> > On Jul 14, 2017, at 06:30, Yuya Nishihara  wrote:
>> > 
>> >> On Wed, 12 Jul 2017 11:52:23 -0700, Sean Farley wrote:
>> >> Sean Farley  writes:
>> >>> Adrian Buehlmann  writes:
>> > On 2017-07-10 22:00, Kevin Bullock wrote:
>> > Greetings, Mercurial hackers!
>> > 
>> > We've set up an instance of Phabricator that we're going to experiment 
>> > with for code reviews. At this time, we're not planning on using any 
>> > of the other features of Phabricator, and the use of Phabricator for 
>> > reviews is very much *an experiment* - we intend to see how this is 
>> > going in a little while (probably around the start of the 4.4 cycle). 
>> > If you're more comfortable submitting and reviewing patches as plain 
>> > email, that's fine - use of Phabricator is optional. In the meantime, 
>> > you'll see e-mails coming to the mailing list when activity happens in 
>> > Phabricator--hopefully we've hit the right settings to make this 
>> > useful without being too chatty.
>> > 
>> > See https://www.mercurial-scm.org/wiki/Phabricator for a little more 
>> > detail, including how to submit new reviews.
>>  
>>  Ugh. Looks way too chatty/cluttered for my taste so far (I'm mostly
>>  lurking the list).
>>  
>>  I'm likely going to unsubscribe Mercurial-devel, if it stays like 
>>  that...
>> >>> 
>> >>> Yeah, I've found this to be pretty ugly as well; though I don't think
>> >>> it's a function of chatty-ness but rather lack of threading :-(
>> >> 
>> >> Another thing that I'd like: can we drop the "[Differential] [Foo
>> >> blah]"? It seems mostly useless information and wastes precious
>> >> horizontal real estate.
>> > 
>> > Agrees, unfortunately. It's too much for casual contributors. I've set up
>> > filtering rule to blackhole these emails so I can stay sane.
>> 
>> It hasn't helped that the list has been extremely active this week. I took 
>> most of a few days off and too was overwhelmed at the volume. Things should 
>> hopefully quiet down next week after the freeze.
>> 
>> Although, given the volume of patches these days, I do question if splitting 
>> up the mailing list might be fruitful. We could establish a new list for the 
>> fire hose of review activity. The dev list could potentially be just for 
>> general discussion. Or we could potentially send just the "new review" 
>> emails to the dev list. I'm not convinced that we should do this. Just 
>> thought I'd throw an idea out there.
>
> Honestly, I'd rather not.  I don't read most of the code review emails, but
> I like seeing them filter through, since it gives me a chance to scan
> through things that might be relevant -- either to Solaris, or our
> extension, or our team, generally.

Yeah, this is my feeling as well. I do find value in skimming messages
and seeing the discussion.

And so far I agree with Augie that my experience has been negative with
phabricator.


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


Re: Experimenting with Phabricator for reviews

2017-07-14 Thread Jun Wu
Excerpts from Augie Fackler's message of 2017-07-14 12:09:10 -0400:
> If there's a way to get just "new review" messages from phabricator
> into the list, let's do that. I _do not_ want us to stop notifying the
> list of phabricator reviews, because then people that don't watch
> phabricator have no visibility into changes happening there, and we
> split our community.

My feeling is that both people who care about, and who don't care about
Phabricator will want to send those emails to /dev/null. Reasons:

  - For people not using Phabricator, they surely don't care about the
notifications and want to nuke them.
  - For people active on Phabricator, they read the notification there and
don't need additional email notifications. (I belong to this category
and I send those emails to /dev/null already).

So it seems to me that the only value of getting those emails is the
"achieving" purpose. One brainstorm idea from an internal discussion is to
send the emails to a separated list. It seems the clang community is doing
something similar - they have "-dev" list and "-commits" list. I guess
nobody really reads the "-commits" list and that seems for achieving only.

> (So far I'm not at all happy with Phabricator and how it's split the
> review load in an awkward way - for this reviewer, it's been a clear
> negative.)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] run-tests: make sure to check if pygments is installed before using it

2017-07-14 Thread Augie Fackler
On Sat, Jul 15, 2017 at 02:35:28AM +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pul...@gmail.com>
> # Date 1500065225 -19800
> #  Sat Jul 15 02:17:05 2017 +0530
> # Node ID 07928a5240e51e2cd44f7e05fccda32053ee0133
> # Parent  2cbccf36af1bd0d9ae9df1ad5fd4a7f8d870ae6c
> run-tests: make sure to check if pygments is installed before using it

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


Re: [PATCH V2] parsers: fix invariant bug in find_deepest

2017-07-14 Thread Sune Foldager
Right, sorry about that. So you ended up un-rebasing the rebase I did before 
submitting :p. Always good to keep in shape, I suppose. Thanks. 

-Sune

> On 14 Jul 2017, at 23.15, Augie Fackler  wrote:
> 
> 
>> On Jul 14, 2017, at 17:14, Sune Foldager  wrote:
>> 
>> Rebase? Didn’t I put in on stable? I realize the files are different on 
>> default, which is where I initially developed it.  
> 
> Ah, you didn't have --flag stable and I missed the branch. Next release is 
> 4.3 anyway, so it'll be there in any case.
> 
>> 
>> As for the commit message change, I assume you mean the issue reference. 
>> Yeah, I didn’t think that would be correct ;). I’m out of the loop.
>> 
>> -Sune
>> 
 On 14 Jul 2017, at 18.51, Augie Fackler  wrote:
 
 On Fri, Jul 14, 2017 at 01:49:09PM +0200, Sune Foldager wrote:
 # HG changeset patch
 # User Sune Foldager 
 # Date 1500032897 -7200
 #  Fri Jul 14 13:48:17 2017 +0200
 # Branch stable
 # Node ID 21158392118c6ffd8c60dd627a338f044726b9cb
 # Parent  c1994c986d77f071e338de35a2c69d7bb87e39a3
 parsers: fix invariant bug in find_deepest
>>> 
>>> queued, thanks
>>> 
>>> (Though with a pretty big rebase and a commit message tweak for the
>>> bugzilla bot)
> 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH V2] parsers: fix invariant bug in find_deepest

2017-07-14 Thread Sune Foldager
Rebase? Didn’t I put in on stable? I realize the files are different on 
default, which is where I initially developed it.

As for the commit message change, I assume you mean the issue reference. Yeah, 
I didn’t think that would be correct ;). I’m out of the loop.

-Sune

> On 14 Jul 2017, at 18.51, Augie Fackler  wrote:
> 
>> On Fri, Jul 14, 2017 at 01:49:09PM +0200, Sune Foldager wrote:
>> # HG changeset patch
>> # User Sune Foldager 
>> # Date 1500032897 -7200
>> #  Fri Jul 14 13:48:17 2017 +0200
>> # Branch stable
>> # Node ID 21158392118c6ffd8c60dd627a338f044726b9cb
>> # Parent  c1994c986d77f071e338de35a2c69d7bb87e39a3
>> parsers: fix invariant bug in find_deepest
> 
> queued, thanks
> 
> (Though with a pretty big rebase and a commit message tweak for the
> bugzilla bot)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH remotenames] locks: take wlock for file writes

2017-07-14 Thread Durham Goode
# HG changeset patch
# User Durham Goode 
# Date 1500070111 25200
#  Fri Jul 14 15:08:31 2017 -0700
# Node ID 1c7d5c611f3fb5ba790eca5ca9d41c3398ba730d
# Parent  75df1d072f09392fb0b7314c856fb9689daa7c91
locks: take wlock for file writes

There are new warnings in upstream that catch vfs writes when the wlock isn't
taken. Remotenames triggers a couple of these. Let's take the lock. In both
cases, it happens during normal write operations (bookmark setting, and pull) so
we don't have to worry about this change causing locks during read operations.

diff --git a/remotenames.py b/remotenames.py
--- a/remotenames.py
+++ b/remotenames.py
@@ -167,10 +167,11 @@ def expull(orig, repo, remote, *args, **
 pullremotenames(repo, remote, bookmarks)
 if repo.vfs.exists(_selectivepullenabledfile):
 if not _isselectivepull(repo.ui):
-repo.vfs.unlink(_selectivepullenabledfile)
+with repo.wlock():
+repo.vfs.unlink(_selectivepullenabledfile)
 else:
 if _isselectivepull(repo.ui):
-with repo.vfs(_selectivepullenabledfile, 'w') as f:
+with repo.wlock(), repo.vfs(_selectivepullenabledfile, 'w') as f:
 f.write('enabled') # content doesn't matter
 return res
 
@@ -1164,11 +1165,12 @@ def _readtracking(repo):
 return tracking
 
 def _writetracking(repo, tracking):
-data = ''
-for book, track in tracking.iteritems():
-data += '%s %s\n' % (book, track)
-vfs = shareawarevfs(repo)
-vfs.write('bookmarks.tracking', data)
+with repo.wlock():
+data = ''
+for book, track in tracking.iteritems():
+data += '%s %s\n' % (book, track)
+vfs = shareawarevfs(repo)
+vfs.write('bookmarks.tracking', data)
 
 def _removetracking(repo, bookmarks):
 tracking = _readtracking(repo)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH V2] codemod: register core configitems using a script

2017-07-14 Thread Jun Wu
# HG changeset patch
# User Jun Wu 
# Date 1500067360 25200
#  Fri Jul 14 14:22:40 2017 -0700
# Node ID 4ba8b3e871116249d7a99062a08955446e896047
# Parent  80e1331a7fe970f3e56fde9044949d72d3afdf30
# Available At https://bitbucket.org/quark-zju/hg-draft
#  hg pull https://bitbucket.org/quark-zju/hg-draft -r 4ba8b3e87111
codemod: register core configitems using a script

This is done by a script [2] using RedBaron [1], a tool designed for doing
code refactoring. All "default" values are decided by the script and are
strongly consistent with the existing code.

There are 2 changes done manually to fix tests:

  [warn] mercurial/exchange.py: experimental.bundle2-output-capture: default 
needs manual removal
  [warn] mercurial/localrepo.py: experimental.hook-track-tags: default needs 
manual removal

Since RedBaron is not confident about how to indent things [2].

[1]: https://github.com/PyCQA/redbaron
[2]: https://github.com/PyCQA/redbaron/issues/100
[3]:

#!/usr/bin/env python
# codemod_configitems.py - codemod tool to fill configitems
#
# Copyright 2017 Facebook, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import, print_function

import os
import sys

import redbaron

def readpath(path):
with open(path) as f:
return f.read()

def writepath(path, content):
with open(path, 'w') as f:
f.write(content)

_configmethods = {'config', 'configbool', 'configint', 'configbytes',
  'configlist', 'configdate'}

def extractstring(rnode):
"""get the string from a RedBaron string or call_argument node"""
while rnode.type != 'string':
rnode = rnode.value
return rnode.value[1:-1]  # unquote, "'str'" -> "str"

def uiconfigitems(red):
"""match *.ui.config* pattern, yield (node, method, args, section, name)"""
for node in red.find_all('atomtrailers'):
entry = None
try:
obj = node[-3].value
method = node[-2].value
args = node[-1]
section = args[0].value
name = args[1].value
if (obj in ('ui', 'self') and method in _configmethods
and section.type == 'string' and name.type == 'string'):
entry = (node, method, args, extractstring(section),
 extractstring(name))
except Exception:
pass
else:
if entry:
yield entry

def coreconfigitems(red):
"""match coreconfigitem(...) pattern, yield (node, args, section, name)"""
for node in red.find_all('atomtrailers'):
entry = None
try:
args = node[1]
section = args[0].value
name = args[1].value
if (node[0].value == 'coreconfigitem' and section.type == 'string'
and name.type == 'string'):
entry = (node, args, extractstring(section),
 extractstring(name))
except Exception:
pass
else:
if entry:
yield entry

def registercoreconfig(cfgred, section, name, defaultrepr):
"""insert coreconfigitem to cfgred AST

section and name are plain string, defaultrepr is a string
"""
# find a place to insert the "coreconfigitem" item
entries = list(coreconfigitems(cfgred))
for node, args, nodesection, nodename in reversed(entries):
if (nodesection, nodename) < (section, name):
# insert after this entry
node.insert_after(
'coreconfigitem(%r, %r,\n'
'default=%s,\n'
')' % (section, name, defaultrepr))
return

def main(argv):
if not argv:
print('Usage: codemod_configitems.py FILES\n'
  'For example, FILES could be "{hgext,mercurial}/*/**.py"')
dirname = os.path.dirname
reporoot = dirname(dirname(dirname(os.path.abspath(__file__

# register configitems to this destination
cfgpath = os.path.join(reporoot, 'mercurial', 'configitems.py')
cfgred = redbaron.RedBaron(readpath(cfgpath))

# state about what to do
registered = set((s, n) for n, a, s, n in coreconfigitems(cfgred))
toregister = {} # {(section, name): defaultrepr}
coreconfigs = set() # {(section, name)}, whether it's used in core

# first loop: scan all files before taking any action
for i, path in enumerate(argv):
print('(%d/%d) scanning %s' % (i + 1, len(argv), path))
iscore = ('mercurial' in path) and ('hgext' not in path)
red = redbaron.RedBaron(readpath(path))
# find all repo.ui.config* and ui.config* calls, and collect their
# section, name and default value information.
for node, method, args, section, name in uiconfigitems(red):
if section == 'web':
# [web] section has some weirdness, ignore them 

[Differential] [Updated] D21: rebase: rewrite defineparents

2017-07-14 Thread quark (Jun Wu)
quark marked an inline comment as done.
quark added inline comments.

INLINE COMMENTS

> durin42 wrote in rebase.py:923
> How did C' end up in a separate subgraph? I thought it was moving to F?
> 
> (I suspect this is also some multi-dest stuff...)

Good catch! Side effect of split again. Updated the comment.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Updated, 257 lines] D21: rebase: rewrite defineparents

2017-07-14 Thread quark (Jun Wu)
quark updated this revision to Diff 161.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D21?vs=156=161

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

Index: hgext/rebase.py
===
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -66,7 +66,6 @@
 revprecursor = -4
 # plain prune (no successor)
 revpruned = -5
-revskipped = (revignored, revprecursor, revpruned)
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -390,10 +389,7 @@
 ui.status(_('rebasing %s\n') % desc)
 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)),
 _('changesets'), total)
-p1, p2, base = defineparents(repo, rev, self.dest,
- self.state,
- self.destancestors,
- self.obsoletenotrebased)
+p1, p2, base = defineparents(repo, rev, self.dest, self.state)
 self.storestatus()
 storecollapsemsg(repo, self.collapsemsg)
 if len(repo[None].parents()) == 2:
@@ -463,9 +459,7 @@
 repo, ui, opts = self.repo, self.ui, self.opts
 if self.collapsef and not self.keepopen:
 p1, p2, _base = defineparents(repo, min(self.state),
-  self.dest, self.state,
-  self.destancestors,
-  self.obsoletenotrebased)
+  self.dest, self.state)
 editopt = opts.get('edit')
 editform = 'rebase.collapse'
 if self.collapsemsg:
@@ -883,15 +877,6 @@
 copies.duplicatecopies(repo, rev, p1rev, skiprev=dest)
 return stats
 
-def nearestrebased(repo, rev, state):
-"""return the nearest ancestors of rev in the rebase result"""
-rebased = [r for r in state if state[r] > nullmerge]
-candidates = repo.revs('max(%ld  and (::%d))', rebased, rev)
-if candidates:
-return state[candidates.first()]
-else:
-return None
-
 def _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs, rebaseobsskipped):
 """
 Abort if rebase will create divergence or rebase is noop because of markers
@@ -915,107 +900,157 @@
   "experimental.allowdivergence=True")
 raise error.Abort(msg % (",".join(divhashes),), hint=h)
 
-def defineparents(repo, rev, dest, state, destancestors,
-  obsoletenotrebased):
-'Return the new parent relationship of the revision that will be rebased'
-parents = repo[rev].parents()
-p1 = p2 = nullrev
-rp1 = None
+def adjusteddest(repo, rev, prev, dest, state):
+"""adjust rebase destination given the current rebase state
+
+rev is being rebased, prev is one of its parent.
+
+For example, when rebase -r 'B+E' -d F, rebase will first move B to B', and
+when it's checking E:
 
-p1n = parents[0].rev()
-if p1n in destancestors:
-p1 = dest
-elif p1n in state:
-if state[p1n] == nullmerge:
-p1 = dest
-elif state[p1n] in revskipped:
-p1 = nearestrebased(repo, p1n, state)
-if p1 is None:
-p1 = dest
-else:
-p1 = state[p1n]
-else: # p1n external
-p1 = dest
-p2 = p1n
+B' <- written during the rebase
+|
+F <- original destination of B, E
+|
+| E <- rev, which is being rebased
+| |
+| D <- prev, one parent of rev being checked
+| |
+| x <- skipped, no successor or successor in (::destination)
+| |
+| C
+| |
+| B <- rebased as B'
+|/
+A
+
+The destination will be adjusted from F to B'.
+"""
+if prev != nullrev:
+# interesting rebase source - having a same dest and is rebased
+source = [s for s, d in state.items() if d > 0]
+candidate = repo.revs('max(%ld and (::%d))', source, prev).first()
+if candidate is not None:
+return state[candidate]
+return dest
 
-if len(parents) == 2 and parents[1].rev() not in destancestors:
-p2n = parents[1].rev()
-# interesting second parent
-if p2n in state:
-if p1 == dest: # p1n in destancestors or external
-p1 = state[p2n]
-if p1 == revprecursor:
-rp1 = obsoletenotrebased[p2n]
-elif state[p2n] in revskipped:
-p2 = nearestrebased(repo, p2n, state)
-if p2 is None:
-# no ancestors rebased yet, detach
-p2 = dest
-else:
-p2 = state[p2n]
-else: # p2n external
-if p2 != nullrev: # p1n external 

Re: [PATCH V2] parsers: fix invariant bug in find_deepest

2017-07-14 Thread Augie Fackler

> On Jul 14, 2017, at 17:14, Sune Foldager  wrote:
> 
> Rebase? Didn’t I put in on stable? I realize the files are different on 
> default, which is where I initially developed it.  

Ah, you didn't have --flag stable and I missed the branch. Next release is 4.3 
anyway, so it'll be there in any case.

> 
> As for the commit message change, I assume you mean the issue reference. 
> Yeah, I didn’t think that would be correct ;). I’m out of the loop.
> 
> -Sune
> 
>> On 14 Jul 2017, at 18.51, Augie Fackler  wrote:
>> 
>>> On Fri, Jul 14, 2017 at 01:49:09PM +0200, Sune Foldager wrote:
>>> # HG changeset patch
>>> # User Sune Foldager 
>>> # Date 1500032897 -7200
>>> #  Fri Jul 14 13:48:17 2017 +0200
>>> # Branch stable
>>> # Node ID 21158392118c6ffd8c60dd627a338f044726b9cb
>>> # Parent  c1994c986d77f071e338de35a2c69d7bb87e39a3
>>> parsers: fix invariant bug in find_deepest
>> 
>> queued, thanks
>> 
>> (Though with a pretty big rebase and a commit message tweak for the
>> bugzilla bot)

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


[Differential] [Commented On] D21: rebase: rewrite defineparents

2017-07-14 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Almost there.

INLINE COMMENTS

> rebase.py:923
> +| ||
> +| B <- rebased as B'   G <- destination of C, separate subgraph
> +|/

How did C' end up in a separate subgraph? I thought it was moving to F?

(I suspect this is also some multi-dest stuff...)

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH] run-tests: make sure to check if pygments is installed before using it

2017-07-14 Thread Jun Wu
Looks good to me.

Excerpts from Pulkit Goyal's message of 2017-07-15 02:35:28 +0530:
> # HG changeset patch
> # User Pulkit Goyal <7895pul...@gmail.com>
> # Date 1500065225 -19800
> #  Sat Jul 15 02:17:05 2017 +0530
> # Node ID 07928a5240e51e2cd44f7e05fccda32053ee0133
> # Parent  2cbccf36af1bd0d9ae9df1ad5fd4a7f8d870ae6c
> run-tests: make sure to check if pygments is installed before using it
> 
> e80041832e introduced support to color the output of tests but used pygments
> without checking whether it's installed or not. That breaks test-run-tests.t 
> for
> machines which don't have pygments installed. This patch conditionalize the
> color test in test-run-tests.t and also add a check to make sure pygments is
> installed before using that.
> 
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -89,10 +89,12 @@
>  processlock = threading.Lock()
>  
>  with_color = False
> +pygmentspresent = False
>  try: # is pygments installed
>  import pygments
>  import pygments.lexers as lexers
>  import pygments.formatters as formatters
> +pygmentspresent = True
>  with_color = True
>  except ImportError:
>  pass
> @@ -1647,7 +1649,7 @@
>  else:
>  self.stream.write('\n')
>  for line in lines:
> -if with_color:
> +if with_color and pygmentspresent:
>  line = pygments.highlight(
>  line,
>  lexers.DiffLexer(),
> diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
> --- a/tests/test-run-tests.t
> +++ b/tests/test-run-tests.t
> @@ -121,6 +121,8 @@
>  
>  test diff colorisation
>  
> +#if pygments
> +
>$ rt test-failure.t --color always
>
>\x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc)
> @@ -138,6 +140,8 @@
>python hash seed: * (glob)
>[1]
>  
> +#endif
> +
>$ rt test-failure.t 2> tmp.log
>[1]
>$ cat tmp.log
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Friendly reminder: Freeze starts next week

2017-07-14 Thread Augie Fackler
Freeze will start on Monday or Tuesday. Bugfixes still welcome during the 
freeze, just not new features. :)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 12 of 14] obscache: use the obscache to compute the obsolete set

2017-07-14 Thread Jun Wu
Excerpts from Boris Feld's message of 2017-07-14 23:01:40 +0200:
> The obsmarkers exchange will need the proposed two layers cache. Radix
> link is a great improvement for obsolescence access of individual
> changesets, but discovery needs to compute and exposes repository wide
> properties that needs to be cached in order to be efficient.

I'm not sure what you're talking about is the only way to improve
discovery/exchange performance. I also have ideas on how to improve them,
and they do not require the two layers cache IIUC.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] run-tests: make sure to check if pygments is installed before using it

2017-07-14 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1500065225 -19800
#  Sat Jul 15 02:17:05 2017 +0530
# Node ID 07928a5240e51e2cd44f7e05fccda32053ee0133
# Parent  2cbccf36af1bd0d9ae9df1ad5fd4a7f8d870ae6c
run-tests: make sure to check if pygments is installed before using it

e80041832e introduced support to color the output of tests but used pygments
without checking whether it's installed or not. That breaks test-run-tests.t for
machines which don't have pygments installed. This patch conditionalize the
color test in test-run-tests.t and also add a check to make sure pygments is
installed before using that.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -89,10 +89,12 @@
 processlock = threading.Lock()
 
 with_color = False
+pygmentspresent = False
 try: # is pygments installed
 import pygments
 import pygments.lexers as lexers
 import pygments.formatters as formatters
+pygmentspresent = True
 with_color = True
 except ImportError:
 pass
@@ -1647,7 +1649,7 @@
 else:
 self.stream.write('\n')
 for line in lines:
-if with_color:
+if with_color and pygmentspresent:
 line = pygments.highlight(
 line,
 lexers.DiffLexer(),
diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
--- a/tests/test-run-tests.t
+++ b/tests/test-run-tests.t
@@ -121,6 +121,8 @@
 
 test diff colorisation
 
+#if pygments
+
   $ rt test-failure.t --color always
   
   \x1b[38;5;124m--- $TESTTMP/test-failure.t\x1b[39m (esc)
@@ -138,6 +140,8 @@
   python hash seed: * (glob)
   [1]
 
+#endif
+
   $ rt test-failure.t 2> tmp.log
   [1]
   $ cat tmp.log
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 12 of 14] obscache: use the obscache to compute the obsolete set

2017-07-14 Thread Boris Feld
On Fri, 2017-07-14 at 14:16 -0400, Augie Fackler wrote:
> On Sun, Jul 09, 2017 at 07:55:24PM +0200, Boris Feld wrote:
> > # HG changeset patch
> > # User Boris Feld 
> > # Date 1495198021 -7200
> > #  Fri May 19 14:47:01 2017 +0200
> > # Node ID 3a93e99b0e718befd57a32615a14fd0d3c194456
> > # Parent  f8953ed43f8d1b146dcff688030133f0d6123a49
> > # EXP-Topic obs-cache
> > obscache: use the obscache to compute the obsolete set
> > 
> > Now that we have a cache and that the cache is kept up to date, we
> > can use it to
> > speeds up the obsolete set computation. This way, we no longer need
> > to load the
> > obsstore for most operation.
> > 
> > On the mercurial-core repository, this provides a significant speed
> > up for
> > operation that do not need further obsolescence information:
> > 
> > > command  | before | after |
> > > id -r @  |  0.670 | 0.093 |
> > > log -r @ |  0.951 | 0.916 |
> > > diff |  0.070 | 0.069 |
> > > diff -r .~1  |  0.705 | 0.120 |
> > > export @ |  0.672 | 0.103 |
> > > log -G -r draft()|  1.117 | 1.084 |
> > > log -G -r draft()|  1.063 | 1.064 |
> > >   -T "{node} {troubles}" ||   |
> > > log -G -r tip|  0.658 | 0.086 |
> > >   -T "{node} {desc}" ||   |
> 
> These timings look pretty good, though I find some of the numbers
> underwhelming (eg 'hg log -r @' seems like it shouldn't be anywhere
> *near* that slow).
> 
> I think given the history here, and that I know Jun has something
> related coming in a few weeks, I'm going to put this series on hold
> until after 4.3 is done so we can get some comparisons between
> approaches, as I believe his solution requires a little less in the
> way of creative caching layers.
> 
> In more detail: the radixlink approach to speeding up obsmarkers
> interests me a lot because it speeds up more than this does, and is
> close on the things where they're similar. If I can have one caching
> layer instead of two, I'd like that, and given how late in the cycle
> it is and the timetable I've heard from Jun I'm happy to let hg 4.3
> not get perf wins today and just make 4.4 the release where we get
> this sorted out.

The obsmarkers exchange will need the proposed two layers cache. Radix
link is a great improvement for obsolescence access of individual
changesets, but discovery needs to compute and exposes repository wide
properties that needs to be cached in order to be efficient.

Pushing these new caches layers in core would help us experimenting
caches on useful things. For example, with these classes in core, we
could trivially add a cache for the current obsmarkers discovery (not
obshashrange). This will probably save 15s from the current obsmarkers
discovery.

Implementing these abstract caches outside of core is cumbersome,
queuing patch 4 would helps us a lot.

Using the new abstract caches with branchmap will take some times
because branchmap has multiple specific quirks. We won't have time to
do that properly before the freeze.

> 
> > 
> > The obsstore loading operation usually disappear from execution
> > profile.
> > 
> > The speeds up rely on a couple of different mechanism:
> > 
> > * First, not having to parse the obsstore provides a massive
> > speedup:
> > 
> >   Time spent computing 'obsolete', no obsstore pre-loaded.
> > 
> > before: wall 0.449502 comb 0.46 user 0.42 sys 0.04
> > (best of 17)
> > after:  wall 0.005752 comb 0.01 user 0.01 sys 0.00
> > (best of 340)
> > 
> > * Second keeping the computation fully in the revision space (no
> > usage of node),
> >   raise and extra 4x speedup.
> > 
> >   Time spent computing 'obsolete', obsstore preloaded:
> > 
> > before: wall 0.007684 comb 0.00 user 0.00 sys 0.00
> > (best of 305)
> > after:  wall 0.001928 comb 0.00 user 0.00 sys 0.00
> > (best of 1250)
> > 
> > To keep the changeset simple, we assume the cache is up to date
> > (from the last
> > transaction). This won't be true when both old and new clients
> > access the
> > repository. (with the special case of no new transactions since
> > last upgrade).
> > We'll address this issue in the next couple of changesets.
> > 
> > This changesets is a first step to install the basic. There are a
> > couple of easy
> > improvement that can further improve this cache:
> > 
> >  * Improving handling of outdated cache on read only operation (see
> > above),
> > 
> >  * Avoid reaading the full obsstore data from disk to check the
> > cache key
> >    (about -4ms, 3x speedup)
> > 
> >  * Optimise the python code to reduce attribute lookup
> >    (about 25% of the remaining of the time spent there).
> > 
> > diff -r f8953ed43f8d -r 3a93e99b0e71 mercurial/obsolete.py
> > --- a/mercurial/obsolete.py Fri May 19 14:46:46 2017 +0200
> > +++ b/mercurial/obsolete.py Fri May 19 14:47:01 2017 +0200
> > @@ 

[Differential] [Updated, 70 lines] D26: rebase: remove revignored and nullmerge states

2017-07-14 Thread quark (Jun Wu)
quark updated this revision to Diff 159.
Herald added a reviewer: hg-reviewers.
This revision now requires review to proceed.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D26?vs=42=159

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

Index: hgext/rebase.py
===
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -60,12 +60,10 @@
 
 # Indicates that a revision needs to be rebased
 revtodo = -1
-nullmerge = -2
-revignored = -3
 
 # legacy revstates no longer needed in current code
-# -4: revprecursor, -5: revpruned
-legacystates = {'-4', '-5'}
+# -2: nullmerge, -3: revignored, -4: revprecursor, -5: revpruned
+legacystates = {'-2', '-3', '-4', '-5'}
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -233,8 +231,6 @@
 oldrev, newrev = l.split(':')
 if newrev in legacystates:
 continue
-if newrev in (str(nullmerge), str(revignored)):
-state[repo[oldrev].rev()] = int(newrev)
 elif newrev == nullid:
 state[repo[oldrev].rev()] = revtodo
 # Legacy compat special case
@@ -439,10 +435,6 @@
 self.skipped.add(rev)
 self.state[rev] = p1
 ui.debug('next revision set to %s\n' % p1)
-elif self.state[rev] == nullmerge:
-pass
-elif self.state[rev] == revignored:
-pass
 else:
 ui.status(_('already rebased %s as %s\n') %
   (desc, repo[self.state[rev]]))
@@ -463,7 +455,7 @@
 commitmsg = 'Collapsed revision'
 for rebased in self.state:
 if rebased not in self.skipped and\
-   self.state[rebased] > nullmerge:
+   self.state[rebased] >= revtodo:
 commitmsg += '\n* %s' % repo[rebased].description()
 editopt = True
 editor = cmdutil.getcommiteditor(edit=editopt, editform=editform)
@@ -479,7 +471,7 @@
 else:
 newrev = repo[newnode].rev()
 for oldrev in self.state.iterkeys():
-if self.state[oldrev] > nullmerge:
+if self.state[oldrev] >= revtodo:
 self.state[oldrev] = newrev
 
 if 'qtip' in repo.tags():
@@ -1226,7 +1218,6 @@
 raise error.Abort(_('no matching revisions'))
 roots.sort()
 state = dict.fromkeys(rebaseset, revtodo)
-detachset = set()
 emptyrebase = True
 for root in roots:
 commonbase = root.ancestor(dest)
@@ -1248,66 +1239,13 @@
 
 emptyrebase = False
 repo.ui.debug('rebase onto %s starting from %s\n' % (dest, root))
-# Rebase tries to turn  into a parent of  while
-# preserving the number of parents of rebased changesets:
-#
-# - A changeset with a single parent will always be rebased as a
-#   changeset with a single parent.
-#
-# - A merge will be rebased as merge unless its parents are both
-#   ancestors of  or are themselves in the rebased set and
-#   pruned while rebased.
-#
-# If one parent of  is an ancestor of , the rebased
-# version of this parent will be . This is always true with
-# --base option.
-#
-# Otherwise, we need to *replace* the original parents with
-# . This "detaches" the rebased set from its former location
-# and rebases it onto . Changes introduced by ancestors of
-#  not common with  (the detachset, marked as
-# nullmerge) are "removed" from the rebased changesets.
-#
-# - If  has a single parent, set it to .
-#
-# - If  is a merge, we cannot decide which parent to
-#   replace, the rebase operation is not clearly defined.
-#
-# The table below sums up this behavior:
-#
-# +--+--+-+
-# |  | one parent   |  merge  |
-# +--+--+-+
-# | parent in| new parent is  | parents in :: are |
-# | :: |  | remapped to   |
-# +--+--+-+
-# | unrelated source | new parent is  | ambiguous, abort|
-# +--+--+-+
-#
-# The actual abort is handled by `defineparents`
-if len(root.parents()) <= 1:
-# ancestors of  not ancestors of 
-

[Differential] [Request, 6 lines] D85: rebase: remove rebaseset from _checkobsrebase

2017-07-14 Thread quark (Jun Wu)
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The parameter is not used. Therefore removed.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

Index: hgext/rebase.py
===
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -279,12 +279,11 @@
 if not self.ui.configbool('experimental', 'rebaseskipobsolete',
   default=True):
 return
-rebaseset = set(rebaserevs)
 obsoleteset = set(obsoleterevs)
 self.obsoletenotrebased = _computeobsoletenotrebased(self.repo,
 obsoleteset, dest)
 skippedset = set(self.obsoletenotrebased)
-_checkobsrebase(self.repo, self.ui, obsoleteset, rebaseset, skippedset)
+_checkobsrebase(self.repo, self.ui, obsoleteset, skippedset)
 
 def _prepareabortorcontinue(self, isabort):
 try:
@@ -862,12 +861,11 @@
 copies.duplicatecopies(repo, rev, p1rev, skiprev=dest)
 return stats
 
-def _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs, rebaseobsskipped):
+def _checkobsrebase(repo, ui, rebaseobsrevs, rebaseobsskipped):
 """
 Abort if rebase will create divergence or rebase is noop because of markers
 
 `rebaseobsrevs`: set of obsolete revision in source
-`rebasesetrevs`: set of revisions to be rebased from source
 `rebaseobsskipped`: set of revisions from source skipped because they have
 successors in destination
 """


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Updated, 32 lines] D24: rebase: remove revprecursor and revpruned states (BC)

2017-07-14 Thread quark (Jun Wu)
quark updated this revision to Diff 158.
Herald added a reviewer: hg-reviewers.
This revision now requires review to proceed.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D24?vs=40=158

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

Index: tests/test-rebase-obsolete.t
===
--- tests/test-rebase-obsolete.t
+++ tests/test-rebase-obsolete.t
@@ -969,10 +969,10 @@
   2:1e9a3c00cbe9 b (no-eol)
   $ hg rebase -r 2 -d 3 --config experimental.evolution.track-operation=1
   note: not rebasing 2:1e9a3c00cbe9 "b" (mybook), already in destination as 
3:be1832deae9a "b"
-Check that working directory was updated to rev 3 although rev 2 was skipped
+Check that working directory was not updated to rev 3 because rev 2 was skipped
 during the rebase operation
   $ hg log -r .
-  3:be1832deae9a b (no-eol)
+  2:1e9a3c00cbe9 b (no-eol)
 
 Check that bookmark was not moved to rev 3 if rev 2 was skipped during the
 rebase operation. This makes sense because if rev 2 has a successor, the
Index: hgext/rebase.py
===
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -62,10 +62,10 @@
 revtodo = -1
 nullmerge = -2
 revignored = -3
-# successor in rebase destination
-revprecursor = -4
-# plain prune (no successor)
-revpruned = -5
+
+# legacy revstates no longer needed in current code
+# -4: revprecursor, -5: revpruned
+legacystates = {'-4', '-5'}
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -231,8 +231,9 @@
 activebookmark = l
 else:
 oldrev, newrev = l.split(':')
-if newrev in (str(nullmerge), str(revignored),
-  str(revprecursor), str(revpruned)):
+if newrev in legacystates:
+continue
+if newrev in (str(nullmerge), str(revignored)):
 state[repo[oldrev].rev()] = int(newrev)
 elif newrev == nullid:
 state[repo[oldrev].rev()] = revtodo
@@ -308,9 +309,6 @@
 return abort(self.repo, self.originalwd, self.dest,
  self.state, activebookmark=self.activebookmark)
 
-obsrevs = (r for r, st in self.state.items() if st == revprecursor)
-self._handleskippingobsolete(self.state.keys(), obsrevs, self.dest)
-
 def _preparenewrebase(self, dest, rebaseset):
 if dest is None:
 return _nothingtorebase()
@@ -445,10 +443,6 @@
 ui.debug('ignoring null merge rebase of %s\n' % rev)
 elif self.state[rev] == revignored:
 ui.status(_('not rebasing ignored %s\n') % desc)
-elif self.state[rev] == revprecursor:
-pass
-elif self.state[rev] == revpruned:
-pass
 else:
 ui.status(_('already rebased %s as %s\n') %
   (desc, repo[self.state[rev]]))
@@ -494,9 +488,7 @@
 # restore original working directory
 # (we do this before stripping)
 newwd = self.state.get(self.originalwd, self.originalwd)
-if newwd == revprecursor:
-newwd = self.obsoletenotrebased[self.originalwd]
-elif newwd < 0:
+if newwd < 0:
 # original directory is a parent of rebase set root or ignored
 newwd = self.originalwd
 if newwd not in [c.rev() for c in repo[None].parents()]:
@@ -1322,14 +1314,14 @@
 succ = obsoletenotrebased[r]
 if succ is None:
 msg = _('note: not rebasing %s, it has no successor\n') % desc
-state[r] = revpruned
+del state[r]
 else:
 destctx = unfi[succ]
 destdesc = '%d:%s "%s"' % (destctx.rev(), destctx,
destctx.description().split('\n', 1)[0])
 msg = (_('note: not rebasing %s, already in destination as %s\n')
% (desc, destdesc))
-state[r] = revprecursor
+del state[r]
 repo.ui.status(msg)
 return originalwd, dest.rev(), state
 


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Updated, 27 lines] D23: rebase: move obsoleted not rebased messages earlier (BC)

2017-07-14 Thread quark (Jun Wu)
quark updated this revision to Diff 157.
Herald added a reviewer: hg-reviewers.
This revision now requires review to proceed.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D23?vs=39=157

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

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

Index: tests/test-rebase-obsolete.t
===
--- tests/test-rebase-obsolete.t
+++ tests/test-rebase-obsolete.t
@@ -204,8 +204,8 @@
   o  0:cd010b8cd998 A
   
   $ hg rebase --source 'desc(B)' --dest 'tip' --config 
experimental.rebaseskipobsolete=True
+  note: not rebasing 9:08483444fef9 "D", already in destination as 
11:4596109a6a43 "D"
   rebasing 8:8877864f1edb "B"
-  note: not rebasing 9:08483444fef9 "D", already in destination as 
11:4596109a6a43 "D"
   rebasing 10:5ae4c968c6ac "C"
   $ hg debugobsolete
   42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 0 
{cd010b8cd998f3981a5a8115f94f8da4ab506089} (*) {'user': 'test'} (glob)
@@ -711,8 +711,8 @@
   
   $ hg debugobsolete `hg log -r 7 -T '{node}\n'` --config 
experimental.evolution=all
   $ hg rebase -d 6 -r "4::"
+  note: not rebasing 7:360bbaa7d3ce "O", it has no successor
   rebasing 4:ff2c4d47b71d "C"
-  note: not rebasing 7:360bbaa7d3ce "O", it has no successor
   rebasing 8:8d47583e023f "P" (tip)
 
 If all the changeset to be rebased are obsolete and present in the 
destination, we
@@ -877,6 +877,7 @@
   |
   ~
   $ hg rebase -r ".^^ + .^ + ." -d 19
+  note: not rebasing 21:8b31da3c4919 "dummy change", already in destination as 
19:601db7a18f51 "dummy change successor"
   rebasing 20:b82fb57ea638 "willconflict second version"
   merging willconflict
   warning: conflicts while merging willconflict! (edit, then use 'hg resolve 
--mark')
@@ -888,7 +889,6 @@
   continue: hg rebase --continue
   $ hg rebase --continue
   rebasing 20:b82fb57ea638 "willconflict second version"
-  note: not rebasing 21:8b31da3c4919 "dummy change", already in destination as 
19:601db7a18f51 "dummy change successor"
   rebasing 22:7bdc8a87673d "dummy change" (tip)
   $ cd ..
 
Index: hgext/rebase.py
===
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -446,14 +446,9 @@
 elif self.state[rev] == revignored:
 ui.status(_('not rebasing ignored %s\n') % desc)
 elif self.state[rev] == revprecursor:
-destctx = repo[self.obsoletenotrebased[rev]]
-descdest = '%d:%s "%s"' % (destctx.rev(), destctx,
-   destctx.description().split('\n', 1)[0])
-msg = _('note: not rebasing %s, already in destination as 
%s\n')
-ui.status(msg % (desc, descdest))
+pass
 elif self.state[rev] == revpruned:
-msg = _('note: not rebasing %s, it has no successor\n')
-ui.status(msg % desc)
+pass
 else:
 ui.status(_('already rebased %s as %s\n') %
   (desc, repo[self.state[rev]]))
@@ -1321,11 +1316,21 @@
 rebasedomain = set(repo.revs('%ld::%ld', rebaseset, rebaseset))
 for ignored in set(rebasedomain) - set(rebaseset):
 state[ignored] = revignored
+unfi = repo.unfiltered()
 for r in obsoletenotrebased:
-if obsoletenotrebased[r] is None:
+desc = _ctxdesc(unfi[r])
+succ = obsoletenotrebased[r]
+if succ is None:
+msg = _('note: not rebasing %s, it has no successor\n') % desc
 state[r] = revpruned
 else:
+destctx = unfi[succ]
+destdesc = '%d:%s "%s"' % (destctx.rev(), destctx,
+   destctx.description().split('\n', 1)[0])
+msg = (_('note: not rebasing %s, already in destination as %s\n')
+   % (desc, destdesc))
 state[r] = revprecursor
+repo.ui.status(msg)
 return originalwd, dest.rev(), state
 
 def clearrebased(ui, repo, state, skipped, collapsedas=None):


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Updated, 257 lines] D21: rebase: rewrite defineparents

2017-07-14 Thread quark (Jun Wu)
quark updated this revision to Diff 156.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D21?vs=37=156

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

AFFECTED FILES
  hgext/rebase.py

CHANGE DETAILS

Index: hgext/rebase.py
===
--- hgext/rebase.py
+++ hgext/rebase.py
@@ -66,7 +66,6 @@
 revprecursor = -4
 # plain prune (no successor)
 revpruned = -5
-revskipped = (revignored, revprecursor, revpruned)
 
 cmdtable = {}
 command = registrar.command(cmdtable)
@@ -390,10 +389,7 @@
 ui.status(_('rebasing %s\n') % desc)
 ui.progress(_("rebasing"), pos, ("%d:%s" % (rev, ctx)),
 _('changesets'), total)
-p1, p2, base = defineparents(repo, rev, self.dest,
- self.state,
- self.destancestors,
- self.obsoletenotrebased)
+p1, p2, base = defineparents(repo, rev, self.dest, self.state)
 self.storestatus()
 storecollapsemsg(repo, self.collapsemsg)
 if len(repo[None].parents()) == 2:
@@ -463,9 +459,7 @@
 repo, ui, opts = self.repo, self.ui, self.opts
 if self.collapsef and not self.keepopen:
 p1, p2, _base = defineparents(repo, min(self.state),
-  self.dest, self.state,
-  self.destancestors,
-  self.obsoletenotrebased)
+  self.dest, self.state)
 editopt = opts.get('edit')
 editform = 'rebase.collapse'
 if self.collapsemsg:
@@ -883,15 +877,6 @@
 copies.duplicatecopies(repo, rev, p1rev, skiprev=dest)
 return stats
 
-def nearestrebased(repo, rev, state):
-"""return the nearest ancestors of rev in the rebase result"""
-rebased = [r for r in state if state[r] > nullmerge]
-candidates = repo.revs('max(%ld  and (::%d))', rebased, rev)
-if candidates:
-return state[candidates.first()]
-else:
-return None
-
 def _checkobsrebase(repo, ui, rebaseobsrevs, rebasesetrevs, rebaseobsskipped):
 """
 Abort if rebase will create divergence or rebase is noop because of markers
@@ -915,107 +900,157 @@
   "experimental.allowdivergence=True")
 raise error.Abort(msg % (",".join(divhashes),), hint=h)
 
-def defineparents(repo, rev, dest, state, destancestors,
-  obsoletenotrebased):
-'Return the new parent relationship of the revision that will be rebased'
-parents = repo[rev].parents()
-p1 = p2 = nullrev
-rp1 = None
+def adjusteddest(repo, rev, prev, dest, state):
+"""adjust rebase destination given the current rebase state
+
+rev is being rebased, prev is one of its parent.
+
+For example, when rebase -r 'B+C+E' -d F, rebase will first move B to B', C
+to C', and when it's checking E:
 
-p1n = parents[0].rev()
-if p1n in destancestors:
-p1 = dest
-elif p1n in state:
-if state[p1n] == nullmerge:
-p1 = dest
-elif state[p1n] in revskipped:
-p1 = nearestrebased(repo, p1n, state)
-if p1 is None:
-p1 = dest
-else:
-p1 = state[p1n]
-else: # p1n external
-p1 = dest
-p2 = p1n
+B' <- written during the rebase
+|
+F <- original destination of B, E
+|
+| E <- rev, which is being rebased
+| |
+| D <- prev, one parent of rev being checked
+| |
+| x <- skipped
+| |
+| C <- rebased as C'   C' <- written during the rebase
+| ||
+| B <- rebased as B'   G <- destination of C, separate subgraph
+|/
+A
+
+The destination will be adjusted from F to B'.
+"""
+if prev != nullrev:
+# interesting rebase source - having a same dest and is rebased
+source = [s for s, d in state.items() if d > 0]
+candidate = repo.revs('max(%ld and (::%d))', source, prev).first()
+if candidate is not None:
+return state[candidate]
+return dest
 
-if len(parents) == 2 and parents[1].rev() not in destancestors:
-p2n = parents[1].rev()
-# interesting second parent
-if p2n in state:
-if p1 == dest: # p1n in destancestors or external
-p1 = state[p2n]
-if p1 == revprecursor:
-rp1 = obsoletenotrebased[p2n]
-elif state[p2n] in revskipped:
-p2 = nearestrebased(repo, p2n, state)
-if p2 is None:
-# no ancestors rebased yet, detach
-p2 = 

[Differential] [Commented On] D21: rebase: rewrite defineparents

2017-07-14 Thread quark (Jun Wu)
quark added inline comments.

INLINE COMMENTS

> durin42 wrote in rebase.py:910
> I can't figure out what this comment is trying to tell me. Why on earth 
> would, given the graph I see, rebase rewrite my explicit 'hg rebase -r E -d 
> F' into having B' as the destination?

Good catch. Will add more text here.

> durin42 wrote in rebase.py:928
> Again, I'm confused. What's the rebase operation in play that is linearizing 
> here? I don't even know how I'd spell that on the command line.

This is for multi-dest. I'll move it to a future patch.

> durin42 wrote in rebase.py:964
> Could you expand this docstring to explain what this means? I think that 
> might make the whole change easier to review.

This docstring was unchanged - it is the same as the original function.

> durin42 wrote in rebase.py:1044
> Define ALLSRC - it's not in the codebase prior to this change.

Side effect of splitting. Will avoid using ALLSRC.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[PATCH 2 of 2 V3] commitextras: check the format of the arguments and no internal key is used

2017-07-14 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1499856010 -19800
#  Wed Jul 12 16:10:10 2017 +0530
# Node ID 2cbccf36af1bd0d9ae9df1ad5fd4a7f8d870ae6c
# Parent  e51d188da49636884ae6c0df94f501e84436b857
# EXP-Topic fbext
commitextras: check the format of the arguments and no internal key is used

This patch adds check to make the arguments are passed as KEY=VALUE and no key
which is used internally is passed.

This patch also adds test for the extension.

diff --git a/hgext/commitextras.py b/hgext/commitextras.py
--- a/hgext/commitextras.py
+++ b/hgext/commitextras.py
@@ -12,6 +12,7 @@
 from mercurial.i18n import _
 from mercurial import (
 commands,
+error,
 extensions,
 registrar,
 )
@@ -20,6 +21,10 @@
 command = registrar.command(cmdtable)
 testedwith = 'ships-with-hg-core'
 
+usedinternally = set(['amend_source', 'branch', 'histedit_source', 'topic',
+'rebase_source', 'intermediate-source', '__touch-noise__',
+'source', 'transplant_source'])
+
 def extsetup(ui):
 entry = extensions.wrapcommand(commands.table, 'commit', _commit)
 options = entry[1]
@@ -33,7 +38,15 @@
 extras = opts.get('extra')
 if extras:
 for raw in extras:
+if '=' not in raw:
+msg = _("unable to parse '%s', should follow "
+"KEY=VALUE format")
+raise error.Abort(msg % raw)
 k, v = raw.split('=', 1)
+if k in usedinternally:
+msg = _("key '%s' is used internally, can't be set "
+"manually")
+raise error.Abort(msg % k)
 inneropts['extra'][k] = v
 return origcommit(*innerpats, **inneropts)
 
diff --git a/tests/test-commit.t b/tests/test-commit.t
--- a/tests/test-commit.t
+++ b/tests/test-commit.t
@@ -124,6 +124,24 @@
   $ hg tip --template '{date|isodate}\n' | grep '1970'
   [1]
 
+Using the advanced --extra flag
+
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "commitextras=" >> $HGRCPATH
+  $ hg status
+  ? baz
+  ? quux
+  $ hg add baz
+  $ hg commit -m "adding extras" --extra sourcehash=foo --extra oldhash=bar
+  $ hg log -r . -T '{extras % "{extra}\n"}'
+  branch=default
+  oldhash=bar
+  sourcehash=foo
+  $ hg add quux
+  $ hg commit -m "adding internal used extras" --extra amend_source=hash
+  abort: key 'amend_source' is used internally, can't be set manually
+  [255]
+
 Make sure we do not obscure unknown requires file entries (issue2649)
 
   $ echo foo >> foo
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2 V3] commitextras: move fb extension to core which add extras to a commit

2017-07-14 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1499799225 -19800
#  Wed Jul 12 00:23:45 2017 +0530
# Node ID e51d188da49636884ae6c0df94f501e84436b857
# Parent  80e1331a7fe970f3e56fde9044949d72d3afdf30
# EXP-Topic fbext
commitextras: move fb extension to core which add extras to a commit

This patch moves the Facebook extension to add extra fields to a commit to a
in-core extension.

diff --git a/hgext/commitextras.py b/hgext/commitextras.py
new file mode 100644
--- /dev/null
+++ b/hgext/commitextras.py
@@ -0,0 +1,45 @@
+# commitextras.py
+#
+# Copyright 2013 Facebook, Inc.
+#
+# This software may be used and distributed according to the terms of the
+# GNU General Public License version 2 or any later version.
+
+'''adds a new flag extras to commit'''
+
+from __future__ import absolute_import
+
+from mercurial.i18n import _
+from mercurial import (
+commands,
+extensions,
+registrar,
+)
+
+cmdtable = {}
+command = registrar.command(cmdtable)
+testedwith = 'ships-with-hg-core'
+
+def extsetup(ui):
+entry = extensions.wrapcommand(commands.table, 'commit', _commit)
+options = entry[1]
+options.append(('', 'extra', [],
+_('set a changeset\'s extra values'), _("KEY=VALUE")))
+
+def _commit(orig, ui, repo, *pats, **opts):
+origcommit = repo.commit
+try:
+def _wrappedcommit(*innerpats, **inneropts):
+extras = opts.get('extra')
+if extras:
+for raw in extras:
+k, v = raw.split('=', 1)
+inneropts['extra'][k] = v
+return origcommit(*innerpats, **inneropts)
+
+# This __dict__ logic is needed because the normal
+# extension.wrapfunction doesn't seem to work.
+repo.__dict__['commit'] = _wrappedcommit
+return orig(ui, repo, *pats, **opts)
+finally:
+del repo.__dict__['commit']
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -254,6 +254,7 @@
censorerase file content at a given revision
churn command to display statistics about repository history
clonebundles  advertise pre-generated bundles to seed clones
+   commitextras  adds a new flag extras to commit
convert   import revisions from foreign VCS repositories into
  Mercurial
eol   automatically manage newlines in repository files
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Commented On] D30: merge: Removed sorting in casefolding detection, for a slight performance win

2017-07-14 Thread alex_gaynor (Alex Gaynor)
alex_gaynor added a comment.


  Going to note that I'm less confident in the correctness of the second change 
than I am the first.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: alex_gaynor, durin42, dsp
Cc: quark, krbullock, dsp, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Commented On] D30: merge: Removed sorting in casefolding detection, for a slight performance win

2017-07-14 Thread alex_gaynor (Alex Gaynor)
alex_gaynor added a comment.


  Not quite sure this is science, but 
  
  First set of numbers is `tip`, second is with my patch:
  
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
9.49 real10.23 user 3.13 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
4.74 real 7.59 user 2.73 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.45 real 7.32 user 2.66 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
4.83 real 7.50 user 2.66 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.64 real 7.55 user 2.69 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
5.09 real 7.87 user 2.67 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
5.39 real 8.13 user 2.74 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
5.27 real 8.00 user 2.70 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.45 real 7.68 user 2.58 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
4.93 real 7.72 user 2.61 sys
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.90 real 6.91 user 2.81 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
3.99 real 6.81 user 2.52 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.02 real 7.00 user 2.61 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
4.82 real 7.42 user 2.69 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.60 real 7.80 user 2.78 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
4.11 real 7.77 user 2.73 sys
~/p/mozilla-central ❯❯❯ time ~/projects/hg/hg up 
consolidate-sandbox-disable; time ~/projects/hg/hg up central
4324 files updated, 0 files merged, 491 files removed, 0 files unresolved
(activating bookmark consolidate-sandbox-disable)
4.24 real 7.74 user 2.77 sys
4654 files updated, 0 files merged, 161 files removed, 0 files unresolved
(leaving bookmark consolidate-sandbox-disable)
4.35 real 7.80 user 2.78 sys

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  

[Differential] [Commented On] D30: merge: Removed sorting in casefolding detection, for a slight performance win

2017-07-14 Thread durin42 (Augie Fackler)
durin42 added a comment.


  Ah, I see. Alex, do you have any idea what the performance numbers on this 
are like, anecdotally on your mozilla repo?

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: alex_gaynor, durin42, dsp
Cc: quark, krbullock, dsp, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Accepted] D22: rebase: extract ctx description logic to a function

2017-07-14 Thread durin42 (Augie Fackler)
durin42 accepted this revision.
durin42 added a comment.


  Once d21 is done, this looks fine.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: quark, phillco, durin42
Cc: durin42, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Accepted] D25: rebase: remove messages for nullmerge and revignored (BC)

2017-07-14 Thread durin42 (Augie Fackler)
durin42 accepted this revision.
durin42 added a comment.
This revision is now accepted and ready to land.


  Once d21 is done, this looks fine.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Accepted] D23: rebase: move obsoleted not rebased messages earlier (BC)

2017-07-14 Thread durin42 (Augie Fackler)
durin42 accepted this revision.
durin42 added a comment.
This revision is now accepted and ready to land.


  Once d21 is done, this looks fine.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Requested Changes] D21: rebase: rewrite defineparents

2017-07-14 Thread durin42 (Augie Fackler)
durin42 requested changes to this revision.
durin42 added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> rebase.py:910
>  
> -p1n = parents[0].rev()
> -if p1n in destancestors:
> -p1 = dest
> -elif p1n in state:
> -if state[p1n] == nullmerge:
> -p1 = dest
> -elif state[p1n] in revskipped:
> -p1 = nearestrebased(repo, p1n, state)
> -if p1 is None:
> -p1 = dest
> -else:
> -p1 = state[p1n]
> -else: # p1n external
> -p1 = dest
> -p2 = p1n
> +B' <- written during the rebase
> +|

I can't figure out what this comment is trying to tell me. Why on earth would, 
given the graph I see, rebase rewrite my explicit 'hg rebase -r E -d F' into 
having B' as the destination?

> rebase.py:928
> +
> +Besides, adjust dest according to existing rebase information. For 
> example,
> +

Again, I'm confused. What's the rebase operation in play that is linearizing 
here? I don't even know how I'd spell that on the command line.

> rebase.py:964
> +def defineparents(repo, rev, dest, state):
> +'Return the new parent relationship of the revision that will be rebased'
> +cl = repo.changelog

Could you expand this docstring to explain what this means? I think that might 
make the whole change easier to review.

> rebase.py:1044
> +else:
> +# Prefer merge base candidates in (ALLSRC::). Because they are 
> usually
> +# not calculable from changelog DAG alone. For example,

Define ALLSRC - it's not in the codebase prior to this change.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Accepted] D24: rebase: remove revprecursor and revpruned states (BC)

2017-07-14 Thread durin42 (Augie Fackler)
durin42 accepted this revision.
durin42 added a comment.
This revision is now accepted and ready to land.


  Once d21 is done, this looks fine.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH 2 of 3] configitems: use codemod script to register coreconfigitems

2017-07-14 Thread Martin von Zweigbergk via Mercurial-devel
On Fri, Jul 14, 2017 at 11:59 AM, Augie Fackler  wrote:
>
>> On Jul 14, 2017, at 14:58, Jun Wu  wrote:
>>
>> Excerpts from Augie Fackler's message of 2017-07-14 14:39:17 -0400:
>>> Urg. This is kind of unreviewable, because it's gathering configitems
>>> from everywhere and splatting them in one big file, so it's hard to
>>> audit defaults etc.
>>
>> Why is audit needed if defaults are written by code, not human?
>
> Because I'd like to actually read through things and make sure it's behaving 
> sensibly.
>
>>
>>> Could we maybe migrate one file's config items at a time to
>>> configitems.py? I know it'd be a huge series, but I could rip through
>>> that extremely quickly via mail, whereas this big hairball is going to
>>> be very hard to check.
>>
>> Per file is not a good idea, since if two files have "config('a', 'b',
>> 'c')", they need to be changed in a single patch.
>
> Could we break it down by config section or something then?

I'm fine with it being a single patch. I prefer that to 130 patches
actually. But that's because it's generated, not otherwise. I did some
spot-checking and it all looked correct. Okay if I queue a V2 that
includes the script in the message, Augie?


> ___
> 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 2 of 3] configitems: use codemod script to register coreconfigitems

2017-07-14 Thread Augie Fackler

> On Jul 14, 2017, at 14:58, Jun Wu  wrote:
> 
> Excerpts from Augie Fackler's message of 2017-07-14 14:39:17 -0400:
>> Urg. This is kind of unreviewable, because it's gathering configitems
>> from everywhere and splatting them in one big file, so it's hard to
>> audit defaults etc.
> 
> Why is audit needed if defaults are written by code, not human?

Because I'd like to actually read through things and make sure it's behaving 
sensibly.

> 
>> Could we maybe migrate one file's config items at a time to
>> configitems.py? I know it'd be a huge series, but I could rip through
>> that extremely quickly via mail, whereas this big hairball is going to
>> be very hard to check.
> 
> Per file is not a good idea, since if two files have "config('a', 'b',
> 'c')", they need to be changed in a single patch.

Could we break it down by config section or something then?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 3] configitems: use codemod script to register coreconfigitems

2017-07-14 Thread Jun Wu
Excerpts from Augie Fackler's message of 2017-07-14 14:39:17 -0400:
> Urg. This is kind of unreviewable, because it's gathering configitems
> from everywhere and splatting them in one big file, so it's hard to
> audit defaults etc.

Why is audit needed if defaults are written by code, not human?

> Could we maybe migrate one file's config items at a time to
> configitems.py? I know it'd be a huge series, but I could rip through
> that extremely quickly via mail, whereas this big hairball is going to
> be very hard to check.

Per file is not a good idea, since if two files have "config('a', 'b',
'c')", they need to be changed in a single patch.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Commented On] D37: phabricator: avoid calling differential.getrawdiff

2017-07-14 Thread durin42 (Augie Fackler)
durin42 added a comment.


  In https://phab.mercurial-scm.org/D37#1094, @quark wrote:
  
  > If the time to fetch a stack is not a concern, I can drop this.
  
  
  I'm not worried about it for now. Speed of `hg phabread` is nowhere near even 
being a pain point for me (the web UI is a much bigger issue)

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: quark, durin42
Cc: 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] configitems: use devel.all-warnings to replace devel.all

2017-07-14 Thread Augie Fackler
On Wed, Jul 12, 2017 at 06:22:48PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1499898287 25200
> #  Wed Jul 12 15:24:47 2017 -0700
> # Node ID 61035c132ae5643796a2a5b1571d5cc7f350c133
> # Parent  a0df53ed55b26539c62584231cfcb567594ab34a
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #  hg pull https://bitbucket.org/quark-zju/hg-draft -r 
> 61035c132ae5
> configitems: use devel.all-warnings to replace devel.all
>
> It appears to be a misspell in patch.py.
>
> diff --git a/mercurial/configitems.py b/mercurial/configitems.py
> --- a/mercurial/configitems.py
> +++ b/mercurial/configitems.py
> @@ -95,7 +95,4 @@ coreconfigitem('commands', 'update.requi
>  default=False,
>  )
> -coreconfigitem('devel', 'all',
> -default=False,
> -)
>  coreconfigitem('devel', 'all-warnings',
>  default=False,
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py

Nice catch. I've queued this with only the patch.py hunk included (and
a tweak to the commit message).

> @@ -2568,5 +2568,5 @@ def trydiff(repo, revs, ctx1, ctx2, modi
>  gitmode = {'l': '12', 'x': '100755', '': '100644'}
>
> -if relroot != '' and (repo.ui.configbool('devel', 'all')
> +if relroot != '' and (repo.ui.configbool('devel', 'all-warnings')
>or repo.ui.configbool('devel', 'check-relroot')):
>  for f in modified + added + removed + copy.keys() + copy.values():
> ___
> 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 2 of 3] configitems: use codemod script to register coreconfigitems

2017-07-14 Thread Augie Fackler
On Wed, Jul 12, 2017 at 06:22:47PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1499898287 25200
> #  Wed Jul 12 15:24:47 2017 -0700
> # Node ID a0df53ed55b26539c62584231cfcb567594ab34a
> # Parent  695702ea1caedaeeed9a6d63473c0e338adf35f4
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #  hg pull https://bitbucket.org/quark-zju/hg-draft -r 
> a0df53ed55b2
> configitems: use codemod script to register coreconfigitems

Urg. This is kind of unreviewable, because it's gathering configitems
from everywhere and splatting them in one big file, so it's hard to
audit defaults etc.

Could we maybe migrate one file's config items at a time to
configitems.py? I know it'd be a huge series, but I could rip through
that extremely quickly via mail, whereas this big hairball is going to
be very hard to check.

>
> This is the result of running:
>
>   contrib/codemod/codemod_configitems.py mercurial/**/*.py
>
> Plus 2 manual fixes (to make test pass) according to the warning printed by
> the script:
>
>   [warn] mercurial/exchange.py: experimental.bundle2-output-capture: default 
> needs manual removal
>   [warn] mercurial/localrepo.py: experimental.hook-track-tags: default needs 
> manual removal
>
> The script cannot do that automatically because RedBaron cannot figure out
> how to indent things [1].
>
> [1]: https://github.com/PyCQA/redbaron/issues/100
>
> diff --git a/hgext/journal.py b/hgext/journal.py
> --- a/hgext/journal.py
> +++ b/hgext/journal.py
> @@ -303,5 +303,5 @@ class journalstorage(object):
>  l = lock.lock(
>  vfs, 'namejournal.lock',
> -int(self.ui.config("ui", "timeout", "600")), desc=desc)
> +int(self.ui.config("ui", "timeout")), desc=desc)
>  self.ui.warn(_("got lock after %s seconds\n") % l.delay)
>  self._lockref = weakref.ref(l)
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -974,5 +974,5 @@ def overridearchive(orig, repo, dest, no
>  archiver = archival.archivers[kind](dest, mtime or ctx.date()[0])
>
> -if repo.ui.configbool("ui", "archivemeta", True):
> +if repo.ui.configbool("ui", "archivemeta"):
>  write('.hg_archival.txt', 0o644, False,
>lambda: archival.buildmetadata(ctx))
> diff --git a/mercurial/archival.py b/mercurial/archival.py
> --- a/mercurial/archival.py
> +++ b/mercurial/archival.py
> @@ -308,5 +308,5 @@ def archive(repo, dest, node, kind, deco
>  archiver = archivers[kind](dest, mtime or ctx.date()[0])
>
> -if repo.ui.configbool("ui", "archivemeta", True):
> +if repo.ui.configbool("ui", "archivemeta"):
>  name = '.hg_archival.txt'
>  if not matchfn or matchfn(name):
> diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
> --- a/mercurial/bookmarks.py
> +++ b/mercurial/bookmarks.py
> @@ -523,5 +523,5 @@ def updatefromremote(ui, repo, remotemar
>  status = ui.status
>  warn = ui.warn
> -if ui.configbool('ui', 'quietbookmarkmove', False):
> +if ui.configbool('ui', 'quietbookmarkmove'):
>  status = warn = ui.debug
>
> diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
> --- a/mercurial/bundle2.py
> +++ b/mercurial/bundle2.py
> @@ -1799,5 +1799,5 @@ def handleobsmarker(op, inpart):
>  tr = op.gettransaction()
>  markerdata = inpart.read()
> -if op.ui.config('experimental', 'obsmarkers-exchange-debug', False):
> +if op.ui.config('experimental', 'obsmarkers-exchange-debug'):
>  op.ui.write(('obsmarker-exchange: %i bytes received\n')
>  % len(markerdata))
> diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
> --- a/mercurial/chgserver.py
> +++ b/mercurial/chgserver.py
> @@ -486,5 +486,5 @@ class chgunixservicehandler(object):
>  def __init__(self, ui):
>  self.ui = ui
> -self._idletimeout = ui.configint('chgserver', 'idletimeout', 3600)
> +self._idletimeout = ui.configint('chgserver', 'idletimeout')
>  self._lastactive = time.time()
>
> @@ -498,5 +498,5 @@ class chgunixservicehandler(object):
>  def _inithashstate(self, address):
>  self._baseaddress = address
> -if self.ui.configbool('chgserver', 'skiphash', False):
> +if self.ui.configbool('chgserver', 'skiphash'):
>  self._hashstate = None
>  self._realaddress = address
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -209,5 +209,5 @@ def recordfilter(ui, originalhunks, oper
>  """
>  usecurses = crecordmod.checkcurses(ui)
> -testfile = ui.config('experimental', 'crecordtest', None)
> +testfile = ui.config('experimental', 'crecordtest')
>  oldwrite = setupwrapcolorwrite(ui)
>  try:
> @@ -1688,5 +1688,5 @@ def _lookuplogtemplate(ui, tmpl, style):
>

Re: [PATCH 1 of 3] contrib: add a codemod script to write coreconfigitem

2017-07-14 Thread Augie Fackler
On Wed, Jul 12, 2017 at 06:22:46PM -0700, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1499891115 25200
> #  Wed Jul 12 13:25:15 2017 -0700
> # Node ID 695702ea1caedaeeed9a6d63473c0e338adf35f4
> # Parent  26e4ba058215e536d3827befbea99ff6203d35f8
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #  hg pull https://bitbucket.org/quark-zju/hg-draft -r 
> 695702ea1cae
> contrib: add a codemod script to write coreconfigitem
>
> The coreconfigitem migration seems possible to be automatized. I have tried
> RedBaron [1] which seems easy to use and suitable for this usecase. The
> script is kept in contrib in case we want to re-run it in the future to
> cover new config options. [web] section is ignored now since its usage of
> config is a bit weird and we will have issues like check-config complaining
> undocumented web.* after codemod.
>
> Note that the script only works for core hg code and does not work for
> extension code now (it writes to mercurial/configitems.py). This gives other
> people a chance to learn this area and improve the codemod script.
>
> [1]: http://redbaron.pycqa.org/
>
> diff --git a/contrib/codemod/codemod_configitems.py 
> b/contrib/codemod/codemod_configitems.py
> new file mode 100755
> --- /dev/null
> +++ b/contrib/codemod/codemod_configitems.py

This is going to seem highly nitpicky, but can we just call this
"contrib/codemod/configitems.py" instead of stuttering the codemod
part?

> @@ -0,0 +1,182 @@
> +#!/usr/bin/env python
> +# codemod_configitems.py - codemod tool to fill configitems
> +#
> +# Copyright 2017 Facebook, Inc.
> +#
> +# This software may be used and distributed according to the terms of the
> +# GNU General Public License version 2 or any later version.
> +from __future__ import absolute_import, print_function
> +
> +import os
> +import sys
> +
> +import redbaron
> +
> +def readpath(path):
> +with open(path) as f:
> +return f.read()
> +
> +def writepath(path, content):
> +with open(path, 'w') as f:
> +f.write(content)
> +
> +_configmethods = {'config', 'configbool', 'configint', 'configbytes',
> +  'configlist', 'configdate'}
> +
> +def extractstring(rnode):
> +"""get the string from a RedBaron string or call_argument node"""
> +while rnode.type != 'string':
> +rnode = rnode.value
> +return rnode.value[1:-1]  # unquote, "'str'" -> "str"
> +
> +def uiconfigitems(red):
> +"""match *.ui.config* pattern, yield (node, method, args, section, 
> name)"""
> +for node in red.find_all('atomtrailers'):
> +entry = None
> +try:
> +obj = node[-3].value
> +method = node[-2].value
> +args = node[-1]
> +section = args[0].value
> +name = args[1].value
> +if (obj in ('ui', 'self') and method in _configmethods
> +and section.type == 'string' and name.type == 'string'):
> +entry = (node, method, args, extractstring(section),
> + extractstring(name))
> +except Exception:
> +pass
> +else:
> +if entry:
> +yield entry
> +
> +def coreconfigitems(red):
> +"""match coreconfigitem(...) pattern, yield (node, args, section, 
> name)"""
> +for node in red.find_all('atomtrailers'):
> +entry = None
> +try:
> +args = node[1]
> +section = args[0].value
> +name = args[1].value
> +if (node[0].value == 'coreconfigitem' and section.type == 
> 'string'
> +and name.type == 'string'):
> +entry = (node, args, extractstring(section),
> + extractstring(name))
> +except Exception:
> +pass
> +else:
> +if entry:
> +yield entry
> +
> +def registercoreconfig(cfgred, section, name, defaultrepr):
> +"""insert coreconfigitem to cfgred AST
> +
> +section and name are plain string, defaultrepr is a string
> +"""
> +# find a place to insert the "coreconfigitem" item
> +entries = list(coreconfigitems(cfgred))
> +for node, args, nodesection, nodename in reversed(entries):
> +if (nodesection, nodename) < (section, name):
> +# insert after this entry
> +node.insert_after(
> +'coreconfigitem(%r, %r,\n'
> +'default=%s,\n'
> +')' % (section, name, defaultrepr))
> +return
> +
> +def main(argv):
> +if not argv:
> +print('Usage: codemod_configitems.py FILES\n'
> +  'For example, FILES could be "{hgext,mercurial}/*/**.py"')
> +dirname = os.path.dirname
> +reporoot = dirname(dirname(dirname(os.path.abspath(__file__
> +
> +# register configitems to this destination
> +cfgpath = os.path.join(reporoot, 'mercurial', 'configitems.py')
> +cfgred = 

Re: [PATCH 10 of 14] obsstore: pass a repository object for initialisation

2017-07-14 Thread Augie Fackler

> On Jul 14, 2017, at 14:27, Boris Feld  wrote:
> 
> On Fri, 2017-07-14 at 14:16 -0400, Augie Fackler wrote:
>>> On Jul 14, 2017, at 14:15, Boris Feld 
>>> wrote:
>>> 
>>> On Fri, 2017-07-14 at 14:11 -0400, Augie Fackler wrote:
 On Sun, Jul 09, 2017 at 07:55:22PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1495197862 -7200
> #  Fri May 19 14:44:22 2017 +0200
> # Node ID 985d753d4f5799f2a332140adedb06efd465d62b
> # Parent  63214f4d9a766761259b650539eede424413e6a2
> # EXP-Topic obs-cache
> obsstore: pass a repository object for initialisation
> 
> The cache will needs a repository object (to grab a 'vfs'), so
> we
> pass a repo object instead of just the 'svfs' and we grab the
> 'svfs'
> from there.
 
 I suspect I'll get to it, but why does this cache want to know
 about
 anything outside of svfs?
 
 I'm pretty uncomfortable (architecturally) with passing all of
 `self`
 into the cache layer.
>>> 
>>> The obscache need the vfs and not the svfs because caches lives in
>>> .hg
>>> and not in .hg/store.
>>> 
>>> Passing the whole repo and grabbing what we need seemed simpler.
>> 
>> It's simpler today, but more of a potential headache later if someone
>> decides to just retain the whole repo in the cache. I'd rather not do
>> it.
> 
> I understand the danger.
> 
> Should we pass vfs and svfs explicitly in the V2 then?

Yep. But let's wait until after the freeze, we've got enough other stuff 
pouring through the list I don't know that we have time to get through another 
round on this series.

(If you can do the first two patches and move branch cache to that 
infrastructure, feel free to send that though)

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


Re: [PATCH 10 of 14] obsstore: pass a repository object for initialisation

2017-07-14 Thread Boris Feld
On Fri, 2017-07-14 at 14:16 -0400, Augie Fackler wrote:
> > On Jul 14, 2017, at 14:15, Boris Feld 
> > wrote:
> > 
> > On Fri, 2017-07-14 at 14:11 -0400, Augie Fackler wrote:
> > > On Sun, Jul 09, 2017 at 07:55:22PM +0200, Boris Feld wrote:
> > > > # HG changeset patch
> > > > # User Boris Feld 
> > > > # Date 1495197862 -7200
> > > > #  Fri May 19 14:44:22 2017 +0200
> > > > # Node ID 985d753d4f5799f2a332140adedb06efd465d62b
> > > > # Parent  63214f4d9a766761259b650539eede424413e6a2
> > > > # EXP-Topic obs-cache
> > > > obsstore: pass a repository object for initialisation
> > > > 
> > > > The cache will needs a repository object (to grab a 'vfs'), so
> > > > we
> > > > pass a repo object instead of just the 'svfs' and we grab the
> > > > 'svfs'
> > > > from there.
> > > 
> > > I suspect I'll get to it, but why does this cache want to know
> > > about
> > > anything outside of svfs?
> > > 
> > > I'm pretty uncomfortable (architecturally) with passing all of
> > > `self`
> > > into the cache layer.
> > 
> > The obscache need the vfs and not the svfs because caches lives in
> > .hg
> > and not in .hg/store.
> > 
> > Passing the whole repo and grabbing what we need seemed simpler.
> 
> It's simpler today, but more of a potential headache later if someone
> decides to just retain the whole repo in the cache. I'd rather not do
> it.

I understand the danger.

Should we pass vfs and svfs explicitly in the V2 then?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4] sslutil: inform the user about how to fix an incomplete certificate chain

2017-07-14 Thread Augie Fackler
On Thu, Jul 13, 2017 at 06:40:08PM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1499899033 14400
> #  Wed Jul 12 18:37:13 2017 -0400
> # Node ID 2000c901f306bc051b3d4fe5f89176f164933f6d
> # Parent  f931e230e7265b024e823c32b50a3167dd9e43a4
> sslutil: inform the user about how to fix an incomplete certificate chain

queued, thanks


(ugh, what a mess)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 12 of 12] bookmarks: use 'applychanges' for bookmark update

2017-07-14 Thread Augie Fackler
On Fri, Jul 14, 2017 at 07:54:10PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1499708423 -7200
> #  Mon Jul 10 19:40:23 2017 +0200
> # Node ID c8af08d67851fae61c1cf459f0f0bf20f61b9298
> # Parent  bbebf6b3d2514134fc750903de90ec515cf4c4d3
> # EXP-Topic tr.changes.bookmarks
> bookmarks: use 'applychanges' for bookmark update

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


mercurial@33476: 39 new changesets

2017-07-14 Thread Mercurial Commits
39 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/8056481caa81
changeset:   33438:8056481caa81
user:Jun Wu 
date:Thu Jul 13 18:31:35 2017 -0700
summary: codemod: simplify nested withs

https://www.mercurial-scm.org/repo/hg/rev/0e114b992e02
changeset:   33439:0e114b992e02
user:Martin von Zweigbergk 
date:Thu Jul 13 09:51:50 2017 -0700
summary: util: remove unused ctxmanager

https://www.mercurial-scm.org/repo/hg/rev/ec306bc6915b
changeset:   33440:ec306bc6915b
user:Adam Simpkins 
date:Wed Jul 12 15:24:07 2017 -0700
summary: dirstate: update backup functions to take full backup filename

https://www.mercurial-scm.org/repo/hg/rev/de7c6ec27d99
changeset:   33441:de7c6ec27d99
user:Jun Wu 
date:Mon Jul 10 22:37:33 2017 -0700
summary: phabricator: respect metadata sent by arc

https://www.mercurial-scm.org/repo/hg/rev/3ab0d5767b54
changeset:   33442:3ab0d5767b54
user:Jun Wu 
date:Mon Jul 10 13:50:50 2017 -0700
summary: phabricator: finding old nodes in batch

https://www.mercurial-scm.org/repo/hg/rev/e48082e0a8d5
changeset:   33443:e48082e0a8d5
user:Jun Wu 
date:Tue Jul 11 08:17:29 2017 -0700
summary: phabricator: verify local tags before trusting them

https://www.mercurial-scm.org/repo/hg/rev/c4e39512a661
changeset:   33444:c4e39512a661
user:Martin von Zweigbergk 
date:Wed Jul 12 11:18:02 2017 -0700
summary: histedit: remove transaction from state object

https://www.mercurial-scm.org/repo/hg/rev/0491004e2233
changeset:   33445:0491004e2233
user:Martin von Zweigbergk 
date:Wed Jul 12 13:17:49 2017 -0700
summary: histedit: create transaction outside of try

https://www.mercurial-scm.org/repo/hg/rev/fad6852cf879
changeset:   33446:fad6852cf879
user:Martin von Zweigbergk 
date:Wed Jul 12 13:57:03 2017 -0700
summary: histedit: extract InterventionRequired transaction handling to 
utils

https://www.mercurial-scm.org/repo/hg/rev/6f4e5e5940a5
changeset:   33447:6f4e5e5940a5
user:Martin von Zweigbergk 
date:Fri Jul 07 14:39:59 2017 -0700
summary: match: write forceincludematcher using unionmatcher

https://www.mercurial-scm.org/repo/hg/rev/04be8aec44a8
changeset:   33448:04be8aec44a8
user:Martin von Zweigbergk 
date:Tue Jul 11 10:46:10 2017 -0700
summary: match: make unionmatcher a proper matcher

https://www.mercurial-scm.org/repo/hg/rev/5747967e257c
changeset:   33449:5747967e257c
user:Boris Feld 
date:Mon Jul 10 22:22:42 2017 +0200
summary: phase: put retractboundary out of the loop in advanceboundary

https://www.mercurial-scm.org/repo/hg/rev/d017f1d37378
changeset:   33450:d017f1d37378
user:Boris Feld 
date:Mon Jul 10 22:18:41 2017 +0200
summary: phases: extract the intermediate set of affected revs

https://www.mercurial-scm.org/repo/hg/rev/e44d54260c32
changeset:   33451:e44d54260c32
user:Boris Feld 
date:Tue Jul 11 02:39:52 2017 +0200
summary: phases: track phase movements in 'advanceboundary'

https://www.mercurial-scm.org/repo/hg/rev/7b25a56366cf
changeset:   33452:7b25a56366cf
user:Boris Feld 
date:Mon Jul 10 23:50:16 2017 +0200
summary: phases: extract the core of boundary retraction in 
'_retractboundary'

https://www.mercurial-scm.org/repo/hg/rev/f6b7617a85bb
changeset:   33453:f6b7617a85bb
user:Boris Feld 
date:Tue Jul 11 03:47:25 2017 +0200
summary: phases: add a 'registernew' method to set new phases

https://www.mercurial-scm.org/repo/hg/rev/3c20d7ef42e1
changeset:   33454:3c20d7ef42e1
user:Boris Feld 
date:Tue Jul 11 01:05:27 2017 +0200
summary: localrepo: use the 'registernew' function to set the phase of new 
commit

https://www.mercurial-scm.org/repo/hg/rev/b1bc8cf3fea8
changeset:   33455:b1bc8cf3fea8
user:Boris Feld 
date:Tue Jul 11 00:59:23 2017 +0200
summary: convert: use the new 'phase.registernew' function

https://www.mercurial-scm.org/repo/hg/rev/ae052d04b89e
changeset:   33456:ae052d04b89e
user:Boris Feld 
date:Tue Jul 11 01:17:36 2017 +0200
summary: phases: rework phase movement code in 'cg.apply' to use 
'registernew'

https://www.mercurial-scm.org/repo/hg/rev/61714c282106
changeset:   33457:61714c282106
user:Boris Feld 
date:Wed Jul 12 23:15:09 2017 +0200
summary: phases: detect when boundaries has been actually retracted


Re: [PATCH 10 of 14] obsstore: pass a repository object for initialisation

2017-07-14 Thread Augie Fackler

> On Jul 14, 2017, at 14:15, Boris Feld  wrote:
> 
> On Fri, 2017-07-14 at 14:11 -0400, Augie Fackler wrote:
>> On Sun, Jul 09, 2017 at 07:55:22PM +0200, Boris Feld wrote:
>>> # HG changeset patch
>>> # User Boris Feld 
>>> # Date 1495197862 -7200
>>> #  Fri May 19 14:44:22 2017 +0200
>>> # Node ID 985d753d4f5799f2a332140adedb06efd465d62b
>>> # Parent  63214f4d9a766761259b650539eede424413e6a2
>>> # EXP-Topic obs-cache
>>> obsstore: pass a repository object for initialisation
>>> 
>>> The cache will needs a repository object (to grab a 'vfs'), so we
>>> pass a repo object instead of just the 'svfs' and we grab the
>>> 'svfs'
>>> from there.
>> 
>> I suspect I'll get to it, but why does this cache want to know about
>> anything outside of svfs?
>> 
>> I'm pretty uncomfortable (architecturally) with passing all of `self`
>> into the cache layer.
> 
> The obscache need the vfs and not the svfs because caches lives in .hg
> and not in .hg/store.
> 
> Passing the whole repo and grabbing what we need seemed simpler.

It's simpler today, but more of a potential headache later if someone decides 
to just retain the whole repo in the cache. I'd rather not do it.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 12 of 14] obscache: use the obscache to compute the obsolete set

2017-07-14 Thread Augie Fackler
On Sun, Jul 09, 2017 at 07:55:24PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1495198021 -7200
> #  Fri May 19 14:47:01 2017 +0200
> # Node ID 3a93e99b0e718befd57a32615a14fd0d3c194456
> # Parent  f8953ed43f8d1b146dcff688030133f0d6123a49
> # EXP-Topic obs-cache
> obscache: use the obscache to compute the obsolete set
>
> Now that we have a cache and that the cache is kept up to date, we can use it 
> to
> speeds up the obsolete set computation. This way, we no longer need to load 
> the
> obsstore for most operation.
>
> On the mercurial-core repository, this provides a significant speed up for
> operation that do not need further obsolescence information:
>
> | command  | before | after |
> | id -r @  |  0.670 | 0.093 |
> | log -r @ |  0.951 | 0.916 |
> | diff |  0.070 | 0.069 |
> | diff -r .~1  |  0.705 | 0.120 |
> | export @ |  0.672 | 0.103 |
> | log -G -r draft()|  1.117 | 1.084 |
> | log -G -r draft()|  1.063 | 1.064 |
> |   -T "{node} {troubles}" ||   |
> | log -G -r tip|  0.658 | 0.086 |
> |   -T "{node} {desc}" ||   |

These timings look pretty good, though I find some of the numbers
underwhelming (eg 'hg log -r @' seems like it shouldn't be anywhere
*near* that slow).

I think given the history here, and that I know Jun has something
related coming in a few weeks, I'm going to put this series on hold
until after 4.3 is done so we can get some comparisons between
approaches, as I believe his solution requires a little less in the
way of creative caching layers.

In more detail: the radixlink approach to speeding up obsmarkers
interests me a lot because it speeds up more than this does, and is
close on the things where they're similar. If I can have one caching
layer instead of two, I'd like that, and given how late in the cycle
it is and the timetable I've heard from Jun I'm happy to let hg 4.3
not get perf wins today and just make 4.4 the release where we get
this sorted out.

>
> The obsstore loading operation usually disappear from execution profile.
>
> The speeds up rely on a couple of different mechanism:
>
> * First, not having to parse the obsstore provides a massive speedup:
>
>   Time spent computing 'obsolete', no obsstore pre-loaded.
>
> before: wall 0.449502 comb 0.46 user 0.42 sys 0.04 (best of 
> 17)
> after:  wall 0.005752 comb 0.01 user 0.01 sys 0.00 (best of 
> 340)
>
> * Second keeping the computation fully in the revision space (no usage of 
> node),
>   raise and extra 4x speedup.
>
>   Time spent computing 'obsolete', obsstore preloaded:
>
> before: wall 0.007684 comb 0.00 user 0.00 sys 0.00 (best of 
> 305)
> after:  wall 0.001928 comb 0.00 user 0.00 sys 0.00 (best of 
> 1250)
>
> To keep the changeset simple, we assume the cache is up to date (from the last
> transaction). This won't be true when both old and new clients access the
> repository. (with the special case of no new transactions since last upgrade).
> We'll address this issue in the next couple of changesets.
>
> This changesets is a first step to install the basic. There are a couple of 
> easy
> improvement that can further improve this cache:
>
>  * Improving handling of outdated cache on read only operation (see above),
>
>  * Avoid reaading the full obsstore data from disk to check the cache key
>(about -4ms, 3x speedup)
>
>  * Optimise the python code to reduce attribute lookup
>(about 25% of the remaining of the time spent there).
>
> diff -r f8953ed43f8d -r 3a93e99b0e71 mercurial/obsolete.py
> --- a/mercurial/obsolete.py   Fri May 19 14:46:46 2017 +0200
> +++ b/mercurial/obsolete.py   Fri May 19 14:47:01 2017 +0200
> @@ -1096,11 +1096,24 @@
>  @cachefor('obsolete')
>  def _computeobsoleteset(repo):
>  """the set of obsolete revisions"""
> -getnode = repo.changelog.node
>  notpublic = _mutablerevs(repo)
> -isobs = repo.obsstore.successors.__contains__
> -obs = set(r for r in notpublic if isobs(getnode(r)))
> -return obs
> +if not notpublic or not repo.obsstore:
> +# all changeset are public, none are obsolete
> +return set()
> +
> +# XXX There are a couple of case where the cache could not be up to date:
> +#
> +# 1) no transaction happened in the repository since the upgrade,
> +# 2) both old and new client touches that repository
> +#
> +# recomputing the whole cache in these case is a bit slower that using 
> the
> +# good old version (parsing markers and checking them). We could add some
> +# logic to fall back to the old way in these cases.
> +obscache = repo.obsstore.obscache
> +obscache.update(repo) # ensure it is up to date:
> +isobs = obscache.get
> +
> +return set(r for r in notpublic if isobs(r))
>
>  @cachefor('unstable')

[Differential] [Commented On] D60: match: remove unused negatematcher

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D60#1166, @durham wrote:
  
  > As I mentioned in IRC, this is actually important for scalability, since I 
think 'visitdir' has to return True for any negatematcher, since it can't know 
what is or isn't relevant to the underlying matcher.
  
  
  It could actually return False if the underlying matcher returns 'all'.
  
  I now realize that that value is poorly documented. What 'all' actually means 
is not just that all subdirectories should be visited, but also that all files 
in them match. See use in treemanifest._match(). I should fix the docstring...

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH 10 of 14] obsstore: pass a repository object for initialisation

2017-07-14 Thread Boris Feld
On Fri, 2017-07-14 at 14:11 -0400, Augie Fackler wrote:
> On Sun, Jul 09, 2017 at 07:55:22PM +0200, Boris Feld wrote:
> > # HG changeset patch
> > # User Boris Feld 
> > # Date 1495197862 -7200
> > #  Fri May 19 14:44:22 2017 +0200
> > # Node ID 985d753d4f5799f2a332140adedb06efd465d62b
> > # Parent  63214f4d9a766761259b650539eede424413e6a2
> > # EXP-Topic obs-cache
> > obsstore: pass a repository object for initialisation
> > 
> > The cache will needs a repository object (to grab a 'vfs'), so we
> > pass a repo object instead of just the 'svfs' and we grab the
> > 'svfs'
> > from there.
> 
> I suspect I'll get to it, but why does this cache want to know about
> anything outside of svfs?
> 
> I'm pretty uncomfortable (architecturally) with passing all of `self`
> into the cache layer.

The obscache need the vfs and not the svfs because caches lives in .hg
and not in .hg/store.

Passing the whole repo and grabbing what we need seemed simpler.

> 
> > 
> > diff -r 63214f4d9a76 -r 985d753d4f57 contrib/perf.py
> > --- a/contrib/perf.py   Fri May 19 14:46:26 2017 +0200
> > +++ b/contrib/perf.py   Fri May 19 14:44:22 2017 +0200
> > @@ -1391,8 +1391,7 @@
> > 
> >  Result is the number of markers in the repo."""
> >  timer, fm = gettimer(ui)
> > -svfs = getsvfs(repo)
> > -timer(lambda: len(obsolete.obsstore(svfs)))
> > +timer(lambda: len(obsolete.obsstore(repo)))
> >  fm.end()
> > 
> >  @command('perflrucachedict', formatteropts +
> > diff -r 63214f4d9a76 -r 985d753d4f57 mercurial/obsolete.py
> > --- a/mercurial/obsolete.py Fri May 19 14:46:26 2017 +0200
> > +++ b/mercurial/obsolete.py Fri May 19 14:44:22 2017 +0200
> > @@ -519,10 +519,10 @@
> >  # 1024 byte should be about 10 markers in average
> >  _obskeyspan = 1024
> > 
> > -def __init__(self, svfs, defaultformat=_fm1version,
> > readonly=False):
> > +def __init__(self, repo, defaultformat=_fm1version,
> > readonly=False):
> >  # caches for various obsolescence related cache
> >  self.caches = {}
> > -self.svfs = svfs
> > +self.svfs = repo.svfs
> >  self._defaultformat = defaultformat
> >  self._readonly = readonly
> > 
> > @@ -799,7 +799,7 @@
> >  if defaultformat is not None:
> >  kwargs['defaultformat'] = defaultformat
> >  readonly = not isenabled(repo, createmarkersopt)
> > -store = obsstore(repo.svfs, readonly=readonly, **kwargs)
> > +store = obsstore(repo, readonly=readonly, **kwargs)
> >  if store and readonly:
> >  ui.warn(_('obsolete feature not enabled but %i markers
> > found!\n')
> >  % len(list(store)))
> > ___
> > 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 10 of 14] obsstore: pass a repository object for initialisation

2017-07-14 Thread Augie Fackler
On Sun, Jul 09, 2017 at 07:55:22PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1495197862 -7200
> #  Fri May 19 14:44:22 2017 +0200
> # Node ID 985d753d4f5799f2a332140adedb06efd465d62b
> # Parent  63214f4d9a766761259b650539eede424413e6a2
> # EXP-Topic obs-cache
> obsstore: pass a repository object for initialisation
>
> The cache will needs a repository object (to grab a 'vfs'), so we
> pass a repo object instead of just the 'svfs' and we grab the 'svfs'
> from there.

I suspect I'll get to it, but why does this cache want to know about
anything outside of svfs?

I'm pretty uncomfortable (architecturally) with passing all of `self`
into the cache layer.

>
> diff -r 63214f4d9a76 -r 985d753d4f57 contrib/perf.py
> --- a/contrib/perf.py Fri May 19 14:46:26 2017 +0200
> +++ b/contrib/perf.py Fri May 19 14:44:22 2017 +0200
> @@ -1391,8 +1391,7 @@
>
>  Result is the number of markers in the repo."""
>  timer, fm = gettimer(ui)
> -svfs = getsvfs(repo)
> -timer(lambda: len(obsolete.obsstore(svfs)))
> +timer(lambda: len(obsolete.obsstore(repo)))
>  fm.end()
>
>  @command('perflrucachedict', formatteropts +
> diff -r 63214f4d9a76 -r 985d753d4f57 mercurial/obsolete.py
> --- a/mercurial/obsolete.py   Fri May 19 14:46:26 2017 +0200
> +++ b/mercurial/obsolete.py   Fri May 19 14:44:22 2017 +0200
> @@ -519,10 +519,10 @@
>  # 1024 byte should be about 10 markers in average
>  _obskeyspan = 1024
>
> -def __init__(self, svfs, defaultformat=_fm1version, readonly=False):
> +def __init__(self, repo, defaultformat=_fm1version, readonly=False):
>  # caches for various obsolescence related cache
>  self.caches = {}
> -self.svfs = svfs
> +self.svfs = repo.svfs
>  self._defaultformat = defaultformat
>  self._readonly = readonly
>
> @@ -799,7 +799,7 @@
>  if defaultformat is not None:
>  kwargs['defaultformat'] = defaultformat
>  readonly = not isenabled(repo, createmarkersopt)
> -store = obsstore(repo.svfs, readonly=readonly, **kwargs)
> +store = obsstore(repo, readonly=readonly, **kwargs)
>  if store and readonly:
>  ui.warn(_('obsolete feature not enabled but %i markers found!\n')
>  % len(list(store)))
> ___
> 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


[Differential] [Commented On] D60: match: remove unused negatematcher

2017-07-14 Thread durham (Durham Goode)
durham added a comment.


  As I mentioned in IRC, this is actually important for scalability, since I 
think 'visitdir' has to return True for any negatematcher, since it can't know 
what is or isn't relevant to the underlying matcher.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH 05 of 14] obsstore: add a method to incrementally retrieve obsmarkers

2017-07-14 Thread Augie Fackler
On Sun, Jul 09, 2017 at 07:55:17PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1497674383 -7200
> #  Sat Jun 17 06:39:43 2017 +0200
> # Node ID 7c41d1484f53c53d516153d19a90c331c3f87c16
> # Parent  e73d330f6fdb0cf1635920f4302b61b321ec58e2
> # EXP-Topic obs-cache
> obsstore: add a method to incrementally retrieve obsmarkers

This one and its follow-up both look interesting, but I don't know if
we have any imminent callers?

>
> Parsing the full obsstore is slow, so cache that depends on obsstore content
> wants a way to know if the obsstore changed, and it this change was append
> only.
>
> For this purpose we introduce an official cache-key for the obsstore. This
> cache-key work in a way similar to the '(tiprev, tipnode)' pair used for the
> changelog. We use the size of the obsstore file and the hash of its tail. That
> way, we can check if the obsstore grew and if the content we knew is still
> present in the obsstore.
>
> The cachekey comes with a method that only returns the obsmarkers that changed
> between the last seen "cache-key" value and the current state of the
> repository. That method is race free and should be used by caches. See
> documentation for details.
>
> note: we are reading the full obsstore file from disk as part of the key
> validation process. This could be avoided but we keep the implementation
> simple for now. Once it is in place and running we can iterate to make it
> better.
>
> diff -r e73d330f6fdb -r 7c41d1484f53 mercurial/obsolete.py
> --- a/mercurial/obsolete.py   Sun Jun 04 10:02:09 2017 -0700
> +++ b/mercurial/obsolete.py   Sat Jun 17 06:39:43 2017 +0200
> @@ -70,6 +70,7 @@
>  from __future__ import absolute_import
>
>  import errno
> +import hashlib
>  import struct
>
>  from .i18n import _
> @@ -513,6 +514,10 @@
>  # parents: (tuple of nodeid) or None, parents of precursors
>  #  None is used when no data has been recorded
>
> +# how much data to read at the end of file,
> +# 1024 byte should be about 10 markers in average
> +_obskeyspan = 1024
> +
>  def __init__(self, svfs, defaultformat=_fm1version, readonly=False):
>  # caches for various obsolescence related cache
>  self.caches = {}
> @@ -540,6 +545,72 @@
>
>  __bool__ = __nonzero__
>
> +def getmarkerssince(self, previouscontentkey):
> +"""retrieve all new markers (since "contentkey") + updated content 
> key
> +
> +This function is to be used by cache depending on obsstore content. 
> It
> +make sure cache can incrementally update themselves without fear
> +obsstore stripping or race condition.  If the content key is invalid
> +(some obsstore content got stripped), all markers in the obsstore 
> will
> +be returned.
> +
> +return: (reset, obsmarkers, contentkey)
> +
> +:reset: boolean, True if previouscontentkey was invalided. Previously
> +stored data are invalid and should be discarded. Full markers
> +content is return in this case.
> +
> +:obsmarkers: the list of new obsmarkers.
> +
> +:contentkey: a key matching the content of 'previouscontentkey' +
> + 'obsmarkers'.
> +
> +The content key is a pair of:
> +
> +(obsstore size, hash of last N bytes of the obsstore)
> +
> +It must be kept around by cache and provided again for the next
> +incremental read of new obsmarkers.
> +"""
> +# XXX This function could avoid loading the whole data from disk (and
> +# only read new markers). It currently use 'self._data' to keep the
> +# code simpler.
> +keysize, keyhash = previouscontentkey
> +fulldata = self._data
> +
> +# check the existing cache key
> +reset = False
> +if len(fulldata) < keysize: # less data than expected, this is a 
> strip
> +reset = True
> +else:
> +if keysize == 0: # no obsstore
> +actualhash = node.nullid
> +else:
> +first = max(0, keysize - self._obskeyspan)
> +keydata = fulldata[first:keysize]
> +actualhash = hashlib.sha1(keydata).digest()
> +reset = actualhash != keyhash
> +newsize = len(fulldata)
> +
> +# read the new data
> +if reset:
> +keysize = None # read all data
> +elif keysize == newsize:
> +# no update since last change, exist early
> +return False, [], previouscontentkey
> +if newsize:
> +start = max(0, newsize - self._obskeyspan)
> +newhash = hashlib.sha1(fulldata[start:newsize]).digest()
> +__, obsmarkers = _readmarkers(fulldata, keysize, newsize)
> +else:
> +# obsstore is empty, use a generic hash and skip reading markers.
> +newhash == node.nullid
> +

Re: [PATCH 03 of 14] obsstore: keep self._data updated with _addmarkers

2017-07-14 Thread Augie Fackler
On Sun, Jul 09, 2017 at 07:55:15PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1496552183 25200
> #  Sat Jun 03 21:56:23 2017 -0700
> # Node ID ff2ebc11f12a26a4e0bda3ccf5fde63f5f690813
> # Parent  8b71290526ddb77f157e075191dd748793d85601
> # EXP-Topic obs-cache
> obsstore: keep self._data updated with _addmarkers

Took this one.

>
> This makes sure obsstore._data is still correct with added markers.
>
> The '_data' propertycache was added in 17ce57b7873f.
>
> diff -r 8b71290526dd -r ff2ebc11f12a mercurial/obsolete.py
> --- a/mercurial/obsolete.py   Fri Jul 07 22:15:52 2017 +0200
> +++ b/mercurial/obsolete.py   Sat Jun 03 21:56:23 2017 -0700
> @@ -607,8 +607,8 @@
>  offset = f.tell()
>  transaction.add('obsstore', offset)
>  # offset == 0: new file - add the version header
> -for bytes in encodemarkers(new, offset == 0, self._version):
> -f.write(bytes)
> +data = b''.join(encodemarkers(new, offset == 0, 
> self._version))
> +f.write(data)
>  finally:
>  # XXX: f.close() == filecache invalidation == obsstore 
> rebuilt.
>  # call 'filecacheentry.refresh()'  here
> @@ -616,7 +616,7 @@
>  addedmarkers = transaction.changes.get('obsmarkers')
>  if addedmarkers is not None:
>  addedmarkers.update(new)
> -self._addmarkers(new)
> +self._addmarkers(new, data)
>  # new marker *may* have changed several set. invalidate the 
> cache.
>  self.caches.clear()
>  # records the number of new markers for the transaction hooks
> @@ -673,8 +673,9 @@
>  def _cached(self, attr):
>  return attr in self.__dict__
>
> -def _addmarkers(self, markers):
> +def _addmarkers(self, markers, rawdata):
>  markers = list(markers) # to allow repeated iteration
> +self._data = self._data + rawdata
>  self._all.extend(markers)
>  if self._cached('successors'):
>  _addsuccessors(self.successors, markers)
> ___
> 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 02 of 14] cache: introduce a changelogsourcebase class

2017-07-14 Thread Augie Fackler
On Sun, Jul 09, 2017 at 07:55:14PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1499458552 -7200
> #  Fri Jul 07 22:15:52 2017 +0200
> # Node ID 8b71290526ddb77f157e075191dd748793d85601
> # Parent  6edb62505c697329de034c2fdc47befd5896f31f
> # EXP-Topic obs-cache
> cache: introduce a changelogsourcebase class

These two are interesting on their own, assuming we've got existing
caches that could be refactored.

>
> This abstract class will help code that need a cache tracking the changelog
> content (eg: the branchmap cache). The cache key used is the same as what the
> branchmap uses.

This sounds like we could get these two in by migrating the branchmap
cache to use them?

>
> diff -r 6edb62505c69 -r 8b71290526dd mercurial/cache.py
> --- a/mercurial/cache.py  Fri Jul 07 22:14:01 2017 +0200
> +++ b/mercurial/cache.py  Fri Jul 07 22:15:52 2017 +0200
> @@ -10,6 +10,7 @@
>  import struct
>
>  from . import (
> +node,
>  util,
>  )
>
> @@ -125,3 +126,41 @@
>  def _deserializecachekey(self, data):
>  """read the cachekey from bytes"""
>  return self._cachekeystruct.unpack(data)
> +
> +class changelogsourcebase(incrementalcachebase):
> +"""an abstract class for cache sourcing data from the changelog
> +
> +For this purpose it use a cache key covering changelog content.
> +The cache key parts are: (tiprev, tipnode)
> +"""
> +
> +__metaclass__ = abc.ABCMeta
> +
> +# default key used for an empty cache
> +emptykey = (0, node.nullid)
> +_cachekeyspec = 'i20s'
> +_cachename = None # used for debug message
> +
> +# Useful "public" function (no need to override them)
> +
> +def _fetchchangelogdata(self, cachekey, cl):
> +"""use a cachekey to fetch incremental data
> +
> +Exists as its own method to help subclass to reuse it."""
> +tiprev = len(cl) - 1
> +tipnode = cl.node(tiprev)
> +newkey = (tiprev, tipnode)
> +tiprev = len(cl) - 1
> +if newkey == cachekey:
> +return False, [], newkey
> +keyrev, keynode = cachekey
> +if tiprev < keyrev or cl.node(keyrev) != keynode:
> +revs = ()
> +if len(cl):
> +revs = list(cl.revs(stop=tiprev))
> +return True, revs, newkey
> +else:
> +return False, list(cl.revs(start=keyrev + 1, stop=tiprev)), 
> newkey
> +
> +def _fetchupdatedata(self, repo):
> +return self._fetchchangelogdata(self._cachekey, repo.changelog)
> ___
> 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


[Differential] [Accepted] D83: match: make base matcher return True for visitdir

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
martinvonz accepted this revision.
martinvonz added a comment.
This revision is now accepted and ready to land.


  Thanks. I had been thinking of making this change. I agree it's better to be 
slow but correct by default.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Request, 2 lines] D83: match: make base matcher return True for visitdir

2017-07-14 Thread durham (Durham Goode)
durham created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  If a matcher doesn't implement visitdir, we should be returning True so that
  tree traversals are not prematurely pruned. The old value of False would 
prevent
  tree traversals when using any matcher that didn't implement visitdir.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

Index: mercurial/match.py
===
--- mercurial/match.py
+++ mercurial/match.py
@@ -305,7 +305,7 @@
 This function's behavior is undefined if it has returned False for
 one of the dir's parent directories.
 '''
-return False
+return True
 
 def always(self):
 '''Matcher will match everything and .files() will be empty --


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH 2 of 3] configitems: use codemod script to register coreconfigitems

2017-07-14 Thread Martin von Zweigbergk via Mercurial-devel
On Wed, Jul 12, 2017 at 6:22 PM, Jun Wu  wrote:
> # HG changeset patch
> # User Jun Wu 
> # Date 1499898287 25200
> #  Wed Jul 12 15:24:47 2017 -0700
> # Node ID a0df53ed55b26539c62584231cfcb567594ab34a
> # Parent  695702ea1caedaeeed9a6d63473c0e338adf35f4
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #  hg pull https://bitbucket.org/quark-zju/hg-draft -r 
> a0df53ed55b2
> configitems: use codemod script to register coreconfigitems

Great!

Like with the "multi-with" patch you sent recently, I don't think the
script will ever be used again (I'd rather have check-code check for
it), so could you rebase this series (there were just a few more
config patches accepted, maybe some for core config?) and include the
script in the commit message instead? Thanks!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 09 of 12] bookmark: use 'applychanges' when stripping

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499701068 -7200
#  Mon Jul 10 17:37:48 2017 +0200
# Node ID 32399e89b8ed9662b07d6a656a447e6ef5bafc1b
# Parent  0d37c4628a9cc6491e35ad69e8c780ccaf3d26bc
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' when stripping

diff -r 0d37c4628a9c -r 32399e89b8ed hgext/strip.py
--- a/hgext/strip.pyMon Jul 10 17:30:20 2017 +0200
+++ b/hgext/strip.pyMon Jul 10 17:37:48 2017 +0200
@@ -78,9 +78,7 @@
 with repo.transaction('strip') as tr:
 if repo._activebookmark in bookmarks:
 bookmarksmod.deactivate(repo)
-for bookmark in bookmarks:
-del repomarks[bookmark]
-repomarks.recordchange(tr)
+repomarks.applychanges(repo, tr, [(b, None) for b in 
bookmarks])
 for bookmark in sorted(bookmarks):
 ui.write(_("bookmark '%s' deleted\n") % bookmark)
 
@@ -157,9 +155,8 @@
 revs.update(set(rsrevs))
 if not revs:
 with repo.lock(), repo.transaction('bookmark') as tr:
-for bookmark in bookmarks:
-del repomarks[bookmark]
-repomarks.recordchange(tr)
+bmchanges = [(b, None) for b in bookmarks]
+repomarks.applychanges(repo, tr, bmchanges)
 for bookmark in sorted(bookmarks):
 ui.write(_("bookmark '%s' deleted\n") % bookmark)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 10 of 12] bookmark: use 'applychanges' in the mq extension

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499701465 -7200
#  Mon Jul 10 17:44:25 2017 +0200
# Node ID e8d6ea8639cdbdd8af729fbad09f508210e02723
# Parent  32399e89b8ed9662b07d6a656a447e6ef5bafc1b
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' in the mq extension

diff -r 32399e89b8ed -r e8d6ea8639cd hgext/mq.py
--- a/hgext/mq.py   Mon Jul 10 17:37:48 2017 +0200
+++ b/hgext/mq.py   Mon Jul 10 17:44:25 2017 +0200
@@ -1834,9 +1834,7 @@
 patchf.close()
 
 marks = repo._bookmarks
-for bm in bmlist:
-marks[bm] = n
-marks.recordchange(tr)
+marks.applychanges(repo, tr, [(bm, n) for bm in bmlist])
 tr.close()
 
 self.applied.append(statusentry(n, patchfn))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 11 of 12] bookmark: use 'applychanges' in 'repair.strip'

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499701607 -7200
#  Mon Jul 10 17:46:47 2017 +0200
# Node ID bbebf6b3d2514134fc750903de90ec515cf4c4d3
# Parent  e8d6ea8639cdbdd8af729fbad09f508210e02723
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' in 'repair.strip'

diff -r e8d6ea8639cd -r bbebf6b3d251 mercurial/repair.py
--- a/mercurial/repair.py   Mon Jul 10 17:44:25 2017 +0200
+++ b/mercurial/repair.py   Mon Jul 10 17:46:47 2017 +0200
@@ -219,11 +219,10 @@
 f.close()
 repo._phasecache.invalidate()
 
-for m in updatebm:
-bm[m] = repo[newbmtarget].node()
 
 with repo.transaction('repair') as tr:
-bm.recordchange(tr)
+bmchanges = [(m, repo[newbmtarget].node()) for m in updatebm]
+bm.applychanges(repo, tr, bmchanges)
 
 # remove undo files
 for undovfs, undofile in repo.undofiles():
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 08 of 12] bookmark: use 'applychanges' in the convert extension

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499700620 -7200
#  Mon Jul 10 17:30:20 2017 +0200
# Node ID 0d37c4628a9cc6491e35ad69e8c780ccaf3d26bc
# Parent  85ce60fb04bbbf060d7657209802b6a0e0cc030a
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' in the convert extension

diff -r 85ce60fb04bb -r 0d37c4628a9c hgext/convert/hg.py
--- a/hgext/convert/hg.py   Mon Jul 10 17:28:53 2017 +0200
+++ b/hgext/convert/hg.py   Mon Jul 10 17:30:20 2017 +0200
@@ -425,9 +425,9 @@
 tr = self.repo.transaction('bookmark')
 self.ui.status(_("updating bookmarks\n"))
 destmarks = self.repo._bookmarks
-for bookmark in updatedbookmark:
-destmarks[bookmark] = nodemod.bin(updatedbookmark[bookmark])
-destmarks.recordchange(tr)
+changes = [(bookmark, nodemod.bin(updatedbookmark[bookmark]))
+   for bookmark in updatedbookmark]
+destmarks.applychanges(self.repo, tr, changes)
 tr.close()
 finally:
 lockmod.release(lock, wlock, tr)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 12 of 12] bookmarks: use 'applychanges' for bookmark update

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499708423 -7200
#  Mon Jul 10 19:40:23 2017 +0200
# Node ID c8af08d67851fae61c1cf459f0f0bf20f61b9298
# Parent  bbebf6b3d2514134fc750903de90ec515cf4c4d3
# EXP-Topic tr.changes.bookmarks
bookmarks: use 'applychanges' for bookmark update

There is still some use of 'deletedivergent' bookmark here. They will be taken
care of later. The 'deletedivergent' code needs some rework before fitting in
the new world.

diff -r bbebf6b3d251 -r c8af08d67851 mercurial/bookmarks.py
--- a/mercurial/bookmarks.pyMon Jul 10 17:46:47 2017 +0200
+++ b/mercurial/bookmarks.pyMon Jul 10 19:40:23 2017 +0200
@@ -350,6 +350,7 @@
 if not active:
 return False
 
+bmchanges = []
 if marks[active] in parents:
 new = repo[node]
 divs = [repo[b] for b in marks
@@ -357,7 +358,7 @@
 anc = repo.changelog.ancestors([new.rev()])
 deletefrom = [b.node() for b in divs if b.rev() in anc or b == new]
 if validdest(repo, repo[marks[active]], new):
-marks[active] = new.node()
+bmchanges.append((active, new.node()))
 update = True
 
 if deletedivergent(repo, deletefrom, active):
@@ -368,7 +369,7 @@
 try:
 lock = repo.lock()
 tr = repo.transaction('bookmark')
-marks.recordchange(tr)
+marks.applychanges(repo, tr, bmchanges)
 tr.close()
 finally:
 lockmod.release(tr, lock)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 06 of 12] bookmark: use 'applychanges' when updating a bookmark through pushkey

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499700268 -7200
#  Mon Jul 10 17:24:28 2017 +0200
# Node ID 1fc04ebe411862e9648382fa2a0790d8bdaf3862
# Parent  76dde98a2c0bc24ab110ba3ecc06698c735adf57
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' when updating a bookmark through pushkey

diff -r 76dde98a2c0b -r 1fc04ebe4118 mercurial/bookmarks.py
--- a/mercurial/bookmarks.pyMon Jul 10 17:22:17 2017 +0200
+++ b/mercurial/bookmarks.pyMon Jul 10 17:24:28 2017 +0200
@@ -402,12 +402,12 @@
 if existing != old and existing != new:
 return False
 if new == '':
-del marks[key]
+changes = [(key, None)]
 else:
 if new not in repo:
 return False
-marks[key] = repo[new].node()
-marks.recordchange(tr)
+changes = [(key, repo[new].node())]
+marks.applychanges(repo, tr, changes)
 tr.close()
 return True
 finally:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 04 of 12] bookmark: use 'applychanges' for adding new bookmark

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499699456 -7200
#  Mon Jul 10 17:10:56 2017 +0200
# Node ID 34170eeaa6fbfb43b1ceac331ae50678afe10610
# Parent  9f589c0e64901c5a15add541d5213574664fa218
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' for adding new bookmark

diff -r 9f589c0e6490 -r 34170eeaa6fb mercurial/bookmarks.py
--- a/mercurial/bookmarks.pyMon Jul 10 17:08:20 2017 +0200
+++ b/mercurial/bookmarks.pyMon Jul 10 17:10:56 2017 +0200
@@ -758,6 +758,7 @@
 marks = repo._bookmarks
 cur = repo.changectx('.').node()
 newact = None
+changes = []
 for mark in names:
 mark = checkformat(repo, mark)
 if newact is None:
@@ -769,12 +770,12 @@
 if rev:
 tgt = scmutil.revsingle(repo, rev).node()
 marks.checkconflict(mark, force, tgt)
-marks[mark] = tgt
+changes.append((mark, tgt))
+marks.applychanges(repo, tr, changes)
 if not inactive and cur == marks[newact] and not rev:
 activate(repo, newact)
 elif cur != tgt and newact == repo._activebookmark:
 deactivate(repo)
-marks.recordchange(tr)
 
 def _printbookmarks(ui, repo, bmarks, **opts):
 """private method to print bookmarks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 07 of 12] bookmark: use 'applychanges' when updating bookmark in histedit

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499700533 -7200
#  Mon Jul 10 17:28:53 2017 +0200
# Node ID 85ce60fb04bbbf060d7657209802b6a0e0cc030a
# Parent  1fc04ebe411862e9648382fa2a0790d8bdaf3862
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' when updating bookmark in histedit

diff -r 1fc04ebe4118 -r 85ce60fb04bb hgext/histedit.py
--- a/hgext/histedit.py Mon Jul 10 17:24:28 2017 +0200
+++ b/hgext/histedit.py Mon Jul 10 17:28:53 2017 +0200
@@ -1561,9 +1561,10 @@
 if oldbmarks:
 with repo.lock(), repo.transaction('histedit') as tr:
 marks = repo._bookmarks
+changes = []
 for name in oldbmarks:
-marks[name] = newtopmost
-marks.recordchange(tr)
+changes.append((name, newtopmost))
+marks.applychanges(repo, tr, changes)
 
 def cleanupnode(ui, repo, nodes):
 """strip a group of nodes from the repository
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 12] bookmark: use 'applychanges' when updating from a remote

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499700137 -7200
#  Mon Jul 10 17:22:17 2017 +0200
# Node ID 76dde98a2c0bc24ab110ba3ecc06698c735adf57
# Parent  34170eeaa6fbfb43b1ceac331ae50678afe10610
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' when updating from a remote

diff -r 34170eeaa6fb -r 76dde98a2c0b mercurial/bookmarks.py
--- a/mercurial/bookmarks.pyMon Jul 10 17:10:56 2017 +0200
+++ b/mercurial/bookmarks.pyMon Jul 10 17:22:17 2017 +0200
@@ -579,10 +579,11 @@
 
 if changed:
 tr = trfunc()
+changes = []
 for b, node, writer, msg in sorted(changed):
-localmarks[b] = node
+changes.append((b, node))
 writer(msg)
-localmarks.recordchange(tr)
+localmarks.applychanges(repo, tr, changes)
 
 def incoming(ui, repo, other):
 '''Show bookmarks incoming from other to repo
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 03 of 12] bookmark: use 'applychanges' for bookmark renaming

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499699300 -7200
#  Mon Jul 10 17:08:20 2017 +0200
# Node ID 9f589c0e64901c5a15add541d5213574664fa218
# Parent  e94048e3d4a0422207fce8c146c6be62fd701f85
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' for bookmark renaming

diff -r e94048e3d4a0 -r 9f589c0e6490 mercurial/bookmarks.py
--- a/mercurial/bookmarks.pyMon Jul 10 17:04:16 2017 +0200
+++ b/mercurial/bookmarks.pyMon Jul 10 17:08:20 2017 +0200
@@ -739,11 +739,10 @@
 if old not in marks:
 raise error.Abort(_("bookmark '%s' does not exist") % old)
 marks.checkconflict(mark, force)
-marks[mark] = marks[old]
+changes = [(mark, marks[old]), (old, None)]
+marks.applychanges(repo, tr, changes)
 if repo._activebookmark == old and not inactive:
 activate(repo, mark)
-del marks[old]
-marks.recordchange(tr)
 
 def addbookmarks(repo, tr, names, rev=None, force=False, inactive=False):
 """add a list of bookmarks
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 02 of 12] bookmark: use 'applychanges' for bookmark deletion

2017-07-14 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1499699056 -7200
#  Mon Jul 10 17:04:16 2017 +0200
# Node ID e94048e3d4a0422207fce8c146c6be62fd701f85
# Parent  e94441a7d9e334c5b9e604b9f6cabe4182cd5550
# EXP-Topic tr.changes.bookmarks
bookmark: use 'applychanges' for bookmark deletion

diff -r e94441a7d9e3 -r e94048e3d4a0 mercurial/bookmarks.py
--- a/mercurial/bookmarks.pyMon Jul 10 17:01:34 2017 +0200
+++ b/mercurial/bookmarks.pyMon Jul 10 17:04:16 2017 +0200
@@ -715,13 +715,14 @@
 Raises an abort error if mark does not exist.
 """
 marks = repo._bookmarks
+changes = []
 for mark in names:
 if mark not in marks:
 raise error.Abort(_("bookmark '%s' does not exist") % mark)
 if mark == repo._activebookmark:
 deactivate(repo)
-del marks[mark]
-marks.recordchange(tr)
+changes.append((mark, None))
+marks.applychanges(repo, tr, changes)
 
 def rename(repo, tr, old, new, force=False, inactive=False):
 """rename a bookmark from old to new
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Request, 2 lines] D82: tests: fix an incorrect description in test-ignore.t

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

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-hgignore.t

CHANGE DETAILS

Index: tests/test-hgignore.t
===
--- tests/test-hgignore.t
+++ tests/test-hgignore.t
@@ -82,7 +82,7 @@
   $ rm 'baz\#wat'
 #endif
 
-Check it does not ignore the current directory '.':
+Check that '^\.' does not ignore the root directory:
 
   $ echo "^\." > .hgignore
   $ hg status


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


Re: [PATCH 10 of 10] effectflag: detect when diff changed

2017-07-14 Thread Augie Fackler
On Fri, Jul 07, 2017 at 02:38:39PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1499346007 -7200
> #  Thu Jul 06 15:00:07 2017 +0200
> # Node ID 449fc1c748c6e058e892a4c940e20137e52e7808
> # Parent  6a40d87dfedcce4064eb4bcdb131ed4d427fd4de
> # EXP-Topic effectflag
> effectflag: detect when diff changed

I've done some thinking about this, and I'd like to see a bit of a
unified story between these bits of metadata and
https://www.mercurial-scm.org/wiki/CommitCustodyConcept - I know
Mozilla is super-interested in that, and I think it's got a lot of
merit generally (instead of just recording how things mutate, we could
also do things like have a CI system sign off on a revision in an
in-history way, for example).

I'm a little curious about the decision to use a metadata field but
then do a bitfield inside the metadata. Any reason to not use
comma-separated verbs or something? Just a space constraint concern?

(A v2 of this series, should we go that route, probably also wants to
document the nature of the ef1 field someplace.)

>
> Store in effect flag when the diff changed between the predecessor and
> its successors.
>
> Comparing the diff is not easy because we do not want to incorrectly detect a
> diff modification when the changeset has only been rebased.
>
> diff -r 6a40d87dfedc -r 449fc1c748c6 mercurial/obsutil.py
> --- a/mercurial/obsutil.pyThu Jul 06 14:58:44 2017 +0200
> +++ b/mercurial/obsutil.pyThu Jul 06 15:00:07 2017 +0200
> @@ -542,6 +542,7 @@
>  DESCCHANGED = 1 << 0 # action changed the description
>  METACHANGED = 1 << 1 # action change the meta
>  PARENTCHANGED = 1 << 2 # action change the parent
> +DIFFCHANGED = 1 << 3 # action change diff introduced by the changeset
>  USERCHANGED = 1 << 4 # the user changed
>  DATECHANGED = 1 << 5 # the date changed
>  BRANCHCHANGED = 1 << 6 # the branch changed
> @@ -565,6 +566,46 @@
>
>  return True
>
> +def _prepare_hunk(hunk):
> +"""Drop all information but the username and patch"""
> +cleanunk = []
> +for line in hunk.splitlines():
> +if line.startswith(b'# User') or not line.startswith(b'#'):
> +if line.startswith(b'@@'):
> +line = b'@@\n'
> +cleanunk.append(line)
> +return cleanunk
> +
> +def _getdifflines(iterdiff):
> +"""return a cleaned up lines"""
> +try:
> +lines = next(iterdiff)
> +except StopIteration:
> +return None
> +return _prepare_hunk(lines)
> +
> +def _cmpdiff(leftctx, rightctx):
> +"""return True if both ctx introduce the "same diff"
> +
> +This is a first and basic implementation, with many shortcoming.
> +"""
> +
> +# Leftctx or right ctx might be filtered, so we need to use the contexts
> +# with an unfiltered repository to safely compute the diff
> +leftunfi = leftctx._repo.unfiltered()[leftctx.rev()]
> +leftdiff = leftunfi.diff(git=1)
> +rightunfi = rightctx._repo.unfiltered()[rightctx.rev()]
> +rightdiff = rightunfi.diff(git=1)
> +
> +left, right = (0, 0)
> +while None not in (left, right):
> +left = _getdifflines(leftdiff)
> +right = _getdifflines(rightdiff)
> +
> +if left != right:
> +return False
> +return True
> +
>  def geteffectflag(relation):
>  """ From an obs-marker relation, compute what changed between the
>  predecessor and the successor.
> @@ -604,4 +645,12 @@
>  if ctxmeta != srcmeta:
>  effects |= METACHANGED
>
> +# Check if at least one of the parent has changed
> +if changectx.parents() != source.parents():
> +effects |= PARENTCHANGED
> +
> +# Check if the diff has changed
> +if not _cmpdiff(source, changectx):
> +effects |= DIFFCHANGED
> +
>  return effects
> diff -r 6a40d87dfedc -r 449fc1c748c6 tests/test-obsmarkers-effectflag.t
> --- a/tests/test-obsmarkers-effectflag.t  Thu Jul 06 14:58:44 2017 +0200
> +++ b/tests/test-obsmarkers-effectflag.t  Thu Jul 06 15:00:07 2017 +0200
> @@ -95,7 +95,7 @@
>
>$ hg debugobsolete --rev .
>d6f4d8b8d3c8cde990f13915bced7f92ce1cc54f 0 
> {ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f} (Thu Jan 01 00:00:00 1970 +) 
> {'ef1': '0', 'user': 'test'}
> -  ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f 
> 75781fdbdbf58a987516b00c980bccda1e9ae588 0 (Thu Jan 01 00:00:00 1970 +) 
> {'ef1': '0', 'user': 'test'}
> +  ebfe0333e0d96f68a917afd97c0a0af87f1c3b5f 
> 75781fdbdbf58a987516b00c980bccda1e9ae588 0 (Thu Jan 01 00:00:00 1970 +) 
> {'ef1': '8', 'user': 'test'}
>
>  amend with multiple effect (desc and meta)
>  ---
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
___
Mercurial-devel mailing list

Re: [PATCH 11 of 11] phases: test phases tracking at the transaction level

2017-07-14 Thread Augie Fackler

> On Jul 14, 2017, at 13:39, Boris Feld  wrote:
> 
> On Fri, 2017-07-14 at 12:39 -0400, Augie Fackler wrote:
>> On Fri, Jul 14, 2017 at 03:25:45PM +0200, Boris Feld wrote:
>>> # HG changeset patch
>>> # User Boris Feld 
>>> # Date 1499891988 -7200
>>> #  Wed Jul 12 22:39:48 2017 +0200
>>> # Node ID 0ccb45f63c27d373c02a87e6544e684db27659fe
>>> # Parent  14007d8eba4dd21240bb243e45394fa0dc70545b
>>> # EXP-Topic tr.changes.phases
>>> phases: test phases tracking at the transaction level
>> 
>> queued, thanks
>> 
>> Does this open the door to printing when changes advance from draft
>> to
>> public as a result of a pull?
> 
> Yes!
> 
> We planned to work on push/pull report for the next release. Since it's
> so close to the freeze, we could try adding a simple message for phases
> this weekend if there is no backward-compatibility constraint.

I'm not willing to say no backwards compat constraint, so let's shoot for early 
in the 4.4 cycle.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 11 of 11] phases: test phases tracking at the transaction level

2017-07-14 Thread Boris Feld
On Fri, 2017-07-14 at 12:39 -0400, Augie Fackler wrote:
> On Fri, Jul 14, 2017 at 03:25:45PM +0200, Boris Feld wrote:
> > # HG changeset patch
> > # User Boris Feld 
> > # Date 1499891988 -7200
> > #  Wed Jul 12 22:39:48 2017 +0200
> > # Node ID 0ccb45f63c27d373c02a87e6544e684db27659fe
> > # Parent  14007d8eba4dd21240bb243e45394fa0dc70545b
> > # EXP-Topic tr.changes.phases
> > phases: test phases tracking at the transaction level
> 
> queued, thanks
> 
> Does this open the door to printing when changes advance from draft
> to
> public as a result of a pull?

Yes!

We planned to work on push/pull report for the next release. Since it's
so close to the freeze, we could try adding a simple message for phases
this weekend if there is no backward-compatibility constraint.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[Differential] [Abandoned] D76: contrib: add a codemod script to rewrite nested with

2017-07-14 Thread quark (Jun Wu)
quark abandoned this revision.
quark added a comment.


  Per discussion on https://phab.mercurial-scm.org/D77, use commit message 
instead.

REPOSITORY
  rHG Mercurial

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

EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Closed] D66: histedit: extract InterventionRequired transaction handling to utils

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGfad6852cf879: histedit: extract InterventionRequired 
transaction handling to utils (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D66?vs=116=144

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

AFFECTED FILES
  hgext/histedit.py
  mercurial/util.py

CHANGE DETAILS

Index: mercurial/util.py
===
--- mercurial/util.py
+++ mercurial/util.py
@@ -19,6 +19,7 @@
 import calendar
 import codecs
 import collections
+import contextlib
 import datetime
 import errno
 import gc
@@ -589,6 +590,24 @@
 del self[key]
 super(sortdict, self).__setitem__(key, value)
 
+@contextlib.contextmanager
+def acceptintervention(tr=None):
+"""A context manager that closes the transaction on InterventionRequired
+
+If no transaction was provided, this simply runs the body and returns
+"""
+if not tr:
+yield
+return
+try:
+yield
+tr.close()
+except error.InterventionRequired:
+tr.close()
+raise
+finally:
+tr.release()
+
 class _lrucachenode(object):
 """A node in a doubly linked list.
 
Index: hgext/histedit.py
===
--- hgext/histedit.py
+++ hgext/histedit.py
@@ -1122,7 +1122,7 @@
 # and reopen a transaction. For example, if the action executes an
 # external process it may choose to commit the transaction first.
 tr = repo.transaction('histedit')
-try:
+with util.acceptintervention(tr):
 while state.actions:
 state.write(tr=tr)
 actobj = state.actions[0]
@@ -1136,17 +1136,6 @@
 state.replacements.extend(replacement_)
 state.actions.pop(0)
 
-if tr is not None:
-tr.close()
-except error.InterventionRequired:
-if tr is not None:
-tr.close()
-raise
-except Exception:
-if tr is not None:
-tr.abort()
-raise
-
 state.write()
 ui.progress(_("editing"), None)
 


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Closed] D58: match: make unionmatcher a proper matcher

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG04be8aec44a8: match: make unionmatcher a proper matcher 
(authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D58?vs=129=146

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

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS

Index: mercurial/match.py
===
--- mercurial/match.py
+++ mercurial/match.py
@@ -648,16 +648,34 @@
 (self._path, self._matcher))
 
 class unionmatcher(basematcher):
-"""A matcher that is the union of several matchers."""
+"""A matcher that is the union of several matchers.
+
+The non-matching-attributes (root, cwd, bad, explicitdir, traversedir) are
+taken from the first matcher.
+"""
+
 def __init__(self, matchers):
+m1 = matchers[0]
+super(unionmatcher, self).__init__(m1._root, m1._cwd)
+self.explicitdir = m1.explicitdir
+self.traversedir = m1.traversedir
 self._matchers = matchers
 
 def matchfn(self, f):
 for match in self._matchers:
 if match(f):
 return True
 return False
 
+def visitdir(self, dir):
+r = False
+for m in self._matchers:
+v = m.visitdir(dir)
+if v == 'all':
+return v
+r |= v
+return r
+
 def __repr__(self):
 return ('' % self._matchers)
 


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Closed] D77: codemod: simplify nested withs

2017-07-14 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG8056481caa81: codemod: simplify nested withs (authored by 
quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D77?vs=121=136

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

AFFECTED FILES
  hgext/largefiles/lfutil.py
  mercurial/cmdutil.py
  mercurial/debugcommands.py
  mercurial/upgrade.py

CHANGE DETAILS

Index: mercurial/upgrade.py
===
--- mercurial/upgrade.py
+++ mercurial/upgrade.py
@@ -792,35 +792,33 @@
 upgradeactions = [a.name for a in actions]
 
 ui.write(_('beginning upgrade...\n'))
-with repo.wlock():
-with repo.lock():
-ui.write(_('repository locked and read-only\n'))
-# Our strategy for upgrading the repository is to create a new,
-# temporary repository, write data to it, then do a swap of the
-# data. There are less heavyweight ways to do this, but it is 
easier
-# to create a new repo object than to instantiate all the 
components
-# (like the store) separately.
-tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path)
-backuppath = None
-try:
-ui.write(_('creating temporary repository to stage migrated '
-   'data: %s\n') % tmppath)
-dstrepo = localrepo.localrepository(repo.baseui,
-path=tmppath,
-create=True)
+with repo.wlock(), repo.lock():
+ui.write(_('repository locked and read-only\n'))
+# Our strategy for upgrading the repository is to create a new,
+# temporary repository, write data to it, then do a swap of the
+# data. There are less heavyweight ways to do this, but it is easier
+# to create a new repo object than to instantiate all the components
+# (like the store) separately.
+tmppath = tempfile.mkdtemp(prefix='upgrade.', dir=repo.path)
+backuppath = None
+try:
+ui.write(_('creating temporary repository to stage migrated '
+   'data: %s\n') % tmppath)
+dstrepo = localrepo.localrepository(repo.baseui,
+path=tmppath,
+create=True)
 
-with dstrepo.wlock():
-with dstrepo.lock():
-backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
-  upgradeactions)
+with dstrepo.wlock(), dstrepo.lock():
+backuppath = _upgraderepo(ui, repo, dstrepo, newreqs,
+  upgradeactions)
 
-finally:
-ui.write(_('removing temporary repository %s\n') % tmppath)
-repo.vfs.rmtree(tmppath, forcibly=True)
+finally:
+ui.write(_('removing temporary repository %s\n') % tmppath)
+repo.vfs.rmtree(tmppath, forcibly=True)
 
-if backuppath:
-ui.warn(_('copy of old repository backed up at %s\n') %
-backuppath)
-ui.warn(_('the old repository will not be deleted; remove '
-  'it to free up disk space once the upgraded '
-  'repository is verified\n'))
+if backuppath:
+ui.warn(_('copy of old repository backed up at %s\n') %
+backuppath)
+ui.warn(_('the old repository will not be deleted; remove '
+  'it to free up disk space once the upgraded '
+  'repository is verified\n'))
Index: mercurial/debugcommands.py
===
--- mercurial/debugcommands.py
+++ mercurial/debugcommands.py
@@ -2177,9 +2177,8 @@
 @command('debugupdatecaches', [])
 def debugupdatecaches(ui, repo, *pats, **opts):
 """warm all known caches in the repository"""
-with repo.wlock():
-with repo.lock():
-repo.updatecaches()
+with repo.wlock(), repo.lock():
+repo.updatecaches()
 
 @command('debugupgraderepo', [
 ('o', 'optimize', [], _('extra optimization to perform'), _('NAME')),
Index: mercurial/cmdutil.py
===
--- mercurial/cmdutil.py
+++ mercurial/cmdutil.py
@@ -2750,148 +2750,147 @@
 base = old.p1()
 
 newid = None
-with repo.wlock(), repo.lock():
-with repo.transaction('amend') as tr:
-# See if we got a message from -m or -l, if not, open the editor
-# with the message of the changeset to amend
-message = logmessage(ui, opts)
- 

[Differential] [Closed] D57: match: write forceincludematcher using unionmatcher

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG6f4e5e5940a5: match: write forceincludematcher using 
unionmatcher (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D57?vs=128=145

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

AFFECTED FILES
  mercurial/match.py
  mercurial/sparse.py

CHANGE DETAILS

Index: mercurial/sparse.py
===
--- mercurial/sparse.py
+++ mercurial/sparse.py
@@ -242,6 +242,13 @@
 'sparse checkout\n')
 repo.ui.status(msg % len(tempincludes))
 
+def forceincludematcher(matcher, includes):
+"""Returns a matcher that returns true for any of the forced includes
+before testing against the actual matcher."""
+kindpats = [('path', include, '') for include in includes]
+includematcher = matchmod.includematcher('', '', kindpats)
+return matchmod.unionmatcher([includematcher, matcher])
+
 def matcher(repo, revs=None, includetemp=True):
 """Obtain a matcher for sparse working directories for the given revs.
 
@@ -289,7 +296,7 @@
  include=includes, exclude=excludes,
  default='relpath')
 if subdirs:
-matcher = matchmod.forceincludematcher(matcher, subdirs)
+matcher = forceincludematcher(matcher, subdirs)
 matchers.append(matcher)
 except IOError:
 pass
@@ -303,7 +310,7 @@
 
 if includetemp:
 tempincludes = readtemporaryincludes(repo)
-result = matchmod.forceincludematcher(result, tempincludes)
+result = forceincludematcher(result, tempincludes)
 
 repo._sparsematchercache[key] = result
 
Index: mercurial/match.py
===
--- mercurial/match.py
+++ mercurial/match.py
@@ -647,20 +647,6 @@
 return ('' %
 (self._path, self._matcher))
 
-class forceincludematcher(basematcher):
-"""A matcher that returns true for any of the forced includes before 
testing
-against the actual matcher."""
-def __init__(self, matcher, includes):
-self._matcher = matcher
-self._includes = includes
-
-def matchfn(self, f):
-return f in self._includes or self._matcher(f)
-
-def __repr__(self):
-return ('' %
-(self._matcher, sorted(self._includes)))
-
 class unionmatcher(basematcher):
 """A matcher that is the union of several matchers."""
 def __init__(self, matchers):


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Closed] D65: histedit: create transaction outside of try

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0491004e2233: histedit: create transaction outside of try 
(authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D65?vs=115=143

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

AFFECTED FILES
  hgext/histedit.py

CHANGE DETAILS

Index: hgext/histedit.py
===
--- hgext/histedit.py
+++ hgext/histedit.py
@@ -1107,23 +1107,22 @@
 if action.verb == 'fold' and nextact and nextact.verb == 'fold':
 state.actions[idx].__class__ = _multifold
 
-total = len(state.actions)
-pos = 0
-tr = None
-
 # Force an initial state file write, so the user can run --abort/continue
 # even if there's an exception before the first transaction serialize.
 state.write()
+
+total = len(state.actions)
+pos = 0
+tr = None
+# Don't use singletransaction by default since it rolls the entire
+# transaction back if an unexpected exception happens (like a
+# pretxncommit hook throws, or the user aborts the commit msg editor).
+if ui.configbool("histedit", "singletransaction", False):
+# Don't use a 'with' for the transaction, since actions may close
+# and reopen a transaction. For example, if the action executes an
+# external process it may choose to commit the transaction first.
+tr = repo.transaction('histedit')
 try:
-# Don't use singletransaction by default since it rolls the entire
-# transaction back if an unexpected exception happens (like a
-# pretxncommit hook throws, or the user aborts the commit msg editor).
-if ui.configbool("histedit", "singletransaction", False):
-# Don't use a 'with' for the transaction, since actions may close
-# and reopen a transaction. For example, if the action executes an
-# external process it may choose to commit the transaction first.
-tr = repo.transaction('histedit')
-
 while state.actions:
 state.write(tr=tr)
 actobj = state.actions[0]


EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

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


[Differential] [Closed] D73: util: remove unused ctxmanager

2017-07-14 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0e114b992e02: util: remove unused ctxmanager (authored by 
martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D73?vs=110=137

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

AFFECTED FILES
  contrib/python3-whitelist
  mercurial/util.py
  tests/test-check-module-imports.t
  tests/test-ctxmanager.py

CHANGE DETAILS

Index: tests/test-ctxmanager.py
===
--- tests/test-ctxmanager.py
+++ /dev/null
@@ -1,77 +0,0 @@
-from __future__ import absolute_import
-
-import silenttestrunner
-import unittest
-
-from mercurial import util
-
-class contextmanager(object):
-def __init__(self, name, trace):
-self.name = name
-self.entered = False
-self.exited = False
-self.trace = trace
-
-def __enter__(self):
-self.entered = True
-self.trace(('enter', self.name))
-return self
-
-def __exit__(self, exc_type, exc_val, exc_tb):
-self.exited = exc_type, exc_val, exc_tb
-self.trace(('exit', self.name))
-
-def __repr__(self):
-return '' % self.name
-
-class ctxerror(Exception):
-pass
-
-class raise_on_enter(contextmanager):
-def __enter__(self):
-self.trace(('raise', self.name))
-raise ctxerror(self.name)
-
-class raise_on_exit(contextmanager):
-def __exit__(self, exc_type, exc_val, exc_tb):
-self.trace(('raise', self.name))
-raise ctxerror(self.name)
-
-def ctxmgr(name, trace):
-return lambda: contextmanager(name, trace)
-
-class test_ctxmanager(unittest.TestCase):
-def test_basics(self):
-trace = []
-addtrace = trace.append
-with util.ctxmanager(ctxmgr('a', addtrace), ctxmgr('b', addtrace)) as 
c:
-a, b = c.enter()
-c.atexit(addtrace, ('atexit', 'x'))
-c.atexit(addtrace, ('atexit', 'y'))
-self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'),
- ('atexit', 'y'), ('atexit', 'x'),
- ('exit', 'b'), ('exit', 'a')])
-
-def test_raise_on_enter(self):
-trace = []
-addtrace = trace.append
-with self.assertRaises(ctxerror):
-with util.ctxmanager(ctxmgr('a', addtrace),
- lambda: raise_on_enter('b', addtrace)) as c:
-c.enter()
-addtrace('unreachable')
-self.assertEqual(trace, [('enter', 'a'), ('raise', 'b'), ('exit', 
'a')])
-
-def test_raise_on_exit(self):
-trace = []
-addtrace = trace.append
-with self.assertRaises(ctxerror):
-with util.ctxmanager(ctxmgr('a', addtrace),
- lambda: raise_on_exit('b', addtrace)) as c:
-c.enter()
-addtrace('running')
-self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'), 'running',
- ('raise', 'b'), ('exit', 'a')])
-
-if __name__ == '__main__':
-silenttestrunner.main(__name__)
Index: tests/test-check-module-imports.t
===
--- tests/test-check-module-imports.t
+++ tests/test-check-module-imports.t
@@ -24,7 +24,6 @@
   > -X i18n/posplit \
   > -X tests/test-hgweb-auth.py \
   > -X tests/hypothesishelpers.py \
-  > -X tests/test-ctxmanager.py \
   > -X tests/test-lock.py \
   > -X tests/test-verify-repo-operations.py \
   > -X tests/test-hook.t \
Index: mercurial/util.py
===
--- mercurial/util.py
+++ mercurial/util.py
@@ -3052,66 +3052,6 @@
 yield path[:pos]
 pos = path.rfind('/', 0, pos)
 
-class ctxmanager(object):
-'''A context manager for use in 'with' blocks to allow multiple
-contexts to be entered at once.  This is both safer and more
-flexible than contextlib.nested.
-
-Once Mercurial supports Python 2.7+, this will become mostly
-unnecessary.
-'''
-
-def __init__(self, *args):
-'''Accepts a list of no-argument functions that return context
-managers.  These will be invoked at __call__ time.'''
-self._pending = args
-self._atexit = []
-
-def __enter__(self):
-return self
-
-def enter(self):
-'''Create and enter context managers in the order in which they were
-passed to the constructor.'''
-values = []
-for func in self._pending:
-obj = func()
-values.append(obj.__enter__())
-self._atexit.append(obj.__exit__)
-del self._pending
-return values
-
-def atexit(self, func, *args, **kwargs):
-'''Add a function to call when this context manager exits.  The
-ordering of multiple atexit calls is unspecified, save that
-they will happen before 

[Differential] [Closed] D68: dirstate: update backup functions to take full backup filename

2017-07-14 Thread simpkins (Adam Simpkins)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGec306bc6915b: dirstate: update backup functions to take 
full backup filename (authored by simpkins).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D68?vs=96=138

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

AFFECTED FILES
  hgext/shelve.py
  mercurial/dirstate.py
  mercurial/dirstateguard.py
  mercurial/localrepo.py

CHANGE DETAILS

Index: mercurial/localrepo.py
===
--- mercurial/localrepo.py
+++ mercurial/localrepo.py
@@ -1202,7 +1202,7 @@
 else:
 # discard all changes (including ones already written
 # out) in this transaction
-repo.dirstate.restorebackup(None, prefix='journal.')
+repo.dirstate.restorebackup(None, 'journal.dirstate')
 
 repo.invalidate(clearfilecache=True)
 
@@ -1262,7 +1262,7 @@
 
 @unfilteredmethod
 def _writejournal(self, desc):
-self.dirstate.savebackup(None, prefix='journal.')
+self.dirstate.savebackup(None, 'journal.dirstate')
 self.vfs.write("journal.branch",
   encoding.fromlocal(self.dirstate.branch()))
 self.vfs.write("journal.desc",
@@ -1350,7 +1350,7 @@
 # prevent dirstateguard from overwriting already restored one
 dsguard.close()
 
-self.dirstate.restorebackup(None, prefix='undo.')
+self.dirstate.restorebackup(None, 'undo.dirstate')
 try:
 branch = self.vfs.read('undo.branch')
 self.dirstate.setbranch(encoding.tolocal(branch))
Index: mercurial/dirstateguard.py
===
--- mercurial/dirstateguard.py
+++ mercurial/dirstateguard.py
@@ -31,8 +31,8 @@
 self._repo = repo
 self._active = False
 self._closed = False
-self._suffix = '.backup.%s.%d' % (name, id(self))
-repo.dirstate.savebackup(repo.currenttransaction(), self._suffix)
+self._backupname = 'dirstate.backup.%s.%d' % (name, id(self))
+repo.dirstate.savebackup(repo.currenttransaction(), self._backupname)
 self._active = True
 
 def __del__(self):
@@ -45,25 +45,24 @@
 
 def close(self):
 if not self._active: # already inactivated
-msg = (_("can't close already inactivated backup: dirstate%s")
-   % self._suffix)
+msg = (_("can't close already inactivated backup: %s")
+   % self._backupname)
 raise error.Abort(msg)
 
 self._repo.dirstate.clearbackup(self._repo.currenttransaction(),
- self._suffix)
+ self._backupname)
 self._active = False
 self._closed = True
 
 def _abort(self):
 self._repo.dirstate.restorebackup(self._repo.currenttransaction(),
-   self._suffix)
+   self._backupname)
 self._active = False
 
 def release(self):
 if not self._closed:
 if not self._active: # already inactivated
-msg = (_("can't release already inactivated backup:"
- " dirstate%s")
-   % self._suffix)
+msg = (_("can't release already inactivated backup: %s")
+   % self._backupname)
 raise error.Abort(msg)
 self._abort()
Index: mercurial/dirstate.py
===
--- mercurial/dirstate.py
+++ mercurial/dirstate.py
@@ -1300,10 +1300,10 @@
 else:
 return self._filename
 
-def savebackup(self, tr, suffix='', prefix=''):
-'''Save current dirstate into backup file with suffix'''
-assert len(suffix) > 0 or len(prefix) > 0
+def savebackup(self, tr, backupname):
+'''Save current dirstate into backup file'''
 filename = self._actualfilename(tr)
+assert backupname != filename
 
 # use '_writedirstate' instead of 'write' to write changes certainly,
 # because the latter omits writing out if transaction is running.
@@ -1324,27 +1324,20 @@
 # end of this transaction
 tr.registertmp(filename, location='plain')
 
-backupname = prefix + self._filename + suffix
-assert backupname != filename
 self._opener.tryunlink(backupname)
 # hardlink backup is okay because _writedirstate is always called
 # with an "atomictemp=True" file.
 util.copyfile(self._opener.join(filename),
   self._opener.join(backupname), hardlink=True)
 
-def restorebackup(self, tr, suffix='', prefix=''):
-'''Restore dirstate by backup file with suffix'''
-   

  1   2   >