[PATCH 2 of 2] run-tests: explicitly flush test runner output for Windows stability

2017-06-18 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1497838794 14400
#  Sun Jun 18 22:19:54 2017 -0400
# Node ID 5a86b565abe65d4aca9d290a627736804215a8fa
# Parent  8fd2d66049d936d2cc501ad9a466fb5e67ed8ac2
run-tests: explicitly flush test runner output for Windows stability

When hghave testing goes awry, the output order was changing on Windows.

  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
  @@ -920,10 +920,10 @@
  > EOF
  > done
  $ rt -j 2
  -  
  +  skipped: unknown feature: notarealhghavefeature\r (esc)
  +
  +
  # Ran 5 tests, 0 skipped, 0 warned, 0 failed.
  -  skipped: unknown feature: notarealhghavefeature
  -
  $ cd ..
  $ rm -rf broken

Since 'skipped: unknown feature: notarealhghavefeature\n\n' is printed to stdout
and the rest to stderr, it seems like maybe stdio isn't line buffered on
Windows.  When a program exits, stdout is flushed before stderr[1].

[1] https://blogs.msdn.microsoft.com/oldnewthing/20060519-09/?p=31133

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2010,6 +2010,7 @@
 os.environ['PYTHONHASHSEED'])
 if self._runner.options.time:
 self.printtimes(result.times)
+self.stream.flush()
 
 return result
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] tinyproxy: explicitly flush logged messages

2017-06-18 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1497835913 14400
#  Sun Jun 18 21:31:53 2017 -0400
# Node ID 8fd2d66049d936d2cc501ad9a466fb5e67ed8ac2
# Parent  07d5a503124caed05e1300a5208240764882c831
tinyproxy: explicitly flush logged messages

On Windows, output streams are buffered when redirected to a file, and
TerminateProcess() apparently doesn't trigger a flush.  This left
test-http-proxy.t missing part of the last line when it cat'd proxy.log[1].

Flushing stderr is all that is needed (on py27 anyway).  I originally flushed
stdout too, but that added additional output to the log:

 $ cat proxy.log
  +  Accept: $LOCALIP (localhost)\r (esc)
  +  Serving HTTP on 0.0.0.0 port 20810 ...\r (esc)
  +   connect to localhost:$HGPORT\r (esc)
 * - - [*] "GET http://localhost:$HGPORT/?cmd=capabilities HTTP/1.1" - - 
(glob)
  +   bye\r (esc)
  +   connect to localhost:$HGPORT\r (esc)
 * - - [*] "GET http://localhost:$HGPORT/?cmd=branchmap HTTP/1.1" - - 
x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
  +   bye\r (esc)
  +   connect to localhost:$HGPORT\r (esc)
 * - - [*] "GET http://localhost:$HGPORT/?cmd=stream_out HTTP/1.1" - - 
x-hgproto-1:0.1 0.2 comp=*zlib,none,bzip2 (glob)
  +   bye\r (esc)
  +   connect to localhost:$HGPORT\r (esc)
 ...

[1] 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-April/096987.html

diff --git a/tests/tinyproxy.py b/tests/tinyproxy.py
--- a/tests/tinyproxy.py
+++ b/tests/tinyproxy.py
@@ -53,6 +53,8 @@
 self.log_message('"%s" %s %s%s',
  self.requestline, str(code), str(size),
  ''.join([' %s:%s' % h for h in sorted(xheaders)]))
+# Flush for Windows, so output isn't lost on TerminateProcess()
+sys.stderr.flush()
 
 def _connect_to(self, netloc, soc):
 i = netloc.find(':')
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@32878: 42 new changesets

2017-06-18 Thread Mercurial Commits
42 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/50586a0a946f
changeset:   32837:50586a0a946f
user:Yuya Nishihara 
date:Sat Apr 22 18:42:03 2017 +0900
summary: cmdutil: factor out helper to create changeset_templater with 
literal template

https://www.mercurial-scm.org/repo/hg/rev/615ec3f14aa9
changeset:   32838:615ec3f14aa9
user:Yuya Nishihara 
date:Sat Apr 22 18:48:38 2017 +0900
summary: formatter: wrap (tmpl, mapfile) by named tuple

https://www.mercurial-scm.org/repo/hg/rev/b425ec7fb7f6
changeset:   32839:b425ec7fb7f6
user:Yuya Nishihara 
date:Sat Apr 22 19:02:47 2017 +0900
summary: cmdutil: pass templatespec tuple directly to changeset_templater 
(API)

https://www.mercurial-scm.org/repo/hg/rev/57c13c0d1cde
changeset:   32840:57c13c0d1cde
user:Yuya Nishihara 
date:Sat Apr 22 19:07:00 2017 +0900
summary: formatter: put topic in templatespec tuple

https://www.mercurial-scm.org/repo/hg/rev/883adaea9e80
changeset:   32841:883adaea9e80
user:Yuya Nishihara 
date:Sat Apr 22 19:29:41 2017 +0900
summary: formatter: render template specified by templatespec tuple

https://www.mercurial-scm.org/repo/hg/rev/97a4d09f5140
changeset:   32842:97a4d09f5140
user:Yuya Nishihara 
date:Tue Apr 11 21:38:24 2017 +0900
summary: changeset_templater: render template specified by templatespec 
tuple

https://www.mercurial-scm.org/repo/hg/rev/a470bbb4e3af
changeset:   32843:a470bbb4e3af
user:Martin von Zweigbergk 
date:Thu Jun 15 17:00:32 2017 -0700
summary: clonebundle: use context managers for lock and transaction

https://www.mercurial-scm.org/repo/hg/rev/76bb53f8d374
changeset:   32844:76bb53f8d374
user:Martin von Zweigbergk 
date:Thu Jun 15 14:47:18 2017 -0700
summary: unbundle: use context manager for transaction

https://www.mercurial-scm.org/repo/hg/rev/58a6f64a7018
changeset:   32845:58a6f64a7018
user:Martin von Zweigbergk 
date:Thu Jun 15 22:57:20 2017 -0700
summary: exchange: use context manager for bundle1 unbundling

https://www.mercurial-scm.org/repo/hg/rev/7c11869cf23a
changeset:   32846:7c11869cf23a
user:Gregory Szorc 
date:Thu Jun 15 10:46:39 2017 -0700
summary: tests: add test coverage for check-config

https://www.mercurial-scm.org/repo/hg/rev/e5a6a540ae63
changeset:   32847:e5a6a540ae63
user:Gregory Szorc 
date:Thu Jun 15 10:36:23 2017 -0700
summary: check-config: use compiled regexp

https://www.mercurial-scm.org/repo/hg/rev/485b8e87e244
changeset:   32848:485b8e87e244
user:Gregory Szorc 
date:Thu Jun 15 10:38:19 2017 -0700
summary: check-config: use named groups in regexp

https://www.mercurial-scm.org/repo/hg/rev/e9fc5550be46
changeset:   32849:e9fc5550be46
user:Gregory Szorc 
date:Thu Jun 15 10:58:36 2017 -0700
summary: check-config: look for ui.configwith

https://www.mercurial-scm.org/repo/hg/rev/e33c9a47b0db
changeset:   32850:e33c9a47b0db
user:Gregory Szorc 
date:Thu Jun 15 11:04:46 2017 -0700
summary: config: document profiling.show{min,max}

https://www.mercurial-scm.org/repo/hg/rev/cb6436e051ca
changeset:   32851:cb6436e051ca
user:Gregory Szorc 
date:Thu Jun 15 11:10:51 2017 -0700
summary: profiling: allow configuring minimum display threshold for hotpath

https://www.mercurial-scm.org/repo/hg/rev/3a64ac39b893
changeset:   32852:3a64ac39b893
user:Augie Fackler 
date:Thu Jun 15 12:49:13 2017 -0400
summary: md5sum: adapt for python 3 support

https://www.mercurial-scm.org/repo/hg/rev/3139a7a1e7d4
changeset:   32853:3139a7a1e7d4
user:Augie Fackler 
date:Thu Jun 15 13:13:36 2017 -0400
summary: tests: try and fail more gracefully with broken unicode escapes

https://www.mercurial-scm.org/repo/hg/rev/7a877e569ed6
changeset:   32854:7a877e569ed6
user:Augie Fackler 
date:Thu Jun 15 10:59:48 2017 -0400
summary: contrib: check in a whitelist of passing tests in Python 3

https://www.mercurial-scm.org/repo/hg/rev/28f429d19a71
changeset:   32855:28f429d19a71
user:Augie Fackler 
date:Thu Jun 15 11:00:29 2017 -0400
summary: contrib: add a ratchet for tests in Python 3

https://www.mercurial-scm.org/repo/hg/rev/41f99a90675d
changeset:   32856:41f99a90675d
user:Matt Harbison 
date:Sun May 07 14:58:40 2017 -0400
summary: hghave: enable 'serve' on Windows


[PATCH] highlight: put pygments import inside demandimport.deactivated

2017-06-18 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1497841554 14400
#  Sun Jun 18 23:05:54 2017 -0400
# Node ID 44dd362d5685815692baed660a476eebfed8346e
# Parent  2851b24eecc483ce1546d63d155fa2e9250e3f44
highlight: put pygments import inside demandimport.deactivated

I tripped on some weirdness relating to _thread vs threading way down
in a dep of highlight recently. I'm not really sure why I'm only just
seeing this defect now, but experimentally this fixes the problem, and
shouldn't cause any load-time slowness for people until pygments is
actually about to be used since highlight.highlight is still lazily
loaded in the highlight/__init__.py file.

diff --git a/hgext/highlight/highlight.py b/hgext/highlight/highlight.py
--- a/hgext/highlight/highlight.py
+++ b/hgext/highlight/highlight.py
@@ -10,11 +10,6 @@
 
 from __future__ import absolute_import
 
-import pygments
-import pygments.formatters
-import pygments.lexers
-import pygments.util
-
 from mercurial import demandimport
 demandimport.ignore.extend(['pkgutil', 'pkg_resources', '__main__'])
 
@@ -23,6 +18,12 @@ from mercurial import (
 util,
 )
 
+with demandimport.deactivated():
+import pygments
+import pygments.formatters
+import pygments.lexers
+import pygments.util
+
 highlight = pygments.highlight
 ClassNotFound = pygments.util.ClassNotFound
 guess_lexer = pygments.lexers.guess_lexer
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH RFC] ui: add support for a tweakdefaults knob

2017-06-18 Thread Augie Fackler

> On Jun 18, 2017, at 21:59, Augie Fackler  wrote:
> 
>> 
>> On Jun 17, 2017, at 01:01, Yuya Nishihara  wrote:
>> 
 I have no idea how we should process values which are only set in untrusted
 config. Using hasconfig(untrusted=True) might be a bit safer, but there 
 would
 still be inconsistency.
>>> 
>>> I thought untrusted was the default? Or do you just want it explicit?
>> 
>> untrusted is False by default. I think this and the repo config problems can
>> be mitigated by not setting tweaked values to _ocfg.
>> 
>>  if not tcfg.hasitem(section, name):
>>  tcfg.set(section, name, value, "")
>>  if not ucfg.hasitem(section, name):
>>  ucfg.set(section, name, value, "")
>>  fixconfig()
> 
> Oh, I see the problem now. I'm not sure how to address that. It was 
> intentional that tweakdefaults is only respected if it's a trusted config 
> entry, so all its items can be treated as trusted.
> 
> I think your fix sounds reasonable for the setting of the config items. 
> Should I roll a v3 that moves the tweakdefaults() call to dispatch and make 
> it work this way instead of on (ab)using ui.setconfig?

I just noticed the tweakdefaults patch is pretty far back in the stack at this 
point. I can do a followup if the items I've mentioned here sound good 
(tomorrow, since it's time for me to sleep now...)

> 
> Thanks!
> Augie

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


Re: Transient Windows test failures

2017-06-18 Thread Augie Fackler

> On Jun 16, 2017, at 22:02, Matt Harbison  wrote:
> 
> On Fri, 16 Jun 2017 09:59:30 -0400, Augie Fackler  wrote:
> 
>> On Fri, Jun 16, 2017 at 12:18:18AM -0400, Matt Harbison wrote:
>>> So apparently, this is a symptom of not having %SystemRoot% in the
>>> environment when calling CreateProcess().
>>> 
>>> https://bugs.python.org/issue13524
>>> https://jpassing.com/2009/12/28/the-hidden-danger-of-forgetting-to-specify-systemroot-in-a-custom-environment-block/
>>> 
>>> I see that setup.py special cases this variable.  I did a search for 'env
>>> =', and it looks like hooks and pager start with empty environments, so they
>>> must not inherit this.  IDR if any recent changes were made that start with
>>> an empty environment.
>>> 
>>> The thing I can't get my mind around is the hit and miss nature of the
>>> error, if this is really the problem.
>> 
>> It sounds like it should be harmless to just always forward
>> %SystemRoot% - should we just do that?
> 
> Seems reasonable, but run-tests._getenv() already does an os.environ.copy(), 
> so it should be there?
> 
> It does seem like a good idea to do it for hooks and other things executed, 
> where the environment is built from scratch.  The question is where?  There's 
> util.popen[2-4](), plus some direct calls to subprocess.Popen(), and an 
> os.system().  I considered util.shellenviron(), but there are far fewer calls 
> to this than places where processes are spawned.

My gut (without having gone through the calls) is that we should probably build 
up a subproc module in hg and standardize the various ways we call things - 
right now it's kind of messy, and I strongly suspect we only need 2 or 3 
functions (naive call, call with stdin/stdout/stderr wired up, call with no 
stdin but stdout/stderr captured).

Absent that cleanup, yeah, just do the necessary cleanup on each callsite - the 
os.system() call should (I think) forward everything though, so that one at 
least should be fine...


> I just hit it here:
> 
> --- c:/Users/Matt/projects/hg/tests/test-log.t
> +++ c:/Users/Matt/projects/hg/tests/test-log.t.err
> @@ -1476,72 +1476,64 @@
>   $ hg resolve -m foo
>   (no more unresolved files)
>   $ hg ci -m "First merge, related"
> +  abort: Invalid Signature
> +  [255]
> 
> I was wondering if it's right on the edge of some limit, and paths or 
> whatever being set by the test runner are (sometimes) pushing it out of the 
> environment block.  But the docs say there's no limit to the block size:
> 
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms682653(v=vs.85).aspx
> 
>>> ___
>>> Mercurial-devel mailing list
>>> Mercurial-devel@mercurial-scm.org
>>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

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


[PATCH 2 of 2] tests: enforce use of $PYTHON in tests

2017-06-18 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1497550959 14400
#  Thu Jun 15 14:22:39 2017 -0400
# Node ID d12ed9ad7fd38bc4080709228cd458e9c136
# Parent  6b14e1abca3dcb131c7765c41f30e903d72e1faa
tests: enforce use of $PYTHON in tests

diff --git a/tests/test-check-shbang.t b/tests/test-check-shbang.t
--- a/tests/test-check-shbang.t
+++ b/tests/test-check-shbang.t
@@ -5,9 +5,21 @@
 
 look for python scripts that do not use /usr/bin/env
 
-  $ hg files 'set:grep(r"^#!.*?python") and not grep(r"^#!/usr/bi{1}n/env 
python")'
+  $ hg files 'set:grep(r"^#!.*?python") and not grep(r"^#!/usr/bi{1}n/env 
python") - **/*.t'
   [1]
 
+In tests, enforce $PYTHON and *not* /usr/bin/env python or similar:
+  $ hg files 'set:grep(r"#!.*?python") and **/*.t' \
+  > -X tests/test-check-execute.t \
+  > -X tests/test-check-module-imports.t \
+  > -X tests/test-check-pyflakes.t \
+  > -X tests/test-check-shbang.t
+  [1]
+
+The above exclusions are because they're looking for files that
+contain Python but don't end in .py - please avoid adding more.
+
+
 look for shell scripts that do not use /bin/sh
 
   $ hg files 'set:grep(r"^#!.*/bi{1}n/sh") and not grep(r"^#!/bi{1}n/sh")'
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] tests: use $PYTHON in #! so we always use the right Python

2017-06-18 Thread Augie Fackler
# HG changeset patch
# User Augie Fackler 
# Date 1497551272 14400
#  Thu Jun 15 14:27:52 2017 -0400
# Node ID 6b14e1abca3dcb131c7765c41f30e903d72e1faa
# Parent  2851b24eecc483ce1546d63d155fa2e9250e3f44
tests: use $PYTHON in #! so we always use the right Python

diff --git a/tests/test-bisect.t b/tests/test-bisect.t
--- a/tests/test-bisect.t
+++ b/tests/test-bisect.t
@@ -453,7 +453,7 @@ assuming that the shell returns 127 if c
 test bisecting command
 
   $ cat > script.py < #!/usr/bin/env python
+  > #!$PYTHON
   > import sys
   > from mercurial import ui, hg
   > repo = hg.repository(ui.ui.load(), '.')
diff --git a/tests/test-extdiff.t b/tests/test-extdiff.t
--- a/tests/test-extdiff.t
+++ b/tests/test-extdiff.t
@@ -249,7 +249,7 @@ Edit with extdiff -p:
 Prepare custom diff/edit tool:
 
   $ cat > 'diff tool.py' << EOT
-  > #!/usr/bin/env python
+  > #!$PYTHON
   > import time
   > time.sleep(1) # avoid unchanged-timestamp problems
   > file('a/a', 'ab').write('edited\n')
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -98,7 +98,7 @@ Command with no output, we just want to 
 Check hgweb's load order:
 
   $ cat > hgweb.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
   > from mercurial.hgweb import wsgicgi
diff --git a/tests/test-highlight.t b/tests/test-highlight.t
--- a/tests/test-highlight.t
+++ b/tests/test-highlight.t
@@ -20,7 +20,7 @@
 create random Python file to exercise Pygments
 
   $ cat < primes.py
-  > #!/usr/bin/env python
+  > #!$PYTHON
   > 
   > """Fun with generators. Corresponding Haskell implementation:
   > 
@@ -151,7 +151,7 @@ hgweb filerevision, html
   line wrap: on
line source
   
-  #!/usr/bin/env python
+  #!* (glob)
   
   Fun with generators. 
Corresponding Haskell implementation:
   
@@ -310,7 +310,7 @@ hgweb fileannotate, html
   changeset
   
   
-   1 #!/usr/bin/env 
python
+   1 #!* 
(glob)
   
   
   
@@ -994,7 +994,7 @@ We attempt to highlight unknown files by
   > EOF
 
   $ cat > unknownfile << EOF
-  > #!/usr/bin/python
+  > #!$PYTHON
   > def foo():
   >pass
   > EOF
diff --git a/tests/test-largefiles-cache.t b/tests/test-largefiles-cache.t
--- a/tests/test-largefiles-cache.t
+++ b/tests/test-largefiles-cache.t
@@ -93,7 +93,7 @@ Verify that largefiles from pulled branc
 Portable way to print file permissions:
 
   $ cat > ls-l.py < #!/usr/bin/env python
+  > #!$PYTHON
   > import sys, os
   > path = sys.argv[1]
   > print '%03o' % (os.lstat(path).st_mode & 0777)
diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t
--- a/tests/test-largefiles.t
+++ b/tests/test-largefiles.t
@@ -215,7 +215,7 @@ Test display of largefiles in hgweb
 Test largefiles can be loaded in hgweb (wrapcommand() shouldn't fail)
 
   $ cat < "$TESTTMP/hgweb.cgi"
-  > #!/usr/bin/env python
+  > #!$PYTHON
   > from mercurial import demandimport; demandimport.enable()
   > from mercurial.hgweb import hgweb
   > from mercurial.hgweb import wsgicgi
diff --git a/tests/test-newcgi.t b/tests/test-newcgi.t
--- a/tests/test-newcgi.t
+++ b/tests/test-newcgi.t
@@ -5,7 +5,7 @@ before d74fc8dec2b4 still work.
 
   $ hg init test
   $ cat >hgweb.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > #
   > # An example CGI script to use hgweb, edit as necessary
   > 
@@ -31,7 +31,7 @@ before d74fc8dec2b4 still work.
   > HGWEBDIRCONF
 
   $ cat >hgwebdir.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > #
   > # An example CGI script to export multiple hgweb repos, edit as necessary
   > 
diff --git a/tests/test-newercgi.t b/tests/test-newercgi.t
--- a/tests/test-newercgi.t
+++ b/tests/test-newercgi.t
@@ -5,7 +5,7 @@ This is a rudimentary test of the CGI fi
   $ hg init test
 
   $ cat >hgweb.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > #
   > # An example CGI script to use hgweb, edit as necessary
   > 
@@ -28,7 +28,7 @@ This is a rudimentary test of the CGI fi
   > HGWEBDIRCONF
 
   $ cat >hgwebdir.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > #
   > # An example CGI script to export multiple hgweb repos, edit as necessary
   > 
diff --git a/tests/test-oldcgi.t b/tests/test-oldcgi.t
--- a/tests/test-oldcgi.t
+++ b/tests/test-oldcgi.t
@@ -4,7 +4,7 @@ This tests if CGI files from before d0db
 
   $ hg init test
   $ cat >hgweb.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > #
   > # An example CGI script to use hgweb, edit as necessary
   > 
@@ -26,7 +26,7 @@ This tests if CGI files from before d0db
   > HGWEBDIRCONF
 
   $ cat >hgwebdir.cgi < #!/usr/bin/env python
+  > #!$PYTHON
   > #
   > # An example CGI script to export multiple hgweb repos, edit as necessary
   > 
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
@@ -1001,7 +1001,7 @@ running is placed.
   > #endif
   >   $ test "\$RUNTESTDIR" = "$TESTDIR"
   >   $ head -n 3 

Re: [PATCH RFC] show: implement "stack" view

2017-06-18 Thread Augie Fackler
On Sat, Jun 17, 2017 at 01:02:49PM -0600, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc 
> # Date 1497726059 21600
> #  Sat Jun 17 13:00:59 2017 -0600
> # Node ID c9a3d8cdbb925614419216d6e99d9a70f03d926d
> # Parent  9fcb6df413c9ca475e705ecc15df07584dadb0c1
> show: implement "stack" view
>
> People often want to know what they are working on *now*. As part of
> this, they also commonly want to know how that work is related to other
> changesets in the repo so they can perform common actions like rebase,
> histedit, and merge.
>
> `hg show work` made headway into this space. However, it is geared
> towards a complete repo view as opposed to just the current line of
> work. If you have a lot of in-flight work or the repo has many heads,
> the output can be overwhelming. The closest thing Mercurial has to
> "show me the current thing I'm working on" that doesn't require custom
> revsets is `hg qseries`. And this requires MQ, which completely changes
> workflows and repository behavior and has horrible performance on large
> repos. But as sub-optimal as MQ is, it does some things right, such as
> expose a model of the repo that is easy for people to reason about.
> This simplicity is why I think a lot of people prefer to use MQ, despite
> its shortcomings.
>
> One common development workflow is to author a series of linear
> changesets, using bookmarks, branches, anonymous heads, or even topics
> (3rd party extension). I'll call this a "stack."

We don't use the term stack yet in Mercurial, other than (oddly
enough!) the help for MQ. I'm not wholly opposed to coming up with a
noun for this (stack might even be the right choice), but I think it
might be worth doing a survey of the existing terms of art for this in
our features (eg I know patchbomb calls it a series - that might be
the only other place this is explicitly named right now?)

> You periodically
> rewrite history in place (using `hg histedit`) and reparent the stack
> against newer changesets (using `hg rebase`). This workflow can be
> difficult because there is no obvious way to quickly see the current
> "stack" nor its relation to other changesets. Figuring out arguments to
> `hg rebase` can be difficult and may require highlighting and pasting
> multiple changeset nodes to construct a command.
>
> The goal of this commit is to make stack based workflows simpler
> by exposing a view of the current stack and its relationship to
> other releant changesets, notably the parent of the base changeset
> in the stack and newer heads that the stack could be rebased or merged
> into.
>
> Introduced is the `hg show stack` view. Essentially, it finds all
> mutable changesets from the working directory revision in both
> directions, stopping at a merge or branch point. This limits the
> revisions to a DAG linear range.

Does this have some affordance so that other extensions
(remote{names,branches} specifically come to mind) can redefine the
stack boundary? On Mercurial itself just sniffing for draft changes
will show a lot of things I don't care about anymore since they're
pushed upstream. :)

>
> The stack is rendered as a concise list of changesets. Alongside the
> stack is a visualization of the DAG, similar to `hg log -G`.

Assuming this retains the same lack of BC that we're embracing in `hg
show`, I'm happy to land something eagerly and iterate (my nagging
concerns about noun choice aside.)

[... elided entire implementation, which I didn't read yet ...]

> diff --git a/tests/test-show-stack.t b/tests/test-show-stack.t
> new file mode 100644
> --- /dev/null
> +++ b/tests/test-show-stack.t
> @@ -0,0 +1,235 @@
> +  $ cat >> $HGRCPATH << EOF
> +  > [extensions]
> +  > show =
> +  > EOF
> +
> +  $ hg init repo0
> +  $ cd repo0
> +
> +Empty repo / no checkout results in error
> +
> +  $ hg show stack
> +  abort: stack view only available when there is a working directory
> +  [255]
> +
> +Stack displays single draft changeset as root revision
> +
> +  $ echo 0 > foo
> +  $ hg -q commit -A -m 'commit 0'
> +  $ hg show stack
> +@  9f171 commit 0
> +
> +Stack displays multiple draft changesets
> +
> +  $ echo 1 > foo
> +  $ hg commit -m 'commit 1'
> +  $ echo 2 > foo
> +  $ hg commit -m 'commit 2'
> +  $ echo 3 > foo
> +  $ hg commit -m 'commit 3'
> +  $ echo 4 > foo
> +  $ hg commit -m 'commit 4'
> +  $ hg show stack
> +@  2737b commit 4
> +o  d1a69 commit 3
> +o  128c8 commit 2
> +o  181cc commit 1
> +o  9f171 commit 0
> +
> +Public parent of draft base is displayed, separated from stack
> +
> +  $ hg phase --public -r 0
> +  $ hg show stack
> +@  2737b commit 4
> +o  d1a69 commit 3
> +o  128c8 commit 2
> +o  181cc commit 1
> +   /   (stack base)
> +  o  9f171 commit 0
> +
> +  $ hg phase --public -r 1
> +  $ hg show stack
> +@  2737b commit 4
> +o  d1a69 commit 3
> +o  128c8 commit 2
> +   /   (stack base)
> +  o  181cc commit 1
> +
> +Draft descendants are 

Re: [PATCH 2 of 2] dagop: move blockancestors() and blockdescendants() from context

2017-06-18 Thread Augie Fackler
On Sun, Jun 18, 2017 at 12:59:23AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1487500634 -32400
> #  Sun Feb 19 19:37:14 2017 +0900
> # Node ID 4b258e839f739c8c5c422b34891598aeb05858aa
> # Parent  ea5c0d4b4f3ff4b78218d21e29b8c2068f78907f
> dagop: move blockancestors() and blockdescendants() from context

queued, thanks

(slight conflict that required rebase to fix, but diff-of-diffs looks
sensible based on recent activity in revset.py)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 fix-old-git V2] tests: protect tests involving git ext::sh with git-ext-sh

2017-06-18 Thread Augie Fackler
On Sun, Jun 18, 2017 at 05:00:32PM -0700, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley 
> # Date 1497572093 25200
> #  Thu Jun 15 17:14:53 2017 -0700
> # Branch fix-old-git
> # Node ID 437d33723a6ef1cd58b4d0646adf3a5248102761
> # Parent  8e8e4eb5d74ec4ed2ea59db3defa9819ddc0db8b
> tests: protect tests involving git ext::sh with git-ext-sh

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


[PATCH 1 of 2 fix-old-git V2] hghave: add has_git_range for testing if git understands ext::sh

2017-06-18 Thread Sean Farley
# HG changeset patch
# User Sean Farley 
# Date 1497572003 25200
#  Thu Jun 15 17:13:23 2017 -0700
# Branch fix-old-git
# Node ID 8e8e4eb5d74ec4ed2ea59db3defa9819ddc0db8b
# Parent  07d5a503124caed05e1300a5208240764882c831
hghave: add has_git_range for testing if git understands ext::sh

Even on CentOS 7, git is at version 1.8. It seems git 1.9 is when
ext::sh was introduced so we a check for that. The way these functions
are written follows the same style and format for the way we check svn
and bzr versions.

diff --git a/tests/hghave.py b/tests/hghave.py
index 09b8dbe..2cb0d1f 100644
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -276,10 +276,21 @@ def has_gettext():
 
 @check("git", "git command line client")
 def has_git():
 return matchoutput('git --version 2>&1', br'^git version')
 
+def getgitversion():
+m = matchoutput('git --version 2>&1', br'git version (\d+)\.(\d+)')
+if not m:
+return (0, 0)
+return (int(m.group(1)), int(m.group(2)))
+
+@checkvers("git", "git client (with ext::sh support) version >= %s", (1.9,))
+def has_git_range(v):
+major, minor = v.split('.')[0:2]
+return getgitversion() >= (int(major), int(minor))
+
 @check("docutils", "Docutils text processing library")
 def has_docutils():
 try:
 import docutils.core
 docutils.core.publish_cmdline # silence unused import
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 5 topic-experiment] topics: abort if user wants to show the stack of a non-existent topic

2017-06-18 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1497822215 -19800
#  Mon Jun 19 03:13:35 2017 +0530
# Node ID 8d8ac3adc1f9e03625d293ae78f250b115154d94
# Parent  83df91589000c05359805c96fa84a3995896ee3c
topics: abort if user wants to show the stack of a non-existent topic

diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py
+++ b/hgext3rd/topic/stack.py
@@ -22,6 +22,10 @@
 return ' '.join(prefix % suffix for suffix in labelssuffix)
 
 def showstack(ui, repo, topic, opts):
+
+if topic not in repo.topics:
+raise error.Abort(_('cannot resolve "%s": no such topic found') % 
topic)
+
 fm = ui.formatter('topicstack', opts)
 prev = None
 entries = []
diff --git a/tests/test-topic-stack.t b/tests/test-topic-stack.t
--- a/tests/test-topic-stack.t
+++ b/tests/test-topic-stack.t
@@ -319,3 +319,11 @@
   t2@ c_D (current)
   t1: c_c
 ^ c_b
+
+Trying to list non existing topic
+  $ hg stack thisdoesnotexist
+  abort: cannot resolve "thisdoesnotexist": no such topic found
+  [255]
+  $ hg topic --list thisdoesnotexist
+  abort: cannot resolve "thisdoesnotexist": no such topic found
+  [255]
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 5 topic-experiment] stack: show unstable state for the current revision if it is one (issue5553)

2017-06-18 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1497820835 -19800
#  Mon Jun 19 02:50:35 2017 +0530
# Node ID 83df91589000c05359805c96fa84a3995896ee3c
# Parent  46b090ecd2b9f69f52cae756008f199f78bb22c1
stack: show unstable state for the current revision if it is one (issue5553)

Before this patch if the current revision is unstable, hg stack does not show
the unstable state. This patch fixes that by showing both current and unstable
state for the current revision if that's unstable.

diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py
--- a/hgext3rd/topic/stack.py
+++ b/hgext3rd/topic/stack.py
@@ -69,19 +69,22 @@
 states = []
 iscurrentrevision = repo.revs('%d and parents()', ctx.rev())
 
-if iscurrentrevision:
-states.append('current')
-
 if not isentry:
 symbol = '^'
 # "base" is kind of a "ghost" entry
 # skip other label for them (no current, no unstable)
 states = ['base']
-elif iscurrentrevision:
-symbol = '@'
 elif repo.revs('%d and unstable()', ctx.rev()):
 symbol = '$'
 states.append('unstable')
+# current revision can be unstable also, so in that case show both
+# the states and the symbol '@' (issue5553)
+if iscurrentrevision:
+states.append('current')
+symbol = '@'
+elif iscurrentrevision:
+states.append('current')
+symbol = '@'
 else:
 symbol = ':'
 states.append('clean')
diff --git a/tests/test-topic-stack.t b/tests/test-topic-stack.t
--- a/tests/test-topic-stack.t
+++ b/tests/test-topic-stack.t
@@ -188,7 +188,7 @@
   ### topic: foo
   ### branch: default
   t4$ c_f (unstable)
-  t3@ c_e (current)
+  t3@ c_e (unstable current)
   t2: c_d
   t1: c_c
 ^ c_b
@@ -196,7 +196,7 @@
   [topic.stack.summary.topic|### topic: [topic.active|foo]]
   [topic.stack.summary.branches|### branch: default]
   [topic.stack.index topic.stack.index.unstable|t4][topic.stack.state 
topic.stack.state.unstable|$] [topic.stack.desc 
topic.stack.desc.unstable|c_f][topic.stack.state topic.stack.state.unstable| 
(unstable)]
-  [topic.stack.index topic.stack.index.current|t3][topic.stack.state 
topic.stack.state.current|@] [topic.stack.desc 
topic.stack.desc.current|c_e][topic.stack.state topic.stack.state.current| 
(current)]
+  [topic.stack.index topic.stack.index.unstable 
topic.stack.index.current|t3][topic.stack.state topic.stack.state.unstable 
topic.stack.state.current|@] [topic.stack.desc topic.stack.desc.unstable 
topic.stack.desc.current|c_e][topic.stack.state topic.stack.state.unstable 
topic.stack.state.current| (unstable current)]
   [topic.stack.index topic.stack.index.clean|t2][topic.stack.state 
topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_d]
   [topic.stack.index topic.stack.index.clean|t1][topic.stack.state 
topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_c]
 [topic.stack.state topic.stack.state.base|^] [topic.stack.desc 
topic.stack.desc.base|c_b]
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 5 topic-experiment] topics: make sure we commit on new parents while changing topics (issue5441)

2017-06-18 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1497736426 -19800
#  Sun Jun 18 03:23:46 2017 +0530
# Node ID 3c6e013ffb8cb4e76b1e496bf8c34ebf790a506d
# Parent  522b3457c765d271d8029a92dc3d8590b6679c6b
topics: make sure we commit on new parents while changing topics (issue5441)

While changing topics of a set of linear commits, we used to commit our new
changesets with new topic on parents of its predecessor i.e. changeset before
the topic change. If the topic of parent was also changed, that parent will
become obsolete and hence resulting the cnew commit in unstable state. For a set
of linear commits this repeats and we end up in a tree state as mentioned in the
bug.

This patch fixes the bug by checking whether the parent was obsoleted and if
yes, commit on the new parent.

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -282,6 +282,10 @@
 l = repo.lock()
 txn = repo.transaction('rewrite-topics')
 try:
+newp = None
+oldp = None
+p1 = None
+p2 = None
 for c in repo.set('%r', change):
 def filectxfn(repo, ctx, path):
 try:
@@ -309,11 +313,25 @@
 ui.debug('changing topic of %s from %s to %s\n' % (
 c, oldtopic, newtopic))
 ui.debug('fixedextra: %r\n' % fixedextra)
+# While changing topic of set of linear commits, make sure that
+# we base our commits on new parent rather than old parent 
which
+# was obsoleted while changing the topic
+if newp and c.p1().node() == oldp:
+p1 = newp
+p2 = c.p2().node()
+elif newp and c.p2().node() == oldp:
+p1 = c.p1().node()
+p2 = newp
+else:
+p1 = c.p1().node()
+p2 = c.p2().node()
 mc = context.memctx(
-repo, (c.p1().node(), c.p2().node()), c.description(),
+repo, (p1, p2), c.description(),
 c.files(), filectxfn,
 user=c.user(), date=c.date(), extra=fixedextra)
 newnode = repo.commitctx(mc)
+oldp = c.node()
+newp = newnode
 ui.debug('new node id is %s\n' % node.hex(newnode))
 needevolve = needevolve or (len(c.children()) > 0)
 obsolete.createmarkers(repo, [(c, (repo[newnode],))])
diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -679,30 +679,28 @@
   changed topic on 2 changes
   please run hg evolve --rev "topic(changewat)" now
   $ hg log -Gr 'draft()'
-  o  changeset:   21:3c7d84fcabcd
+  o  changeset:   21:58e15a6365ca
   |  tag: tip
   |  topic:   changewat
-  |  parent:  13:d91cd8fd490e
   |  user:test
   |  date:Thu Jan 01 00:00:00 1970 +
-  |  trouble: unstable
   |  summary: fran?
   |
-  | o  changeset:   20:a96ac830b62e
-  | |  topic:   changewat
-  | |  parent:  3:a53952faf762
+  o  changeset:   20:a96ac830b62e
+  |  topic:   changewat
+  |  parent:  3:a53952faf762
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: start on fran
+  |
+  | @  changeset:   19:b72b86a1f96b
+  | |  topic:   watwat
+  | |  parent:  13:d91cd8fd490e
   | |  user:test
   | |  date:Thu Jan 01 00:00:00 1970 +
-  | |  summary: start on fran
+  | |  summary: fran?
   | |
-  +---@  changeset:   19:b72b86a1f96b
-  | |topic:   watwat
-  | |parent:  13:d91cd8fd490e
-  | |user:test
-  | |date:Thu Jan 01 00:00:00 1970 +
-  | |summary: fran?
-  | |
-  x |  changeset:   13:d91cd8fd490e
+  | x  changeset:   13:d91cd8fd490e
   |/   topic:   wat
   |parent:  3:a53952faf762
   |user:test
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 5 topic-experiment] tests: add a test to show issue5441 in test-topic.t

2017-06-18 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1497736252 -19800
#  Sun Jun 18 03:20:52 2017 +0530
# Node ID 522b3457c765d271d8029a92dc3d8590b6679c6b
# Parent  6e5f5de46c50ebb104a467f4d90a5fa9882db1b9
tests: add a test to show issue5441 in test-topic.t

The issue will be fixed in the next patch and the test will be helpful to show
that.

diff --git a/tests/test-topic.t b/tests/test-topic.t
--- a/tests/test-topic.t
+++ b/tests/test-topic.t
@@ -654,3 +654,58 @@
 Readding the same topic with topic --change should work:
   $ hg topic --change . watwat
   changed topic on 1 changes
+
+Testing issue5441
+  $ hg co 19
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg log -Gr 'draft()'
+  @  changeset:   19:b72b86a1f96b
+  |  tag: tip
+  |  topic:   watwat
+  |  parent:  13:d91cd8fd490e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: fran?
+  |
+  o  changeset:   13:d91cd8fd490e
+  |  topic:   wat
+  |  parent:  3:a53952faf762
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: start on fran
+  |
+
+  $ hg topics --change '13::19' changewat
+  changed topic on 2 changes
+  please run hg evolve --rev "topic(changewat)" now
+  $ hg log -Gr 'draft()'
+  o  changeset:   21:3c7d84fcabcd
+  |  tag: tip
+  |  topic:   changewat
+  |  parent:  13:d91cd8fd490e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  trouble: unstable
+  |  summary: fran?
+  |
+  | o  changeset:   20:a96ac830b62e
+  | |  topic:   changewat
+  | |  parent:  3:a53952faf762
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: start on fran
+  | |
+  +---@  changeset:   19:b72b86a1f96b
+  | |topic:   watwat
+  | |parent:  13:d91cd8fd490e
+  | |user:test
+  | |date:Thu Jan 01 00:00:00 1970 +
+  | |summary: fran?
+  | |
+  x |  changeset:   13:d91cd8fd490e
+  |/   topic:   wat
+  |parent:  3:a53952faf762
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: start on fran
+  |
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 5 topic-experiment] topics: some minute fixes to the documentation which shows up in help

2017-06-18 Thread Pulkit Goyal
# HG changeset patch
# User Pulkit Goyal <7895pul...@gmail.com>
# Date 1497820459 -19800
#  Mon Jun 19 02:44:19 2017 +0530
# Node ID 46b090ecd2b9f69f52cae756008f199f78bb22c1
# Parent  3c6e013ffb8cb4e76b1e496bf8c34ebf790a506d
topics: some minute fixes to the documentation which shows up in help

I am not a native but these changes are simple and obvious.

diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py
+++ b/hgext3rd/topic/__init__.py
@@ -10,7 +10,7 @@
 Compared to bookmark, topic is reference carried by each changesets of the
 series instead of just the single head revision.  Topic are quite similar to
 the way named branch work, except they eventualy fade away when the changeset
-becomes part of the immutable history.  Changeset can below to both a topic and
+becomes part of the immutable history. Changeset can belong to both a topic and
 a named branch, but as long as it is mutable, its topic identity will prevail.
 As a result, default destination for 'update', 'merge', etc...  will take topic
 into account. When a topic is active these operations will only consider other
@@ -21,10 +21,11 @@
 There is currently two commands to be used with that extension: 'topics' and
 'stack'.
 
-The 'hg topics' command is used to set the current topic and list existing one.
-'hg topics --verbose' will list various information related to each topic.
+The 'hg topics' command is used to set the current topic, change and list
+existing one. 'hg topics --verbose' will list various information related to
+each topic.
 
-The 'stack' will show you in formation about the stack of commit belonging to
+The 'stack' will show you information about the stack of commit belonging to
 your current topic.
 
 Topic is offering you aliases reference to changeset in your current topic
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH RFC] ui: add support for a tweakdefaults knob

2017-06-18 Thread Pierre-Yves David



On 06/15/2017 05:48 PM, Yuya Nishihara wrote:

On Thu, 15 Jun 2017 11:21:33 -0400, Augie Fackler wrote:

On Jun 15, 2017, at 11:19, Yuya Nishihara  wrote:
On Wed, 14 Jun 2017 21:37:21 -0400, Augie Fackler wrote:

# HG changeset patch
# User Augie Fackler 
# Date 1497488194 14400
#  Wed Jun 14 20:56:34 2017 -0400
# Node ID 0e5ea7a86a8021d02218c35b07366ac6081ab3fb
# Parent  3abba5bc34546951b11b1bd3f5e5c77b90d950d1
ui: add support for a tweakdefaults knob


+1


+def _maybetweakdefaults(self):
+if not self.configbool('ui', 'tweakdefaults'):
+return
+if self._tweaked or self.plain('tweakdefaults'):
+return
+
+# Note: it is SUPER IMPORTANT that you set self._tweaked to
+# True *before* any calls to setconfig(), otherwise you'll get
+# infinite recursion between setconfig and this method.
+#
+# TODO: We should extract an inner method in setconfig() to
+# avoid this weirdness.
+self._tweaked = True
+tmpcfg = config.config()
+tmpcfg.parse('', tweakrc)
+for section in tmpcfg:
+for name, value in tmpcfg.items(section):
+if not self.hasconfig(section, name):
+self.setconfig(section, name, value, "")


Maybe we want tmpcfg -> {ucfg, tcfg} -> ocfg layers, but it wouldn't be
doable right now since tmpcfg should be inserted *after* [uto]cfg are
loaded.


Yeah. Nobody seems motivated enough to do that work, which I totally get, so I did "done" 
instead of "clean". If it ever gets to be enough of a pain we can refactor, and we can 
maybe fix it up if we ever redo configuration to be a stack of immutable objects.


Nobody except for Jun. I'll review this patch more carefully tomorrow and
probably queue it.


A registry of config option including default value would also fit that 
need. the tweak default knob could update these default in (a copy of) 
the config registry. That would skip the explicit update of the config 
content (and associated concerns).


There have been talk about such registry of option for quite some time 
(including at the 4.2 central sprint). David Demelier ping me about 
this[1] again 10 days ago and found some time to poke at it yesterday.


It turned out I ended up with something that work, I've started 
patchbombing it[2]. Once this is in, we can update the tweakdefault flag 
to use this.


[1] as part of his quest for 
https://www.mercurial-scm.org/wiki/ConfigConsolidationPlan
[2] 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2017-June/099866.html


Cheers,

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


Re: [PATCH 01 of 10] config: explicitly track the use of the standard default value

2017-06-18 Thread Pierre-Yves David


On 06/18/2017 08:55 PM, Pierre-Yves David wrote:

# HG changeset patch
# User Pierre-Yves David 
# Date 1497696671 -7200
#  Sat Jun 17 12:51:11 2017 +0200
# Node ID 5e988d4f834b981d8aaf9d77019550d3800687d5
# Parent  29558247b00eff8c95c7604032b59cfbab34010d
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 5e988d4f834b
config: explicitly track the use of the standard default value

We introduce a small object used to detect that no specific default value has
been passed to 'ui.config'. We need this explicit special value since "None" is
a valid and common default value.

The end goal here is to make progress on a centralised and explicit declaration
of the available config option. A first good usecase for this are "default"
value.  Before starting looking further down this alley we needs to rework the
handling of default value in the 'ui' object to have all configxyz methods going
through the same logic. This is the first changeset on this trek.


The rest of the series (introducing the config registry) is visible here:


https://www.mercurial-scm.org/repo/users/marmoute/mercurial/log?revcount=24=5e988d4f834b%3A%3A8451ff2a0ec5

It does the minimal amount of work to:
* introduce a central registry,
* support reading config item default value from the registry,
* test it for all type of config that used a default,
* allow extension to extend it (cleanly),
* devel warning to catch usage error.

From here, we will be able to:
* add new types of feature to the registry (alias, documentation, etc)
* register all known options (and add support for the necessary special 
case)


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


[PATCH 09 of 10] config: use the 'config' method in 'configsuboptions'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497716900 -7200
#  Sat Jun 17 18:28:20 2017 +0200
# Node ID d8629b5effa68c296e2da9bb8b6eb3ec3451793c
# Parent  a7036af610313c30e956262d57f12931af60576e
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r d8629b5effa6
config: use the 'config' method in 'configsuboptions'

There was unnecessary code duplication. It was getting in the way of the
unification of the default value logic.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -432,14 +432,8 @@ class ui(object):
 Returns a 2-tuple of ``(option, sub-options)``, where `sub-options``
 is a dict of defined sub-options where keys and values are strings.
 """
+main = self.config(section, name, default, untrusted=untrusted)
 data = self._data(untrusted)
-main = data.get(section, name, default)
-if self.debugflag and not untrusted and self._reportuntrusted:
-uvalue = self._ucfg.get(section, name)
-if uvalue is not None and uvalue != main:
-self.debug('ignoring untrusted configuration option '
-   '%s.%s = %s\n' % (section, name, uvalue))
-
 sub = {}
 prefix = '%s:' % name
 for k, v in data.items(section):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 08 of 10] config: use the new '_unset' value for 'configpath'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696722 -7200
#  Sat Jun 17 12:52:02 2017 +0200
# Node ID a7036af610313c30e956262d57f12931af60576e
# Parent  f3d6b4a73db3dc172b7ac2f30c84d4e509df22fe
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a7036af61031
config: use the new '_unset' value for 'configpath'

This should let 'configpath' delegate all special processing of the default
config value to the main 'config' method.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -455,7 +455,7 @@ class ui(object):
 
 return main, sub
 
-def configpath(self, section, name, default=None, untrusted=False):
+def configpath(self, section, name, default=_unset, untrusted=False):
 'get a path config item, expanded relative to repo root or config file'
 v = self.config(section, name, default, untrusted)
 if v is None:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 10 of 10] config: use the new '_unset' value for 'configsuboptions'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696697 -7200
#  Sat Jun 17 12:51:37 2017 +0200
# Node ID e61cd1328c8dd85d8e02a5519e028747074ff254
# Parent  d8629b5effa68c296e2da9bb8b6eb3ec3451793c
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r e61cd1328c8d
config: use the new '_unset' value for 'configsuboptions'

This should let configsuboptions delegate all special processing of the default
config value to the main 'config' method.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -422,7 +422,7 @@ class ui(object):
"%s.%s = %s\n" % (section, n, uvalue))
 return value
 
-def configsuboptions(self, section, name, default=None, untrusted=False):
+def configsuboptions(self, section, name, default=_unset, untrusted=False):
 """Get a config option and all sub-options.
 
 Some config options have sub-options that are declared with the
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 01 of 10] config: explicitly track the use of the standard default value

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696671 -7200
#  Sat Jun 17 12:51:11 2017 +0200
# Node ID 5e988d4f834b981d8aaf9d77019550d3800687d5
# Parent  29558247b00eff8c95c7604032b59cfbab34010d
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 5e988d4f834b
config: explicitly track the use of the standard default value

We introduce a small object used to detect that no specific default value has
been passed to 'ui.config'. We need this explicit special value since "None" is
a valid and common default value.

The end goal here is to make progress on a centralised and explicit declaration
of the available config option. A first good usecase for this are "default"
value.  Before starting looking further down this alley we needs to rework the
handling of default value in the 'ui' object to have all configxyz methods going
through the same logic. This is the first changeset on this trek.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -140,6 +140,10 @@ class httppasswordmgrdbproxy(object):
 def _catchterm(*args):
 raise error.SignalInterrupt
 
+# unique object used to detect no default value has been provided when
+# retrieving configuration value.
+_unset = object()
+
 class ui(object):
 def __init__(self, src=None):
 """Create a fresh new ui object if no src given
@@ -394,7 +398,9 @@ class ui(object):
 def configsource(self, section, name, untrusted=False):
 return self._data(untrusted).source(section, name)
 
-def config(self, section, name, default=None, untrusted=False):
+def config(self, section, name, default=_unset, untrusted=False):
+if default is _unset:
+default = None
 if isinstance(name, list):
 alternates = name
 else:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 04 of 10] config: use the new '_unset' value for 'configint'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696820 -7200
#  Sat Jun 17 12:53:40 2017 +0200
# Node ID 11f995470103d355c41e2bfc7b37160175f026cd
# Parent  3984cb4c86deba1c255208f6c2e4a98f4aff227b
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 11f995470103
config: use the new '_unset' value for 'configint'

This should let 'configint' delegates all special processing of the default
config value to the main 'config' method.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -536,7 +536,7 @@ class ui(object):
 raise error.ConfigError(_("%s.%s is not a valid %s ('%s')")
 % (section, name, desc, v))
 
-def configint(self, section, name, default=None, untrusted=False):
+def configint(self, section, name, default=_unset, untrusted=False):
 """parse a configuration element as an integer
 
 >>> u = ui(); s = 'foo'
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 07 of 10] config: use the new '_unset' value for 'configdate'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696885 -7200
#  Sat Jun 17 12:54:45 2017 +0200
# Node ID f3d6b4a73db3dc172b7ac2f30c84d4e509df22fe
# Parent  d088b10b758236bde21b123edad6eae1b8d3139c
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r f3d6b4a73db3
config: use the new '_unset' value for 'configdate'

This should let 'configdate' delegate all special processing of the default
config value to the main 'config' method.

The default value for date (None) is still enforced in this method if no other
default were passed.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -611,7 +611,7 @@ class ui(object):
 return []
 return v
 
-def configdate(self, section, name, default=None, untrusted=False):
+def configdate(self, section, name, default=_unset, untrusted=False):
 """parse a configuration element as a tuple of ints
 
 >>> u = ui(); s = 'foo'
@@ -622,6 +622,8 @@ class ui(object):
 if self.config(section, name, default, untrusted):
 return self.configwith(util.parsedate, section, name, default,
'date', untrusted)
+if default is _unset:
+return None
 return default
 
 def hasconfig(self, section, name, untrusted=False):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 10] config: use the new '_unset' value for 'configbytes'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696831 -7200
#  Sat Jun 17 12:53:51 2017 +0200
# Node ID fa4f7a297bc32124742d631460fa44677854f202
# Parent  11f995470103d355c41e2bfc7b37160175f026cd
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r fa4f7a297bc3
config: use the new '_unset' value for 'configbytes'

This should let 'configbytes' delegates all special processing of the default
config value to the main 'config' method.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -558,7 +558,7 @@ class ui(object):
 return self.configwith(int, section, name, default, 'integer',
untrusted)
 
-def configbytes(self, section, name, default=0, untrusted=False):
+def configbytes(self, section, name, default=_unset, untrusted=False):
 """parse a configuration element as a quantity in bytes
 
 Units can be specified as b (bytes), k or kb (kilobytes), m or
@@ -580,11 +580,13 @@ class ui(object):
 ConfigError: foo.invalid is not a byte quantity ('somevalue')
 """
 
-value = self.config(section, name, None, untrusted)
+value = self.config(section, name, default, untrusted)
 if value is None:
-if not isinstance(default, str):
-return default
+if default is _unset:
+default = 0
 value = default
+if not isinstance(value, str):
+return value
 try:
 return util.sizetoint(value)
 except error.ParseError:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 03 of 10] config: use the new '_unset' value for 'configwith'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696751 -7200
#  Sat Jun 17 12:52:31 2017 +0200
# Node ID 3984cb4c86deba1c255208f6c2e4a98f4aff227b
# Parent  0d7b693176387264f4e04e8ee6455195fa871e93
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 3984cb4c86de
config: use the new '_unset' value for 'configwith'

This should let 'configwith' delegate all special processing of the default
config value to the main 'config' method.

This changeset introduce a small change in behavior since the default value is
run through the 'convert' function. This does not seems harmful and no actual
test break. This small change make the code simpler so I'm keeping it.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -501,7 +501,7 @@ class ui(object):
 % (section, name, v))
 return b
 
-def configwith(self, convert, section, name, default=None,
+def configwith(self, convert, section, name, default=_unset,
desc=None, untrusted=False):
 """parse a configuration element with a conversion function
 
@@ -513,7 +513,7 @@ class ui(object):
 >>> u.configwith(float, s, 'float2')
 -4.25
 >>> u.configwith(float, s, 'unknown', 7)
-7
+7.0
 >>> u.setconfig(s, 'invalid', 'somevalue')
 >>> u.configwith(float, s, 'invalid')
 Traceback (most recent call last):
@@ -525,9 +525,9 @@ class ui(object):
 ConfigError: foo.invalid is not a valid womble ('somevalue')
 """
 
-v = self.config(section, name, None, untrusted)
+v = self.config(section, name, default, untrusted)
 if v is None:
-return default
+return v # do not attempt to convert None
 try:
 return convert(v)
 except (ValueError, error.ParseError):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 06 of 10] config: use the new '_unset' value for 'configlist'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696844 -7200
#  Sat Jun 17 12:54:04 2017 +0200
# Node ID d088b10b758236bde21b123edad6eae1b8d3139c
# Parent  fa4f7a297bc32124742d631460fa44677854f202
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r d088b10b7582
config: use the new '_unset' value for 'configlist'

This should let 'configlist' delegate all special processing of the default
config value to the main 'config' method.

The default config value ([]) is still handled in this method.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -593,7 +593,7 @@ class ui(object):
 raise error.ConfigError(_("%s.%s is not a byte quantity ('%s')")
 % (section, name, value))
 
-def configlist(self, section, name, default=None, untrusted=False):
+def configlist(self, section, name, default=_unset, untrusted=False):
 """parse a configuration element as a list of comma/space separated
 strings
 
@@ -603,10 +603,13 @@ class ui(object):
 ['this', 'is', 'a small', 'test']
 """
 # default is not always a list
-if isinstance(default, bytes):
-default = config.parselist(default)
-return self.configwith(config.parselist, section, name, default or [],
+v = self.configwith(config.parselist, section, name, default,
'list', untrusted)
+if isinstance(v, bytes):
+return config.parselist(v)
+elif v is None:
+return []
+return v
 
 def configdate(self, section, name, default=None, untrusted=False):
 """parse a configuration element as a tuple of ints
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 02 of 10] config: use the new '_unset' value for 'configbool'

2017-06-18 Thread Pierre-Yves David
# HG changeset patch
# User Pierre-Yves David 
# Date 1497696736 -7200
#  Sat Jun 17 12:52:16 2017 +0200
# Node ID 0d7b693176387264f4e04e8ee6455195fa871e93
# Parent  5e988d4f834b981d8aaf9d77019550d3800687d5
# EXP-Topic config.register
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 0d7b69317638
config: use the new '_unset' value for 'configbool'

This should let 'configbool' delegate all special processing of the default
config value to the main 'config' method.

The default value for bool (False) is still enforced in this method if no other
default were passed.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -467,7 +467,7 @@ class ui(object):
 v = os.path.join(base, os.path.expanduser(v))
 return v
 
-def configbool(self, section, name, default=False, untrusted=False):
+def configbool(self, section, name, default=_unset, untrusted=False):
 """parse a configuration element as a boolean
 
 >>> u = ui(); s = 'foo'
@@ -488,8 +488,10 @@ class ui(object):
 ConfigError: foo.invalid is not a boolean ('somevalue')
 """
 
-v = self.config(section, name, None, untrusted)
+v = self.config(section, name, default, untrusted=untrusted)
 if v is None:
+if default is _unset:
+return False
 return default
 if isinstance(v, bool):
 return v
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3 RFC] templatekw: use common "rev:node" format as the default of predecessors

2017-06-18 Thread Boris Feld
The series look much more better, thank you!

The output is much more clear too!

What would be the best way to include it with an option in hg log
output?

On Sat, 2017-06-17 at 14:02 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1497674058 -32400
> #  Sat Jun 17 13:34:18 2017 +0900
> # Node ID 858c7664b9097bc159bd9347648c1fd17de2826e
> # Parent  5b1a8349209c04dfc5aec3c52a97f7302bcaf322
> templatekw: use common "rev:node" format as the default of
> predecessors
> 
> I'm not sure if this is better. If we're planning to add a template
> keyword
> that returns obsoleted nodes unavailable in the repo (i.e. they have
> no valid
> revision numbers), we might want to use the current "node"-only
> format
> everywhere.
> 
> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -570,7 +570,7 @@ def showpredecessors(repo, ctx, **args):
>  
>  return _hybrid(None, predecessors,
> lambda x: {'ctx': repo[x], 'revcache': {}},
> -   lambda d: short(scmutil.binnode(d['ctx'])))
> +   lambda d: _formatrevnode(d['ctx']))
>  
>  @templatekeyword('p1rev')
>  def showp1rev(repo, ctx, templ, **args):
> diff --git a/tests/test-obsmarker-template.t b/tests/test-obsmarker-
> template.t
> --- a/tests/test-obsmarker-template.t
> +++ b/tests/test-obsmarker-template.t
> @@ -70,8 +70,8 @@ Check templates
>  Predecessors template should show current revision as it is the
> working copy
>    $ hg tlog
>    o  d004c8f274b9
> -  |Predecessors: 471f378eab4c
> -  |semi-colon: 471f378eab4c
> +  |Predecessors: 1:471f378eab4c
> +  |semi-colon: 1:471f378eab4c
>    |json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
>    |map: 1:471f378eab4c5e25f6c77f785b27c936efb22874
>    | @  471f378eab4c
> @@ -84,8 +84,8 @@ Predecessors template should show curren
>  Predecessors template should show current revision as it is the
> working copy
>    $ hg tlog
>    o  d004c8f274b9
> -  |Predecessors: a468dc9b3633
> -  |semi-colon: a468dc9b3633
> +  |Predecessors: 3:a468dc9b3633
> +  |semi-colon: 3:a468dc9b3633
>    |json: ["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]
>    |map: 3:a468dc9b36338b14fdb7825f55ce3df4e71517ad
>    | @  a468dc9b3633
> @@ -96,13 +96,13 @@ Predecessors template should show all th
>  with --hidden
>    $ hg tlog --hidden
>    o  d004c8f274b9
> -  |Predecessors: a468dc9b3633
> -  |semi-colon: a468dc9b3633
> +  |Predecessors: 3:a468dc9b3633
> +  |semi-colon: 3:a468dc9b3633
>    |json: ["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]
>    |map: 3:a468dc9b36338b14fdb7825f55ce3df4e71517ad
>    | @  a468dc9b3633
> -  |/ Predecessors: 471f378eab4c
> -  |  semi-colon: 471f378eab4c
> +  |/ Predecessors: 1:471f378eab4c
> +  |  semi-colon: 1:471f378eab4c
>    |  json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
>    |  map: 1:471f378eab4c5e25f6c77f785b27c936efb22874
>    | x  f137d23bb3e1
> @@ -123,13 +123,13 @@ visible.
>    
>    $ hg tlog --hidden
>    @  d004c8f274b9
> -  |Predecessors: a468dc9b3633
> -  |semi-colon: a468dc9b3633
> +  |Predecessors: 3:a468dc9b3633
> +  |semi-colon: 3:a468dc9b3633
>    |json: ["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]
>    |map: 3:a468dc9b36338b14fdb7825f55ce3df4e71517ad
>    | x  a468dc9b3633
> -  |/ Predecessors: 471f378eab4c
> -  |  semi-colon: 471f378eab4c
> +  |/ Predecessors: 1:471f378eab4c
> +  |  semi-colon: 1:471f378eab4c
>    |  json: ["471f378eab4c5e25f6c77f785b27c936efb22874"]
>    |  map: 1:471f378eab4c5e25f6c77f785b27c936efb22874
>    | x  f137d23bb3e1
> @@ -206,13 +206,13 @@ Check templates
>  Predecessors template should show current revision as it is the
> working copy
>    $ hg tlog
>    o  f257fde29c7a
> -  |Predecessors: 471597cad322
> -  |semi-colon: 471597cad322
> +  |Predecessors: 1:471597cad322
> +  |semi-colon: 1:471597cad322
>    |json: ["471597cad322d1f659bb169751be9133dad92ef3"]
>    |map: 1:471597cad322d1f659bb169751be9133dad92ef3
>    o  337fec4d2edc
> -  |Predecessors: 471597cad322
> -  |semi-colon: 471597cad322
> +  |Predecessors: 1:471597cad322
> +  |semi-colon: 1:471597cad322
>    |json: ["471597cad322d1f659bb169751be9133dad92ef3"]
>    |map: 1:471597cad322d1f659bb169751be9133dad92ef3
>    | @  471597cad322
> @@ -235,13 +235,13 @@ Predecessors template should show both p
>  with --hidden
>    $ hg tlog --hidden
>    @  f257fde29c7a
> -  |Predecessors: 471597cad322
> -  |semi-colon: 471597cad322
> +  |Predecessors: 1:471597cad322
> +  |semi-colon: 1:471597cad322
>    |json: ["471597cad322d1f659bb169751be9133dad92ef3"]
>    |map: 1:471597cad322d1f659bb169751be9133dad92ef3
>    o  337fec4d2edc
> -  |Predecessors: 471597cad322
> -  |semi-colon: 471597cad322
> +  |

[PATCH] help: clarify ancestors() and descendants() include given set (issue5594)

2017-06-18 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1497793616 -32400
#  Sun Jun 18 22:46:56 2017 +0900
# Node ID 19d3c58cd7b80484f774e6dbd7300b8c0e8d5017
# Parent  07d5a503124caed05e1300a5208240764882c831
help: clarify ancestors() and descendants() include given set (issue5594)

Also unified "a changeset" to "changesets".

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -369,7 +369,8 @@ def _ancestors(repo, subset, x, followfi
 
 @predicate('ancestors(set)', safe=True)
 def ancestors(repo, subset, x):
-"""Changesets that are ancestors of a changeset in set.
+"""Changesets that are ancestors of changesets in set, including the
+given changesets themselves.
 """
 return _ancestors(repo, subset, x)
 
@@ -714,7 +715,8 @@ def _descendants(repo, subset, x, follow
 
 @predicate('descendants(set)', safe=True)
 def descendants(repo, subset, x):
-"""Changesets which are descendants of changesets in set.
+"""Changesets which are descendants of changesets in set, including the
+given changesets themselves.
 """
 return _descendants(repo, subset, x)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] check-concurrency: expose the feature as 'check-concurrent-push-mode'

2017-06-18 Thread Yuya Nishihara
On Sun, 18 Jun 2017 14:39:37 +0200, Pierre-Yves David wrote:
> On 06/18/2017 08:09 AM, Yuya Nishihara wrote:
> > On Sat, 17 Jun 2017 11:43:59 +0200, Pierre-Yves David wrote:
> >> # HG changeset patch
> >> # User Pierre-Yves David 
> >> # Date 1495923158 -7200
> >> #  Sun May 28 00:12:38 2017 +0200
> >> # Node ID 37ac2d3f1c505077f5684635df123a1fc31cf594
> >> # Parent  29558247b00eff8c95c7604032b59cfbab34010d
> >> # EXP-Topic pushrace
> >> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> >> #  hg pull 
> >> https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 
> >> 37ac2d3f1c50
> >> check-concurrency: expose the feature as 'check-concurrent-push-mode'
> >
> > Queued, thanks.
> 
> Thanks! this make me spot a typo in the commit summary line (extra 
> check-) in the config name. Should be:
> 
> check-concurrency: expose the feature as 'concurrent-push-mode'
> 
> Can you fix hg-committed?

Sure, fixed. New hash is a7851519ea02.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] check-concurrency: expose the feature as 'check-concurrent-push-mode'

2017-06-18 Thread Pierre-Yves David



On 06/18/2017 08:09 AM, Yuya Nishihara wrote:

On Sat, 17 Jun 2017 11:43:59 +0200, Pierre-Yves David wrote:

# HG changeset patch
# User Pierre-Yves David 
# Date 1495923158 -7200
#  Sun May 28 00:12:38 2017 +0200
# Node ID 37ac2d3f1c505077f5684635df123a1fc31cf594
# Parent  29558247b00eff8c95c7604032b59cfbab34010d
# EXP-Topic pushrace
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#  hg pull 
https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 37ac2d3f1c50
check-concurrency: expose the feature as 'check-concurrent-push-mode'


Queued, thanks.


Thanks! this make me spot a typo in the commit summary line (extra 
check-) in the config name. Should be:


check-concurrency: expose the feature as 'concurrent-push-mode'

Can you fix hg-committed?



+``concurrent-push-mode``
+Level of allowed race condition between two pushing client.


s/client/clients/

and inserted empty line here so the following lines are rendered as lists.


+- 'strict': push is abort if another client touched the repository
+  while the push was preparing. (default)
+- 'check-related': push is only aborted if it affects head that got also
+  affected while the push was preparing.
+
+This requires compatible client (version 4.3 and later). Old client will
+use 'strict'.


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


Re: [PATCH 2 of 6 stable] mq: create non-lossy patches, also with [diff] nobinary=True

2017-06-18 Thread Mads Kiilerich

On 06/18/2017 09:03 AM, Yuya Nishihara wrote:

The direction seems good, but can't we use patchmod.difffeatureopts() ?


Right, thanks. Didn't know about that one.

/Mads

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


Re: [PATCH 2 of 6 stable] mq: create non-lossy patches, also with [diff] nobinary=True

2017-06-18 Thread Yuya Nishihara
On Sat, 17 Jun 2017 23:06:18 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich 
> # Date 1497727704 -7200
> #  Sat Jun 17 21:28:24 2017 +0200
> # Branch stable
> # Node ID 2dae66ed58c0e2440a344ab8de645436a4c1f1a6
> # Parent  1968bc846c16d0cf59a573daf879bb842daaf7f1
> mq: create non-lossy patches, also with [diff] nobinary=True
> 
> Users with custom diff configuration most certainly didn't intend it to make 
> mq
> drop changes.
> 
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -503,7 +503,7 @@ class queue(object):
>  self.guardsdirty = False
>  self.activeguards = None
>  
> -def diffopts(self, opts=None, patchfn=None):
> +def diffopts(self, opts=None, patchfn=None, stable=False):
>  diffopts = patchmod.diffopts(self.ui, opts)
>  if self.gitmode == 'auto':
>  diffopts.upgrade = True
> @@ -516,6 +516,11 @@ class queue(object):
> ' got %s') % self.gitmode)
>  if patchfn:
>  diffopts = self.patchopts(diffopts, patchfn)
> +if stable:
> +# disable custom diff configuration - we need a stable format
> +diffopts.nobinary = False
> +# note: diff options showfunc and unified might influence diffs
> +# but don't do any harm

The direction seems good, but can't we use patchmod.difffeatureopts() ?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 5] changegroup: let callers pass in transaction to apply() (API)

2017-06-18 Thread Martin von Zweigbergk via Mercurial-devel
# HG changeset patch
# User Martin von Zweigbergk 
# Date 1497591998 25200
#  Thu Jun 15 22:46:38 2017 -0700
# Node ID d0254015a38d2727140432aa26efbe18ea8cab8b
# Parent  1a23893eb7f7ea55df8835bd6208f8427fa36d13
changegroup: let callers pass in transaction to apply() (API)

I think passing in the transaction makes it a little clearer and more
consistent with bundle2.

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1199,7 +1199,7 @@
 gen = exchange.readbundle(ui, f, backupfile)
 with repo.transaction('histedit.abort') as tr:
 if not isinstance(gen, bundle2.unbundle20):
-gen.apply(repo, 'histedit', 'bundle:' + backupfile)
+gen.apply(repo, tr, 'histedit', 'bundle:' + backupfile)
 else:
 bundle2.applybundle(repo, gen, tr,
 source='histedit',
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -127,7 +127,7 @@
 try:
 gen = exchange.readbundle(self.repo.ui, fp, self.fname, self.vfs)
 if not isinstance(gen, bundle2.unbundle20):
-gen.apply(self.repo, 'unshelve',
+gen.apply(self.repo, self.repo.currenttransaction(), 
'unshelve',
   'bundle:' + self.vfs.join(self.fname),
   targetphase=phases.secret)
 else:
diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -1473,12 +1473,7 @@
 This is a very early implementation that will massive rework before being
 inflicted to any end-user.
 """
-# Make sure we trigger a transaction creation
-#
-# The addchangegroup function will get a transaction object by itself, but
-# we need to make sure we trigger the creation of a transaction object used
-# for the whole processing scope.
-op.gettransaction()
+tr = op.gettransaction()
 unpackerversion = inpart.params.get('version', '01')
 # We should raise an appropriate exception here
 cg = changegroup.getunbundler(unpackerversion, inpart, None)
@@ -1496,7 +1491,8 @@
 op.repo.requirements.add('treemanifest')
 op.repo._applyopenerreqs()
 op.repo._writerequirements()
-ret = cg.apply(op.repo, 'bundle2', 'bundle2', expectedtotal=nbchangesets)
+ret = cg.apply(op.repo, tr, 'bundle2', 'bundle2',
+   expectedtotal=nbchangesets)
 op.records.add('changegroup', {'return': ret})
 if op.reply is not None:
 # This is definitely not the final form of this
@@ -1554,18 +1550,13 @@
 
 real_part = util.digestchecker(url.open(op.ui, raw_url), size, digests)
 
-# Make sure we trigger a transaction creation
-#
-# The addchangegroup function will get a transaction object by itself, but
-# we need to make sure we trigger the creation of a transaction object used
-# for the whole processing scope.
-op.gettransaction()
+tr = op.gettransaction()
 from . import exchange
 cg = exchange.readbundle(op.repo.ui, real_part, raw_url)
 if not isinstance(cg, changegroup.cg1unpacker):
 raise error.Abort(_('%s: not a bundle version 1.0') %
 util.hidepassword(raw_url))
-ret = cg.apply(op.repo, 'bundle2', 'bundle2')
+ret = cg.apply(op.repo, tr, 'bundle2', 'bundle2')
 op.records.add('changegroup', {'return': ret})
 if op.reply is not None:
 # This is definitely not the final form of this
diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py
--- a/mercurial/changegroup.py
+++ b/mercurial/changegroup.py
@@ -256,7 +256,7 @@
 repo.ui.progress(_('manifests'), None)
 self.callback = None
 
-def apply(self, repo, srctype, url, emptyok=False,
+def apply(self, repo, tr, srctype, url, emptyok=False,
   targetphase=phases.draft, expectedtotal=None):
 """Add the changegroup returned by source.read() to this repo.
 srctype is a string like 'push', 'pull', or 'unbundle'.  url is
@@ -279,12 +279,11 @@
 changesets = files = revisions = 0
 
 try:
-with repo.transaction("\n".join([srctype,
- util.hidepassword(url)])) as tr:
-# The transaction could have been created before and already
-# carries source information. In this case we use the top
-# level data. We overwrite the argument because we need to use
-# the top level value (if they exist) in this function.
+if True:
+# The transaction may already carry source information. In this
+# case we use the top level data. We overwrite the argument
+# because we need to use the top level value (if they exist)
+# in this 

[PATCH 3 of 5] repair: create transaction for bundle1 unbundling earlier

2017-06-18 Thread Martin von Zweigbergk via Mercurial-devel
# HG changeset patch
# User Martin von Zweigbergk 
# Date 1497593354 25200
#  Thu Jun 15 23:09:14 2017 -0700
# Node ID 1a23893eb7f7ea55df8835bd6208f8427fa36d13
# Parent  b6b0928d0128d2b424b40bf4c4d2a59acc20f9ac
repair: create transaction for bundle1 unbundling earlier

See earlier patch for motivation.

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -202,13 +202,15 @@
 if not repo.ui.verbose:
 # silence internal shuffling chatter
 repo.ui.pushbuffer()
+tmpbundleurl = 'bundle:' + vfs.join(tmpbundlefile)
 if isinstance(gen, bundle2.unbundle20):
 with repo.transaction('strip') as tr:
 bundle2.applybundle(repo, gen, tr, source='strip',
-url='bundle:' + 
vfs.join(tmpbundlefile))
+url=tmpbundleurl)
 else:
-gen.apply(repo, 'strip', 'bundle:' + vfs.join(tmpbundlefile),
-  True)
+txnname = "strip\n%s" % util.hidepassword(tmpbundleurl)
+with repo.lock(), repo.transaction(txnname):
+gen.apply(repo, 'strip', tmpbundleurl, True)
 if not repo.ui.verbose:
 repo.ui.popbuffer()
 f.close()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 5] unbundle: create transaction for bundle1 unbundling earlier

2017-06-18 Thread Martin von Zweigbergk via Mercurial-devel
# HG changeset patch
# User Martin von Zweigbergk 
# Date 1497590301 25200
#  Thu Jun 15 22:18:21 2017 -0700
# Node ID b6b0928d0128d2b424b40bf4c4d2a59acc20f9ac
# Parent  c0f6614c4c95281e7188879cd430ce0208680f2c
unbundle: create transaction for bundle1 unbundling earlier

See earlier patch for motivation.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5321,12 +5321,13 @@
 _('packed bundles cannot be applied with '
   '"hg unbundle"'),
 hint=_('use "hg debugapplystreamclonebundle"'))
+url = 'bundle:' + fname
 if isinstance(gen, bundle2.unbundle20):
 with repo.transaction('unbundle') as tr:
 try:
 op = bundle2.applybundle(repo, gen, tr,
  source='unbundle',
- url='bundle:' + fname)
+ url=url)
 except error.BundleUnknownFeatureError as exc:
 raise error.Abort(
 _('%s: unknown bundle feature, %s') % (fname, exc),
@@ -5337,7 +5338,9 @@
for r in op.records['changegroup']]
 modheads = changegroup.combineresults(changes)
 else:
-modheads = gen.apply(repo, 'unbundle', 'bundle:' + fname)
+txnname = 'unbundle\n%s' % util.hidepassword(url)
+with repo.transaction(txnname):
+modheads = gen.apply(repo, 'unbundle', url)
 
 return postincoming(ui, repo, modheads, opts.get(r'update'), None, None)
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2] shelve: rewrite "x in y.children()" as "y in x.parents()"

2017-06-18 Thread Yuya Nishihara
On Sat, 17 Jun 2017 23:13:54 -0700, Martin von Zweigbergk via Mercurial-devel 
wrote:
> # HG changeset patch
> # User Martin von Zweigbergk 
> # Date 1497766179 25200
> #  Sat Jun 17 23:09:39 2017 -0700
> # Node ID d8c3f47d162dafa180996d3dfd8b59f1e901735b
> # Parent  8e02829bec6135f4ec96bb68b54de2c3f56dbc09
> shelve: rewrite "x in y.children()" as "y in x.parents()"

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


[PATCH 2 of 2] rebase: rewrite "x in y.children()" as "y in x.parents()"

2017-06-18 Thread Martin von Zweigbergk via Mercurial-devel
# HG changeset patch
# User Martin von Zweigbergk 
# Date 1497766187 25200
#  Sat Jun 17 23:09:47 2017 -0700
# Node ID ae7a9461a249b94cf2eb48b1ab93d3ecc15ef17e
# Parent  d8c3f47d162dafa180996d3dfd8b59f1e901735b
rebase: rewrite "x in y.children()" as "y in x.parents()"

children() is slow

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1265,7 +1265,7 @@
 samebranch = root.branch() == wctx.branch()
 else:
 samebranch = root.branch() == dest.branch()
-if not collapse and samebranch and root in dest.children():
+if not collapse and samebranch and dest in root.parents():
 # mark the revision as done by setting its new revision
 # equal to its old (current) revisions
 state[root.rev()] = root.rev()
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 2] shelve: rewrite "x in y.children()" as "y in x.parents()"

2017-06-18 Thread Martin von Zweigbergk via Mercurial-devel
# HG changeset patch
# User Martin von Zweigbergk 
# Date 1497766179 25200
#  Sat Jun 17 23:09:39 2017 -0700
# Node ID d8c3f47d162dafa180996d3dfd8b59f1e901735b
# Parent  8e02829bec6135f4ec96bb68b54de2c3f56dbc09
shelve: rewrite "x in y.children()" as "y in x.parents()"

children() is slow

diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -681,7 +681,7 @@
 raise
 
 shelvectx = repo['tip']
-if not shelvectx in state.pendingctx.children():
+if state.pendingctx not in shelvectx.parents():
 # rebase was a no-op, so it produced no child commit
 shelvectx = state.pendingctx
 else:
@@ -758,7 +758,7 @@
 # refresh ctx after rebase completes
 shelvectx = repo['tip']
 
-if not shelvectx in tmpwctx.children():
+if tmpwctx not in shelvectx.parents():
 # rebase was a no-op, so it produced no child commit
 shelvectx = tmpwctx
 return shelvectx
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] check-concurrency: expose the feature as 'check-concurrent-push-mode'

2017-06-18 Thread Yuya Nishihara
On Sat, 17 Jun 2017 11:43:59 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David 
> # Date 1495923158 -7200
> #  Sun May 28 00:12:38 2017 +0200
> # Node ID 37ac2d3f1c505077f5684635df123a1fc31cf594
> # Parent  29558247b00eff8c95c7604032b59cfbab34010d
> # EXP-Topic pushrace
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #  hg pull 
> https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 37ac2d3f1c50
> check-concurrency: expose the feature as 'check-concurrent-push-mode'

Queued, thanks.

> +``concurrent-push-mode``
> +Level of allowed race condition between two pushing client.

s/client/clients/

and inserted empty line here so the following lines are rendered as lists.

> +- 'strict': push is abort if another client touched the repository
> +  while the push was preparing. (default)
> +- 'check-related': push is only aborted if it affects head that got also
> +  affected while the push was preparing.
> +
> +This requires compatible client (version 4.3 and later). Old client will
> +use 'strict'.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH] exchange: switch to usual way of testing for bundle2-ness

2017-06-18 Thread Yuya Nishihara
On Fri, 16 Jun 2017 22:58:04 -0700, Martin von Zweigbergk via Mercurial-devel 
wrote:
> # HG changeset patch
> # User Martin von Zweigbergk 
> # Date 1497679051 25200
> #  Fri Jun 16 22:57:31 2017 -0700
> # Node ID 0296f9489a0510d258ac9ec8ea0841e0a7c4c25c
> # Parent  9d472b219fb07e011c7a6255c5be47e6fc66229c
> exchange: switch to usual way of testing for bundle2-ness

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