D1024: hgweb: do not import uuid immediately to avoid its side effect

2017-10-11 Thread quark (Jun Wu)
quark updated this revision to Diff 2613.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1024?vs=2612=2613

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

AFFECTED FILES
  mercurial/hgweb/common.py
  tests/test-dispatch.t

CHANGE DETAILS

diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -60,3 +60,16 @@
   [255]
 
 #endif
+
+#if no-windows
+
+Current directory removed:
+
+  $ hg init $TESTTMP/repo1
+  $ cd $TESTTMP/repo1
+  $ rm -rf $TESTTMP/repo1
+  $ HGDEMANDIMPORT=disable hg version -q
+  abort: error getting current working directory: * (glob)
+  [255]
+
+#endif
diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -12,7 +12,6 @@
 import errno
 import mimetypes
 import os
-import uuid
 
 from .. import (
 encoding,
@@ -221,6 +220,23 @@
 First value is ``None`` if CSP isn't enabled. Second value is ``None``
 if CSP isn't enabled or if the CSP header doesn't need a nonce.
 """
+# Without demandimport, "import uuid" could have an immediate side-effect
+# running "ldconfig" on Linux trying to find libuuid.
+# With Python <= 2.7.12, that "ldconfig" is run via a shell and the shell
+# may pollute the terminal with:
+#
+#   shell-init: error retrieving current directory: getcwd: cannot access
+#   parent directories: No such file or directory
+#
+# Python >= 2.7.13 has fixed it by running "ldconfig" directly without a
+# shell (hg changeset a09ae70f3489).
+#
+# Moved "import uuid" from here so it's executed after we know we have
+# a sane cwd (i.e. after dispatch.py cwd check).
+#
+# We can move it back once we no longer need Python <= 2.7.12 support.
+import uuid
+
 # Don't allow untrusted CSP setting since it be disable protections
 # from a trusted/global source.
 csp = ui.config('web', 'csp', untrusted=False)



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


D1024: hgweb: do not import uuid immediately to avoid its side effect

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

REVISION SUMMARY
  With hgdemandimport disabled (chg's case), `import uuid` has an immediate
  side effect calling `ctypes.util.find_library` trying to locate the
  `libuuid` library.  This happens at `import` time before `dispatch.run()`.
  The call trace is like:
  
File "hg/hg", line 54, in 
  from mercurial import (
File "hg/mercurial/dispatch.py", line 24, in 
  from . import (
File "hg/mercurial/commands.py", line 23, in 
  from . import (
File "hg/mercurial/help.py", line 33, in 
  from .hgweb import (
File "hg/mercurial/hgweb/__init__.py", line 20, in 
  from . import (
File "hg/mercurial/hgweb/hgweb_mod.py", line 14, in 
  from .common import (
File "hg/mercurial/hgweb/common.py", line 15, in 
  import uuid
File "/usr/lib64/python2.7/uuid.py", line 404, in 
  lib = ctypes.CDLL(ctypes.util.find_library(libname))
  
  The problem is, `ctypes.util.find_library` will execute
  `sh -c '/sbin/ldconfig -p 2>/dev/null'` on Python <= 2.7.12. The output of
  `sh` may pollute the terminal:
  
shell-init: error retrieving current directory: getcwd: cannot access
parent directories: No such file or directory
  
  This patch moves `import uuid` so its side-effect can only happen after the
  cwd check in `dispatch._getlocal`. Therefore the terminal won't be
  polluted by importing `uuid`.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/hgweb/common.py
  tests/test-dispatch.t

CHANGE DETAILS

diff --git a/tests/test-dispatch.t b/tests/test-dispatch.t
--- a/tests/test-dispatch.t
+++ b/tests/test-dispatch.t
@@ -60,3 +60,16 @@
   [255]
 
 #endif
+
+#if no-windows
+
+Current directory removed:
+
+  $ hg init $TESTTMP/repo1
+  $ cd $TESTTMP/repo1
+  $ rm -rf $TESTTMP/repo1
+  $ HGDEMANDIMPORT=disable hg version -q
+  abort: error getting current working directory: No such file or directory
+  [255]
+
+#endif
diff --git a/mercurial/hgweb/common.py b/mercurial/hgweb/common.py
--- a/mercurial/hgweb/common.py
+++ b/mercurial/hgweb/common.py
@@ -12,7 +12,6 @@
 import errno
 import mimetypes
 import os
-import uuid
 
 from .. import (
 encoding,
@@ -221,6 +220,23 @@
 First value is ``None`` if CSP isn't enabled. Second value is ``None``
 if CSP isn't enabled or if the CSP header doesn't need a nonce.
 """
+# Without demandimport, "import uuid" could have an immediate side-effect
+# running "ldconfig" on Linux trying to find libuuid.
+# With Python <= 2.7.12, that "ldconfig" is run via a shell and the shell
+# may pollute the terminal with:
+#
+#   shell-init: error retrieving current directory: getcwd: cannot access
+#   parent directories: No such file or directory
+#
+# Python >= 2.7.13 has fixed it by running "ldconfig" directly without a
+# shell (hg changeset a09ae70f3489).
+#
+# Moved "import uuid" from here so it's executed after we know we have
+# a sane cwd (i.e. after dispatch.py cwd check).
+#
+# We can move it back once we no longer need Python <= 2.7.12 support.
+import uuid
+
 # Don't allow untrusted CSP setting since it be disable protections
 # from a trusted/global source.
 csp = ui.config('web', 'csp', untrusted=False)



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


D1018: selectors2: do not use platform.system()

2017-10-11 Thread quark (Jun Wu)
quark updated this revision to Diff 2609.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1018?vs=2605=2609

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

AFFECTED FILES
  mercurial/pycompat.py
  mercurial/selectors2.py

CHANGE DETAILS

diff --git a/mercurial/selectors2.py b/mercurial/selectors2.py
--- a/mercurial/selectors2.py
+++ b/mercurial/selectors2.py
@@ -29,12 +29,13 @@
 import collections
 import errno
 import math
-import platform
 import select
 import socket
 import sys
 import time
 
+from mercurial import pycompat
+
 namedtuple = collections.namedtuple
 Mapping = collections.Mapping
 
@@ -288,7 +289,7 @@
 __all__.append('SelectSelector')
 
 # Jython has a different implementation of .fileno() for socket objects.
-if platform.system() == 'Java':
+if pycompat.isjython:
 class _JythonSelectorMapping(object):
 """ This is an implementation of _SelectorMapping that is built
 for use specifically with Jython, which does not provide a hashable
@@ -727,7 +728,7 @@
 by eventlet, greenlet, and preserve proper behavior. """
 global _DEFAULT_SELECTOR
 if _DEFAULT_SELECTOR is None:
-if platform.system() == 'Java':  # Platform-specific: Jython
+if pycompat.isjython:
 _DEFAULT_SELECTOR = JythonSelectSelector
 elif _can_allocate('kqueue'):
 _DEFAULT_SELECTOR = KqueueSelector
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -17,6 +17,7 @@
 
 ispy3 = (sys.version_info[0] >= 3)
 ispypy = (r'__pypy__' in sys.builtin_module_names)
+isjython = sys.platform.startswith(r'java')
 
 if not ispy3:
 import cookielib



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


D1020: largefiles: do not use platform.system()

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

REVISION SUMMARY
  See the previous patch for the reason.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/lfutil.py

CHANGE DETAILS

diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py
--- a/hgext/largefiles/lfutil.py
+++ b/hgext/largefiles/lfutil.py
@@ -80,7 +80,7 @@
 encoding.environ.get('APPDATA'))
 if appdata:
 return os.path.join(appdata, longname)
-elif platform.system() == 'Darwin':
+elif pycompat.sysplatform == 'darwin':
 home = encoding.environ.get('HOME')
 if home:
 return os.path.join(home, 'Library', 'Caches', longname)



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


D1018: selectors2: do not use platform.system()

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

REVISION SUMMARY
  `platform.system()` may have a side effect spawning a shell executing
  `uname -p`, which may print a warning when the current directory is removed:
  
shell-init: error retrieving current directory: getcwd: cannot access 
parent directories: No such file or directory
  
  This patch changes selectors2 to test the `sys.platform` string, which is a
  much safer way to detect Jython.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/pycompat.py
  mercurial/selectors2.py

CHANGE DETAILS

diff --git a/mercurial/selectors2.py b/mercurial/selectors2.py
--- a/mercurial/selectors2.py
+++ b/mercurial/selectors2.py
@@ -29,12 +29,13 @@
 import collections
 import errno
 import math
-import platform
 import select
 import socket
 import sys
 import time
 
+from mercurial import pycompat
+
 namedtuple = collections.namedtuple
 Mapping = collections.Mapping
 
@@ -64,7 +65,6 @@
 
 SelectorKey = namedtuple('SelectorKey', ['fileobj', 'fd', 'events', 'data'])
 
-
 class _SelectorMapping(Mapping):
 """ Mapping of file objects to selector keys """
 
@@ -288,7 +288,7 @@
 __all__.append('SelectSelector')
 
 # Jython has a different implementation of .fileno() for socket objects.
-if platform.system() == 'Java':
+if pycompat.isjython:
 class _JythonSelectorMapping(object):
 """ This is an implementation of _SelectorMapping that is built
 for use specifically with Jython, which does not provide a hashable
@@ -727,7 +727,7 @@
 by eventlet, greenlet, and preserve proper behavior. """
 global _DEFAULT_SELECTOR
 if _DEFAULT_SELECTOR is None:
-if platform.system() == 'Java':  # Platform-specific: Jython
+if pycompat.isjython:
 _DEFAULT_SELECTOR = JythonSelectSelector
 elif _can_allocate('kqueue'):
 _DEFAULT_SELECTOR = KqueueSelector
diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py
--- a/mercurial/pycompat.py
+++ b/mercurial/pycompat.py
@@ -17,6 +17,7 @@
 
 ispy3 = (sys.version_info[0] >= 3)
 ispypy = (r'__pypy__' in sys.builtin_module_names)
+isjython = sys.platform.startswith(r'java')
 
 if not ispy3:
 import cookielib



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


D1019: logtoprocess: do not use platform.system()

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

REVISION SUMMARY
  See the previous patch for the reason.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/logtoprocess.py

CHANGE DETAILS

diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py
--- a/hgext/logtoprocess.py
+++ b/hgext/logtoprocess.py
@@ -40,16 +40,19 @@
 import subprocess
 import sys
 
-from mercurial import encoding
+from mercurial import (
+encoding,
+pycompat,
+)
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' 
for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
 # leave the attribute unspecified.
 testedwith = 'ships-with-hg-core'
 
 def uisetup(ui):
-if platform.system() == 'Windows':
+if pycompat.osname == 'nt':
 # no fork on Windows, but we can create a detached process
 # 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863.aspx
 # No stdlib constant exists for this value



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


D1021: check-code: forbid platform.system()

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

REVISION SUMMARY
  See the previous patches for the reason.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -362,6 +362,7 @@
 (r'\.next\(\)', "don't use .next(), use next(...)"),
 (r'([a-z]*).revision\(\1\.node\(',
  "don't convert rev to node before passing to revision(nodeorrev)"),
+(r'platform\.system()', "don't use platform.system(), use pycompat"),
 
 # rules depending on implementation of repquote()
 (r' x+[xpqo%APM][\'"]\n\s+[\'"]x',



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


Re: [PATCH 4 of 4] build: "make deb" failed when the base path contained spaces

2017-10-11 Thread Augie Fackler
On Wed, Oct 11, 2017 at 10:46:20PM +0200, a.mux--- via Mercurial-devel wrote:
> # HG changeset patch
> # User muxator 
> # Date 1507679220 -7200
> #  Wed Oct 11 01:47:00 2017 +0200
> # Node ID 82a268793bfb8c4db32eae6ee009b0d1fd334d43
> # Parent  0dc5f9e9fd59f0c2289ca3133a0e54d49b7882d7
> build: "make deb" failed when the base path contained spaces

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


Re: Fix quoting in build scripts for debian and Docker (first message lost)

2017-10-11 Thread Augie Fackler
On Wed, Oct 11, 2017 at 10:59:26PM +0200, muxator via Mercurial-devel wrote:
> Hi,
>
> I have sent a small patch series on fixing the quoting in the build scripts,
> but somehow it triggered a "filter rule match" and was discarded.

O of N messages are hard-rejected because they always contain
information that should instead be in a commit message, rather than in
something that'll only ever live on the list. See ContributingPatches
in the wiki for more.

> Since the first commit contains a briefer version, I will not repost it.
>
> This is just a note on the strictness of the antispam filter :)
>
> Thanks
>
> ___
> 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


D1016: repoview: remove incorrect documentation of the function

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  In repoview.py, computeunserved() and computemutable() functions had the same
  documentation. The documentation of computemutable() is wrong. I was unable to
  write documentation for the function but it's better to not having the
  documentation than having it wrong.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/repoview.py

CHANGE DETAILS

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -99,9 +99,6 @@
 return hiddens
 
 def computemutable(repo):
-"""compute the set of revision that should be filtered when used a server
-
-Secret and hidden changeset should not pretend to be here."""
 assert not repo.changelog.filteredrevs
 # fast check to avoid revset call on huge repo
 if any(repo._phasecache.phaseroots[1:]):



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


mercurial@34566: 37 new changesets

2017-10-11 Thread Mercurial Commits
37 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/ed5acd3fd7e1
changeset:   34530:ed5acd3fd7e1
user:Kostia Balytskyi 
date:Mon Oct 09 02:30:23 2017 -0700
summary: windows: add an experimental option for long paths support

https://www.mercurial-scm.org/repo/hg/rev/50788d1ae6cc
changeset:   34531:50788d1ae6cc
user:Yuya Nishihara 
date:Sat Oct 07 22:07:10 2017 +0900
summary: chg: just forward --time to command server

https://www.mercurial-scm.org/repo/hg/rev/b09b3eaf9c96
changeset:   34532:b09b3eaf9c96
user:Yuya Nishihara 
date:Mon Oct 02 06:52:10 2017 +0100
summary: py3: work around the scope of exception variable in dispatch.run()

https://www.mercurial-scm.org/repo/hg/rev/163fa0aea71e
changeset:   34533:163fa0aea71e
user:Yuya Nishihara 
date:Mon Oct 02 07:18:24 2017 +0100
summary: dispatch: move initialization of sys.std* files

https://www.mercurial-scm.org/repo/hg/rev/b3073e175c17
changeset:   34534:b3073e175c17
user:Yuya Nishihara 
date:Sat Sep 09 19:13:25 2017 +0900
summary: templater: wrap get/min/max result so map operation can apply to 
element

https://www.mercurial-scm.org/repo/hg/rev/78590585c0db
changeset:   34535:78590585c0db
user:Yuya Nishihara 
date:Sat Sep 09 19:32:56 2017 +0900
summary: templater: add dot operator to easily access a sub item

https://www.mercurial-scm.org/repo/hg/rev/4c1cfe54c08d
changeset:   34536:4c1cfe54c08d
user:Yuya Nishihara 
date:Mon Sep 18 23:07:17 2017 +0900
summary: templater: extend dot operator as a short for get(dict, key)

https://www.mercurial-scm.org/repo/hg/rev/8c3dd5e462cc
changeset:   34537:8c3dd5e462cc
user:Yuya Nishihara 
date:Mon Sep 18 23:49:05 2017 +0900
summary: templatekw: fix scope of peerpath url bound to generator

https://www.mercurial-scm.org/repo/hg/rev/ac38e889b33a
changeset:   34538:ac38e889b33a
user:Yuya Nishihara 
date:Mon Sep 18 23:31:01 2017 +0900
summary: templatekw: make experimental {peerpaths} return a single-level 
dict (BC)

https://www.mercurial-scm.org/repo/hg/rev/f30e59703d98
changeset:   34539:f30e59703d98
user:Yuya Nishihara 
date:Mon Sep 18 23:53:05 2017 +0900
summary: templatekw: rename peerpaths to peerurls per naming convention (BC)

https://www.mercurial-scm.org/repo/hg/rev/1c7c4445686f
changeset:   34540:1c7c4445686f
user:Yuya Nishihara 
date:Sat Sep 30 08:50:24 2017 +0100
summary: templatekw: get rid of temporary dicts from shownamespaces()

https://www.mercurial-scm.org/repo/hg/rev/0a0a72c043ac
changeset:   34541:0a0a72c043ac
user:Yuya Nishihara 
date:Sat Sep 30 08:57:50 2017 +0100
summary: templatekw: allow accessing to nested namespace item by its 
template name

https://www.mercurial-scm.org/repo/hg/rev/153e4e05e9b3
changeset:   34542:153e4e05e9b3
user:Yuya Nishihara 
date:Sun Oct 01 12:21:50 2017 +0100
summary: extdata: show debug message if external command exits with 
non-zero status

https://www.mercurial-scm.org/repo/hg/rev/6fad8059a970
changeset:   34543:6fad8059a970
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: scmutil: handle conflicting files and dirs in origbackuppath

https://www.mercurial-scm.org/repo/hg/rev/34c8080d12ac
changeset:   34544:34c8080d12ac
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: tests: add a test demonstrating basic path conflict failures

https://www.mercurial-scm.org/repo/hg/rev/1913162854f2
changeset:   34545:1913162854f2
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: merge: add pathconflict merge state

https://www.mercurial-scm.org/repo/hg/rev/e4cf957bf7ce
changeset:   34546:e4cf957bf7ce
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: commands: update the resolve command to handle path conflicts

https://www.mercurial-scm.org/repo/hg/rev/81aebcc73beb
changeset:   34547:81aebcc73beb
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: merge: add merge action 'p' to record path conflicts during update

https://www.mercurial-scm.org/repo/hg/rev/b4955650eb57
changeset:   34548:b4955650eb57
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: merge: add merge action 'pr' to rename files during update

https://www.mercurial-scm.org/repo/hg/rev/a991e1d6bc82
changeset:   34549:a991e1d6bc82
user:Mark Thomas 
date:Mon Oct 02 14:05:30 2017 -0700
summary: merge: backup 

Fix quoting in build scripts for debian and Docker (first message lost)

2017-10-11 Thread muxator via Mercurial-devel

Hi,

I have sent a small patch series on fixing the quoting in the build 
scripts, but somehow it triggered a "filter rule match" and was discarded.


Since the first commit contains a briefer version, I will not repost it.

This is just a note on the strictness of the antispam filter :)

Thanks

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


[PATCH 4 of 4] build: "make deb" failed when the base path contained spaces

2017-10-11 Thread a.mux--- via Mercurial-devel
# HG changeset patch
# User muxator 
# Date 1507679220 -7200
#  Wed Oct 11 01:47:00 2017 +0200
# Node ID 82a268793bfb8c4db32eae6ee009b0d1fd334d43
# Parent  0dc5f9e9fd59f0c2289ca3133a0e54d49b7882d7
build: "make deb" failed when the base path contained spaces

With these changes, all the commands triggered by "make deb" use proper quoting
and succeed even when invoked from a directory containing spaces.

diff --git a/contrib/builddeb b/contrib/builddeb
--- a/contrib/builddeb
+++ b/contrib/builddeb
@@ -73,7 +73,7 @@
 exit 1
 fi
 
-cp -r $PWD/contrib/debian debian
+cp -r "$PWD"/contrib/debian debian
 
 sed -i.tmp "s/__VERSION__/$debver/" $changelog
 sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
diff --git a/contrib/debian/rules b/contrib/debian/rules
--- a/contrib/debian/rules
+++ b/contrib/debian/rules
@@ -15,30 +15,30 @@
find debian/mercurial/usr/share -type d -empty -delete
 
 override_dh_install:
-   python$(PYVERS) setup.py install --root $(CURDIR)/debian/mercurial 
--install-layout=deb
+   python$(PYVERS) setup.py install --root "$(CURDIR)"/debian/mercurial 
--install-layout=deb
# chg
make -C contrib/chg \
-   DESTDIR=$(CURDIR)/debian/mercurial \
+   DESTDIR="$(CURDIR)"/debian/mercurial \
PREFIX=/usr \
clean install
# remove arch-independent python stuff
-   find $(CURDIR)/debian/mercurial/usr/lib \
+   find "$(CURDIR)"/debian/mercurial/usr/lib \
! -name '*.so' ! -type d -delete , \
-type d -empty -delete
-   python$(PYVERS) setup.py install --root 
$(CURDIR)/debian/mercurial-common --install-layout=deb
-   make install-doc PREFIX=$(CURDIR)/debian/mercurial-common/usr
+   python$(PYVERS) setup.py install --root 
"$(CURDIR)/debian/mercurial-common" --install-layout=deb
+   make install-doc PREFIX="$(CURDIR)"/debian/mercurial-common/usr
# remove arch-dependent python stuff
-   find $(CURDIR)/debian/mercurial-common/usr/lib \
+   find "$(CURDIR)"/debian/mercurial-common/usr/lib \
-name '*.so' ! -type d -delete , \
-type d -empty -delete
-   cp contrib/hg-ssh $(CURDIR)/debian/mercurial-common/usr/bin
-   mkdir -p $(CURDIR)/debian/mercurial-common/usr/share/mercurial
-   cp contrib/hgk $(CURDIR)/debian/mercurial-common/usr/share/mercurial
-   mkdir -p $(CURDIR)/debian/mercurial-common/etc/mercurial/hgrc.d/
-   cp contrib/debian/*.rc 
$(CURDIR)/debian/mercurial-common/etc/mercurial/hgrc.d/
+   cp contrib/hg-ssh "$(CURDIR)"/debian/mercurial-common/usr/bin
+   mkdir -p "$(CURDIR)"/debian/mercurial-common/usr/share/mercurial
+   cp contrib/hgk "$(CURDIR)"/debian/mercurial-common/usr/share/mercurial
+   mkdir -p "$(CURDIR)"/debian/mercurial-common/etc/mercurial/hgrc.d/
+   cp contrib/debian/*.rc 
"$(CURDIR)"/debian/mercurial-common/etc/mercurial/hgrc.d/
# completions
-   mkdir -p 
$(CURDIR)/debian/mercurial-common/usr/share/bash-completion/completions
-   cp contrib/bash_completion 
$(CURDIR)/debian/mercurial-common/usr/share/bash-completion/completions/hg
-   mkdir -p 
$(CURDIR)/debian/mercurial-common/usr/share/zsh/vendor-completions
-   cp contrib/zsh_completion 
$(CURDIR)/debian/mercurial-common/usr/share/zsh/vendor-completions/_hg
-   rm $(CURDIR)/debian/mercurial-common/usr/bin/hg
+   mkdir -p 
"$(CURDIR)"/debian/mercurial-common/usr/share/bash-completion/completions
+   cp contrib/bash_completion 
"$(CURDIR)"/debian/mercurial-common/usr/share/bash-completion/completions/hg
+   mkdir -p 
"$(CURDIR)"/debian/mercurial-common/usr/share/zsh/vendor-completions
+   cp contrib/zsh_completion 
"$(CURDIR)"/debian/mercurial-common/usr/share/zsh/vendor-completions/_hg
+   rm "$(CURDIR)"/debian/mercurial-common/usr/bin/hg
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 4] build: the initial version detection by make deb/rpm could fail due to missing quoting

2017-10-11 Thread a.mux--- via Mercurial-devel
# HG changeset patch
# User muxator 
# Date 1507678663 -7200
#  Wed Oct 11 01:37:43 2017 +0200
# Node ID fc144c0ec36089c4b60bb3287adc787a1cfcae78
# Parent  f5b679cb5f18ed7f29c42d7a66a3b3a172a11286
build: the initial version detection by make deb/rpm could fail due to missing 
quoting

diff --git a/contrib/packagelib.sh b/contrib/packagelib.sh
--- a/contrib/packagelib.sh
+++ b/contrib/packagelib.sh
@@ -12,9 +12,9 @@
 make local || make local PURE=--pure
 HG="$PWD/hg"
 
-$HG version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; }
+"$HG" version > /dev/null || { echo 'abort: hg version failed!'; exit 1 ; }
 
-hgversion=`LANGUAGE=C $HG version | sed -ne 's/.*(version \(.*\))$/\1/p'`
+hgversion=`LANGUAGE=C "$HG" version | sed -ne 's/.*(version \(.*\))$/\1/p'`
 
 if echo $hgversion | grep + > /dev/null 2>&1 ; then
 tmp=`echo $hgversion | cut -d+ -f 2`
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 4] build: make install in "/doc" failed if the destination dir contained spaces

2017-10-11 Thread a.mux--- via Mercurial-devel
# HG changeset patch
# User muxator 
# Date 1507677588 -7200
#  Wed Oct 11 01:19:48 2017 +0200
# Node ID f5b679cb5f18ed7f29c42d7a66a3b3a172a11286
# Parent  4a6a337f9c682bdf1659295f871dc43ff33677ca
build: make install in "/doc" failed if the destination dir contained spaces

This and the following commits try to add the necessary quoting in the build
scripts to make the process more robust.

The target for now is rendering "make deb" successful even when the base
directory contains spaces (eg. "/opt/mercu rial").
The build process should succeed without scattering files in spurious
directories (eg.: "/opt/mercu/usr/bin/hg").

diff --git a/doc/Makefile b/doc/Makefile
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -18,7 +18,7 @@
 html: $(HTML)
 
 common.txt $(SOURCES) $(SOURCES:%.txt=%.gendoc.txt): $(GENDOC)
-   ${PYTHON} gendoc.py $(basename $@) > $@.tmp
+   ${PYTHON} gendoc.py "$(basename $@)" > $@.tmp
mv $@.tmp $@
 
 %: %.txt %.gendoc.txt common.txt
@@ -39,8 +39,8 @@
 install: man
for i in $(MAN) ; do \
  subdir=`echo $$i | sed -n 's/^.*\.\([0-9]\)$$/man\1/p'` ; \
- mkdir -p $(DESTDIR)$(MANDIR)/$$subdir ; \
- $(INSTALL) $$i $(DESTDIR)$(MANDIR)/$$subdir ; \
+ mkdir -p "$(DESTDIR)$(MANDIR)"/$$subdir ; \
+ $(INSTALL) $$i "$(DESTDIR)$(MANDIR)"/$$subdir ; \
done
 
 clean:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH V4] strip: take branch into account when selecting update target (issue5540)

2017-10-11 Thread Augie Fackler
On Wed, Oct 11, 2017 at 07:12:20PM +0200, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle 
> # Date 1507212785 -7200
> #  Thu Oct 05 16:13:05 2017 +0200
> # Node ID a9047aa04485e29fbad8c7af5cc83d64e7b3df2c
> # Parent  05c2a9f37a1dde8df024876cca0f76108c8e6f42
> # EXP-Topic issue-5540
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> a9047aa04485
> strip: take branch into account when selecting update target (issue5540)

Looks like Yuya's comments are addressed, queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 3 of 3] transaction-summary: display the range of new revisions upon pull/unbundle

2017-10-11 Thread Augie Fackler
On Wed, Oct 04, 2017 at 06:52:45PM +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde 
> # Date 1507135871 -7200
> #  Wed Oct 04 18:51:11 2017 +0200
> # Node ID ae007b70b03657bbb92f4b73e6e0c807669dae10
> # Parent  21115bb034eb168806d485b3b28c3112
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #  hg pull http://hg.logilab.org/users/dlaxalde/hg -r ae007b70b036
> # EXP-Topic pull-info-transaction
> transaction-summary: display the range of new revisions upon pull/unbundle

I've taken the first two patches, but this one at least merits (BC)
flagging I think. I like the feature though, so please mail a v2 of
this patch for further discussion.

>
> Upon pull or unbundle, we display a message with the range of new revisions
> fetched. This revision range could readily be used after a pull to look out
> what's new with 'hg log'. The algorithm takes care of filtering "obsolete"
> revisions that might be present in transaction's "changes" but should not be
> displayed to the end user.

Does this series open the door to informing the user how many changes
moved from draft to public?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D738: directaccess: add support to export and tests to demonstrate things

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 2598.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D738?vs=1906=2598

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-directaccess.t

CHANGE DETAILS

diff --git a/tests/test-directaccess.t b/tests/test-directaccess.t
new file mode 100644
--- /dev/null
+++ b/tests/test-directaccess.t
@@ -0,0 +1,92 @@
+Tests for access level on hidden commits by various commands on based of their
+type.
+
+Setting the required config to start this
+
+  $ cat >> $HGRCPATH < [experimental]
+  > evolution=createmarkers, allowunstable
+  > directaccess=True
+  > [extensions]
+  > uncommit =
+  > amend =
+  > rebase =
+  > EOF
+
+  $ hg init repo
+  $ cd repo
+  $ for ch in {a..h}; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; 
done
+
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  @  7:ec2426147f0e39dbc9cef599b066be6035ce691d Added h
+  |
+  o  6:87d6d66763085b629e6d7ed56778c79827273022 Added g
+  |
+  o  5:825660c69f0cd8d9542c1fea6e5d444c666f063b Added f
+  |
+  o  4:aa98ab95a9284d289c73a270d70c37914795a842 Added e
+  |
+  o  3:62615734edd52f06b6fb9c2beb429e4fe30d57b8 Added d
+  |
+  o  2:28ad74487de9599d00d81085be739c61fc340652 Added c
+  |
+  o  1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
+  |
+  o  0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
+  
+  $ echo "bar" >> h
+  $ hg amend
+
+  $ hg log -G -T '{rev}:{node} {desc}' --hidden
+  @  8:c9fa1a715c1b7661c0fafb362a9f30bd75878d7d Added h
+  |
+  | x  7:ec2426147f0e39dbc9cef599b066be6035ce691d Added h
+  |/
+  o  6:87d6d66763085b629e6d7ed56778c79827273022 Added g
+  |
+  o  5:825660c69f0cd8d9542c1fea6e5d444c666f063b Added f
+  |
+  o  4:aa98ab95a9284d289c73a270d70c37914795a842 Added e
+  |
+  o  3:62615734edd52f06b6fb9c2beb429e4fe30d57b8 Added d
+  |
+  o  2:28ad74487de9599d00d81085be739c61fc340652 Added c
+  |
+  o  1:29becc82797a4bc11ec8880b58eaecd2ab3e7760 Added b
+  |
+  o  0:18d04c59bb5d2d4090ad9a5b59bd6274adb63add Added a
+  
+Testing read only commands on the hidden revision
+=
+
+Testing with rev number
+
+  $ hg exp 7
+  abort: hidden revision '7'!
+  (use --hidden to access hidden revisions)
+  [255]
+
+Testing with hash
+
+  $ hg exp ec2426
+  # HG changeset patch
+  # User test
+  # Date 0 0
+  #  Thu Jan 01 00:00:00 1970 +
+  # Node ID ec2426147f0e39dbc9cef599b066be6035ce691d
+  # Parent  87d6d66763085b629e6d7ed56778c79827273022
+  Added h
+  
+  diff -r 87d6d6676308 -r ec2426147f0e h
+  --- /dev/nullThu Jan 01 00:00:00 1970 +
+  +++ b/h  Thu Jan 01 00:00:00 1970 +
+  @@ -0,0 +1,1 @@
+  +foo
+
+Make sure things with cmdtype undefined dont work with hidden commits
+=
+
+  $ hg rebase -s ec2426 -d .
+  abort: hidden revision 'ec2426'!
+  (use --hidden to access hidden revisions)
+  [255]
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -61,6 +61,8 @@
 
 release = lockmod.release
 
+readonly = registrar.command.readonly
+
 table = {}
 table.update(debugcommandsmod.command._table)
 
@@ -1863,7 +1865,8 @@
 ('', 'switch-parent', None, _('diff against the second parent')),
 ('r', 'rev', [], _('revisions to export'), _('REV')),
 ] + diffopts,
-_('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'))
+_('[OPTION]... [-o OUTFILESPEC] [-r] [REV]...'),
+cmdtype=readonly)
 def export(ui, repo, *changesets, **opts):
 """dump the header and diffs for one or more changesets
 



To: pulkit, #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


D1014: revset: update repo._pinnedrevs with hidden commits from the tree

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds functionality to update the pinnedrevs set with the hidden
  commits whose hashes are passed if the command allow accessing them and 
showing
  warning depending on repo.filtername which is set by the type of command.
  
  The logic to check whether a symbol is hash and logic related to showing
  warning to user is imported from directacess extension from fb-hgext.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/revset.py

CHANGE DETAILS

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2202,6 +2202,10 @@
 tree = revsetlang.analyze(tree)
 tree = revsetlang.optimize(tree)
 posttreebuilthook(tree, repo)
+# add commits to pinned revs if hashes of hidden revs is passed and
+# accessing hidden commmits is allowed
+if repo and repo.filtername in ['visible-hidden', 'visible-warnhidden']:
+_updatepinnedrevs(tree, repo)
 return makematcher(tree)
 
 def makematcher(tree):
@@ -2230,3 +2234,66 @@
 
 # tell hggettext to extract docstrings from these functions:
 i18nfunctions = symbols.values()
+
+hashre = util.re.compile('[0-9a-fA-F]{1,40}')
+_listtuple = ('symbol', '_list')
+
+def _ishashsymbol(symbol, maxrev):
+""" returns true if symbol looks like a hash """
+
+try:
+n = int(symbol)
+if n <= maxrev:
+# It's a rev number
+return False
+except ValueError:
+pass
+return hashre.match(symbol)
+
+def gethashsymbols(tree, maxrev):
+""" returns the list of symbols of the tree that look like hashes
+for example for the revset 3::abe3ff it will return ('abe3ff') """
+
+if not tree:
+return []
+
+results = []
+if len(tree) in (2, 3) and tree[0] == "symbol":
+results.append(tree[1])
+elif tree[0] == "func" and tree[1] == _listtuple:
+# the optimiser will group sequence of hash request
+results += tree[2][1].split('\0')
+elif len(tree) >= 2:
+for subtree in tree[1:]:
+results += gethashsymbols(subtree, maxrev)
+# return directly, we don't need to filter symbols again
+return results
+return [s for s in results if _ishashsymbol(s, maxrev)]
+
+def _updatepinnedrevs(tree, repo):
+""" extracts the symbols that looks like hashes and add them to
+repo._pinnedrevs for accessing hidden hashes
+"""
+
+hiddenset = set()
+cl = repo.unfiltered().changelog
+symbols = gethashsymbols(tree, len(cl))
+for revnode in symbols:
+try:
+revnode = cl._partialmatch(revnode)
+except error.LookupError:
+revnode = None
+if revnode is not None:
+rev = cl.rev(revnode)
+if rev not in repo.changelog:
+hiddenset.add(rev)
+
+if hiddenset:
+if repo.filtername == 'visible-warnhidden':
+repo.ui.warn(_("warning: accessing hidden changesets %s "
+   "for write operation\n") %
+ (",".join([str(repo.unfiltered()[l])
+  for l in hiddenset])))
+
+repo._pinnedrevs.update(hiddenset)
+repo.invalidatevolatilesets()



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


D1013: dispatch: filter the repository depending on func.cmdtype

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds support for filtering the repository on the basis of
  func.cmdtype. After this patch, repo.filtername will be used to decide what
  level of access the running command can has on hidden commits.
  
  All this logic is behind a config flag `experimental.directacess` which 
defaults
  to False.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/configitems.py
  mercurial/dispatch.py

CHANGE DETAILS

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -42,6 +42,8 @@
 )
 
 unrecoverablewrite = registrar.command.unrecoverablewrite
+recoverablewrite = registrar.command.recoverablewrite
+readonly = registrar.command.readonly
 
 class request(object):
 def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
@@ -926,6 +928,14 @@
 ui = repo.ui
 if options['hidden']:
 repo = repo.unfiltered()
+
+# Accessing hidden commits based on func.cmdtype
+if lui.configbool('experimental', 'directaccess'):
+if func.cmdtype == readonly:
+repo = repo.filtered('visible-hidden')
+elif func.cmdtype == recoverablewrite:
+repo = repo.filtered('visible-warnhidden')
+
 args.insert(0, repo)
 elif rpath:
 ui.warn(_("warning: --repository ignored\n"))
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -278,6 +278,9 @@
 coreconfigitem('experimental', 'crecordtest',
 default=None,
 )
+coreconfigitem('experimental', 'directaccess',
+default=False,
+)
 coreconfigitem('experimental', 'editortmpinhg',
 default=False,
 )



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


D736: registrar: add support for storing the type of command in func object

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 2595.
pulkit edited the summary of this revision.
pulkit retitled this revision from "directaccess: add support for storing the 
type of command in func object" to "registrar: add support for storing the type 
of command in func object".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D736?vs=1904=2595

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

AFFECTED FILES
  mercurial/dispatch.py
  mercurial/registrar.py

CHANGE DETAILS

diff --git a/mercurial/registrar.py b/mercurial/registrar.py
--- a/mercurial/registrar.py
+++ b/mercurial/registrar.py
@@ -7,6 +7,7 @@
 
 from __future__ import absolute_import
 
+from .i18n import _
 from . import (
 configitems,
 error,
@@ -131,13 +132,35 @@
 command line arguments. If True, arguments will be examined for potential
 repository locations. See ``findrepo()``. If a repository is found, it
 will be used.
+
+There are three constants in the class which tells what type of the command
+that is. That information will be helpful at various places. It will be 
also
+be used to decide what level of access the command has on hidden commits.
+The constants are:
+
+unrecoverablewrite is for those write commands which can't be recovered 
like
+push.
+recoverablewrite is for write commands which can be recovered like commit.
+readonly is for commands which are read only.
 """
 
+unrecoverablewrite = "unrecoverable"
+recoverablewrite = "recoverable"
+readonly = "readonly"
+
 def _doregister(self, func, name, options=(), synopsis=None,
-norepo=False, optionalrepo=False, inferrepo=False):
+norepo=False, optionalrepo=False, inferrepo=False,
+cmdtype=unrecoverablewrite):
+
+possiblecmdtypes = set([self.unrecoverablewrite, self.recoverablewrite,
+self.readonly])
+if cmdtype not in possiblecmdtypes:
+raise error.ProgrammingError(_("unknown cmdtype value '%s' for "
+"'%s' command") % (cmdtype, name))
 func.norepo = norepo
 func.optionalrepo = optionalrepo
 func.inferrepo = inferrepo
+func.cmdtype = cmdtype
 if synopsis:
 self._table[name] = func, list(options), synopsis
 else:
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -35,11 +35,14 @@
 hook,
 profiling,
 pycompat,
+registrar,
 scmutil,
 ui as uimod,
 util,
 )
 
+unrecoverablewrite = registrar.command.unrecoverablewrite
+
 class request(object):
 def __init__(self, args, ui=None, repo=None, fin=None, fout=None,
  ferr=None, prereposetups=None):
@@ -495,7 +498,7 @@
 return aliasargs(self.fn, args)
 
 def __getattr__(self, name):
-adefaults = {r'norepo': True,
+adefaults = {r'norepo': True, r'cmdtype': unrecoverablewrite,
  r'optionalrepo': False, r'inferrepo': False}
 if name not in adefaults:
 raise AttributeError(name)



To: pulkit, #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


D987: copies: add a config to limit the number of candidates to check in heuristics

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  In https://phab.mercurial-scm.org/D987#16792, @yuja wrote:
  
  > Oops, the default value (5 vs 100) wasn't my point. I doubt if taking the 
first n
  >  candidates would be a good "heuristic."
  
  
  Oh, sorry. I changed it to 100 as I think that will be a good maximum and a 
good default rather than 5.
  
  > If I understand correctly, it may miss the copy information only if the 
file is
  >  out of the n-candidates list. I think it would be hard for users to 
understand
  >  why the copy wasn't detected. That's my concern.
  
  I have added a debug message saying more candidates than the limit which can 
give user a hint in this case. Shall I make that a ui.status() thing?
  
  > (marked as "request changes" to flag discussion is ongoing. no new version 
is requested.)

REPOSITORY
  rHG Mercurial

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

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


D1003: bdiff: sort includes using clang-format

2017-10-11 Thread pulkit (Pulkit Goyal)
pulkit accepted this revision.
pulkit added a comment.


  Should we include some magic string in all these formatting related revisions 
so that we can have an easy revset to skip them in case of `hg annotate`?

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 13 of 14] configitems: register the 'gpg.key' config

2017-10-11 Thread Augie Fackler
On Fri, Oct 06, 2017 at 11:22:29AM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1498786954 -7200
> #  Fri Jun 30 03:42:34 2017 +0200
> # Node ID d54526c257afa33b7624f0b94c16822bcbd08df1
> # Parent  b0c42fec8dc28dec5408c0ec506359afc64e4915
> # EXP-Topic config.register.gpg
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> d54526c257af
> configitems: register the 'gpg.key' config

Boris gave me a stack of 35 patches like this on IRC, which I think included 
these. In any case, these appear to be queued. Thanks!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D960: bundle2: immediate exit for ctrl+c (issue5692)

2017-10-11 Thread durham (Durham Goode)
durham added inline comments.

INLINE COMMENTS

> yuja wrote in bundle2.py:380
> SignalInterrupt is a subclass of KeyboardInterrupt, so there might
> be deeper problem.
> 
> FWIW, I think it's probably a good idea to replace this blacklist
> with `isinstance(exc, Exception)`.

Before my refactor there used to be two levels of error handling, 1) inside 
_parthandler which tried to seek to the end if it wasn't systemexit or 
keyboardinterrup, and 2) inside processbundle (which calls _parthandler) which 
only caught type Exception.

It seems like the correct unification of these would be to just keep the 
`isinstance(exc, Exception)` check above, and delete this sub-check entirely.  
I'll send an update.

REPOSITORY
  rHG Mercurial

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

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


[PATCH V4] strip: take branch into account when selecting update target (issue5540)

2017-10-11 Thread Paul Morelle
# HG changeset patch
# User Paul Morelle 
# Date 1507212785 -7200
#  Thu Oct 05 16:13:05 2017 +0200
# Node ID a9047aa04485e29fbad8c7af5cc83d64e7b3df2c
# Parent  05c2a9f37a1dde8df024876cca0f76108c8e6f42
# EXP-Topic issue-5540
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
a9047aa04485
strip: take branch into account when selecting update target (issue5540)

Test contributed by Matt Harbison

Keep the same behavior in most cases (i.e. first parent of the first root of
stripped changsets), but if the branch differs from wdir's, try to find another
parent of stripped commits that is on the same branch.

diff -r 05c2a9f37a1d -r a9047aa04485 hgext/strip.py
--- a/hgext/strip.pyThu Oct 05 15:11:34 2017 +0200
+++ b/hgext/strip.pyThu Oct 05 16:13:05 2017 +0200
@@ -60,10 +60,19 @@
 
 def _findupdatetarget(repo, nodes):
 unode, p2 = repo.changelog.parents(nodes[0])
+currentbranch = repo[None].branch()
 
 if (util.safehasattr(repo, 'mq') and p2 != nullid
 and p2 in [x.node for x in repo.mq.applied]):
 unode = p2
+elif currentbranch != repo[unode].branch():
+pwdir = 'parents(wdir())'
+revset = 'max(((parents(%ln::%r) + %r) - %ln::%r) and branch(%s))'
+branchtarget = repo.revs(revset, nodes, pwdir, pwdir, nodes, pwdir,
+ currentbranch)
+if branchtarget:
+cl = repo.changelog
+unode = cl.node(branchtarget.first())
 
 return unode
 
diff -r 05c2a9f37a1d -r a9047aa04485 tests/test-strip.t
--- a/tests/test-strip.tThu Oct 05 15:11:34 2017 +0200
+++ b/tests/test-strip.tThu Oct 05 16:13:05 2017 +0200
@@ -941,6 +941,214 @@
   abort: boom
   [255]
 
+test stripping a working directory parent doesn't switch named branches
+
+  $ hg log -G
+  @  changeset:   1:eca11cf91c71
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: commitB
+  |
+  o  changeset:   0:105141ef12d0
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: commitA
+  
+
+  $ hg branch new-branch
+  marked working directory as branch new-branch
+  (branches are permanent and global, did you want a bookmark?)
+  $ hg ci -m "start new branch"
+  $ echo 'foo' > foo.txt
+  $ hg ci -Aqm foo
+  $ hg up default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo 'bar' > bar.txt
+  $ hg ci -Aqm bar
+  $ hg up new-branch
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg merge default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg log -G
+  @  changeset:   4:35358f982181
+  |  tag: tip
+  |  parent:  1:eca11cf91c71
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: bar
+  |
+  | @  changeset:   3:f62c6c09b707
+  | |  branch:  new-branch
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: foo
+  | |
+  | o  changeset:   2:b1d33a8cadd9
+  |/   branch:  new-branch
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |summary: start new branch
+  |
+  o  changeset:   1:eca11cf91c71
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: commitB
+  |
+  o  changeset:   0:105141ef12d0
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: commitA
+  
+
+  $ hg strip --force -r 35358f982181
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  saved backup bundle to 
$TESTTMP/issue4736/.hg/strip-backup/35358f982181-50d992d4-backup.hg (glob)
+  $ hg log -G
+  @  changeset:   3:f62c6c09b707
+  |  branch:  new-branch
+  |  tag: tip
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: foo
+  |
+  o  changeset:   2:b1d33a8cadd9
+  |  branch:  new-branch
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: start new branch
+  |
+  o  changeset:   1:eca11cf91c71
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: commitB
+  |
+  o  changeset:   0:105141ef12d0
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: commitA
+  
+
+  $ hg up default
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo 'bar' > bar.txt
+  $ hg ci -Aqm bar
+  $ hg up new-branch
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg merge default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m merge
+  $ hg log -G
+  @changeset:   5:4cf5e92caec2
+  |\   branch:  

Re: [PATCH] configitems: fix registration for 'blackbox.track' config

2017-10-11 Thread Augie Fackler
On Wed, Oct 11, 2017 at 03:42:21PM +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1507728357 -7200
> #  Wed Oct 11 15:25:57 2017 +0200
> # Node ID 0ae4811261aa53efb6372572dae546fdd98b8f58
> # Parent  4a6a337f9c682bdf1659295f871dc43ff33677ca
> # EXP-Topic config.fixup.blackbox
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 0ae4811261aa
> configitems: fix registration for 'blackbox.track' config

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


Re: [PATCH V2] status: copy-edit and improve --terse and --verbose help

2017-10-11 Thread Augie Fackler
On Wed, Oct 11, 2017 at 10:18:04AM -0500, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock 
> # Date 1507649255 18000
> #  Tue Oct 10 10:27:35 2017 -0500
> # Node ID 0849db4f486b78f7756d9548841d6ba37bd41332
> # Parent  7259f0ddfc0f18138420e7c9c7e4145a25016d7b
> status: copy-edit and improve --terse and --verbose help

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


Re: [PATCH] templater: store revisions as ints so min/max won't compare them as strings

2017-10-11 Thread Augie Fackler
On Thu, Oct 12, 2017 at 12:02:26AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1505830426 -32400
> #  Tue Sep 19 23:13:46 2017 +0900
> # Node ID 71e49fbf7b471fd41478705a4bd7e71f67b0c97e
> # Parent  1b59287a1cfa3074c092837a5f8ecb63cb6e1933
> templater: store revisions as ints so min/max won't compare them as strings

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


[PATCH V2] status: copy-edit and improve --terse and --verbose help

2017-10-11 Thread Kevin Bullock
# HG changeset patch
# User Kevin Bullock 
# Date 1507649255 18000
#  Tue Oct 10 10:27:35 2017 -0500
# Node ID 0849db4f486b78f7756d9548841d6ba37bd41332
# Parent  7259f0ddfc0f18138420e7c9c7e4145a25016d7b
status: copy-edit and improve --terse and --verbose help

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4719,28 +4719,23 @@ def status(ui, repo, *pats, **opts):
 
 .. container:: verbose
 
-  The -t/--terse option abbreviates the output by showing directory name
-  if all the files in it share the same status. The option expects a value
-  which can be a string formed by using 'm', 'a', 'r', 'd', 'u', 'i', 'c'
-  where, 'm' stands for 'modified', 'a' for 'added', 'r' for 'removed',
-  'd' for 'deleted', 'u' for 'unknown', 'i' for 'ignored' and 'c' for 
clean.
-
-  It terses the output of only those status which are passed. The ignored
-  files are not considered while tersing until 'i' is there in --terse 
value
-  or the --ignored option is used.
-
-  --verbose option shows more context about the state of the repo
-  like the repository is in unfinised merge, shelve, rebase state etc.
-  You can have this behaviour turned on by default by following config:
-
-  [commands]
-  status.verbose = true
-
-  You can also skip some states like bisect by adding following in
-  configuration file.
-
-  [commands]
-  status.skipstates = bisect
+  The -t/--terse option abbreviates the output by showing only the 
directory
+  name if all the files in it share the same status. The option takes an
+  argument indicating the statuses to abbreviate: 'm' for 'modified', 'a'
+  for 'added', 'r' for 'removed', 'd' for 'deleted', 'u' for 'unknown', 'i'
+  for 'ignored' and 'c' for clean.
+
+  It abbreviates only those statuses which are passed. Note that ignored
+  files are not displayed with '--terse i' unless the -i/--ignored option 
is
+  also used.
+
+  The -v/--verbose option shows information when the repository is in an
+  unfinished merge, shelve, rebase state etc. You can have this behavior
+  turned on by default by enabling the ``commands.status.verbose`` option.
+
+  You can skip displaying some of these states by setting
+  ``commands.status.skipstates`` to one or more of: 'bisect', 'graft',
+  'histedit', 'merge', 'rebase', or 'unshelve'.
 
   Examples:
 
@@ -4762,7 +4757,13 @@ def status(ui, repo, *pats, **opts):
 
   hg status -an0
 
+  - show more information about the repository status, abbreviating
+added, removed, modified, deleted, and untracked paths::
+
+  hg status -v -t mardu
+
 Returns 0 on success.
+
 """
 
 opts = pycompat.byteskwargs(opts)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH] templater: store revisions as ints so min/max won't compare them as strings

2017-10-11 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1505830426 -32400
#  Tue Sep 19 23:13:46 2017 +0900
# Node ID 71e49fbf7b471fd41478705a4bd7e71f67b0c97e
# Parent  1b59287a1cfa3074c092837a5f8ecb63cb6e1933
templater: store revisions as ints so min/max won't compare them as strings

Because a template value has no explicit type (like ancient PHP), ifcontains()
has to coerce the type of the needle. Before, it was always converted to a
string, which meant any container type should be a list/dict of strings.
This no longer works since we've introduced min/max functions.

In order to work around the untyped nature of templater, this patch adds
a type specifier to hybrid dict/list. It isn't named as "valuetype" since
the _hybrid class can also wrap a dict.

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -37,12 +37,13 @@ class _hybrid(object):
 - "{files|json}"
 """
 
-def __init__(self, gen, values, makemap, joinfmt):
+def __init__(self, gen, values, makemap, joinfmt, keytype=None):
 if gen is not None:
 self.gen = gen  # generator or function returning generator
 self._values = values
 self._makemap = makemap
 self.joinfmt = joinfmt
+self.keytype = keytype  # hint for 'x in y' where type(x) is unresolved
 def gen(self):
 """Default generator to stringify this as {join(self, ' ')}"""
 for i, x in enumerate(self._values):
@@ -788,15 +789,14 @@ def showparents(**args):
 repo = args['repo']
 ctx = args['ctx']
 pctxs = scmutil.meaningfulparents(repo, ctx)
-# ifcontains() needs a list of str
-prevs = ["%d" % p.rev() for p in pctxs]
+prevs = [p.rev() for p in pctxs]
 parents = [[('rev', p.rev()),
 ('node', p.hex()),
 ('phase', p.phasestr())]
for p in pctxs]
 f = _showlist('parent', parents, args)
-return _hybrid(f, prevs, lambda x: {'ctx': repo[int(x)], 'revcache': {}},
-   lambda x: scmutil.formatchangeid(repo[int(x)]))
+return _hybrid(f, prevs, lambda x: {'ctx': repo[x], 'revcache': {}},
+   lambda x: scmutil.formatchangeid(repo[x]), keytype=int)
 
 @templatekeyword('phase')
 def showphase(repo, ctx, templ, **args):
@@ -818,12 +818,10 @@ def showrevslist(name, revs, **args):
 be evaluated"""
 args = pycompat.byteskwargs(args)
 repo = args['ctx'].repo()
-# ifcontains() needs a list of str
-revs = ["%d" % r for r in revs]
-f = _showlist(name, revs, args)
+f = _showlist(name, ['%d' % r for r in revs], args)
 return _hybrid(f, revs,
-   lambda x: {name: x, 'ctx': repo[int(x)], 'revcache': {}},
-   pycompat.identity)
+   lambda x: {name: x, 'ctx': repo[x], 'revcache': {}},
+   pycompat.identity, keytype=int)
 
 @templatekeyword('subrepos')
 def showsubrepos(**args):
diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -333,12 +333,12 @@ def evalboolean(context, mapping, arg):
 # empty dict/list should be False as they are expected to be ''
 return bool(stringify(thing))
 
-def evalinteger(context, mapping, arg, err):
+def evalinteger(context, mapping, arg, err=None):
 v = evalfuncarg(context, mapping, arg)
 try:
 return int(v)
 except (TypeError, ValueError):
-raise error.ParseError(err)
+raise error.ParseError(err or _('not an integer'))
 
 def evalstring(context, mapping, arg):
 return stringify(evalrawexp(context, mapping, arg))
@@ -353,6 +353,20 @@ def evalstringliteral(context, mapping, 
 thing = func(context, mapping, data)
 return stringify(thing)
 
+_evalfuncbytype = {
+bool: evalboolean,
+bytes: evalstring,
+int: evalinteger,
+}
+
+def evalastype(context, mapping, arg, typ):
+"""Evaluate given argument and coerce its type"""
+try:
+f = _evalfuncbytype[typ]
+except KeyError:
+raise error.ProgrammingError('invalid type specified: %r' % typ)
+return f(context, mapping, arg)
+
 def runinteger(context, mapping, data):
 return int(data)
 
@@ -782,8 +796,9 @@ def ifcontains(context, mapping, args):
 # i18n: "ifcontains" is a keyword
 raise error.ParseError(_("ifcontains expects three or four arguments"))
 
-needle = evalstring(context, mapping, args[0])
 haystack = evalfuncarg(context, mapping, args[1])
+needle = evalastype(context, mapping, args[0],
+getattr(haystack, 'keytype', None) or bytes)
 
 if needle in haystack:
 yield evalrawexp(context, mapping, args[2])
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
@@ -3147,6 +3147,13 @@ Test manifest/get() can be join()-ed as 
   $ hg log -R 

D1006: bdiff: remove extra space after * per clang-format

2017-10-11 Thread durin42 (Augie Fackler)
durin42 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/D1006

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -30,7 +30,7 @@
unsigned hash;
int i;
const char *p, *b = a;
-   const char * const plast = a + len - 1;
+   const char *const plast = a + len - 1;
struct bdiff_line *l;
 
/* count the lines */



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


D1004: bdiff: format header file with clang-format

2017-10-11 Thread durin42 (Augie Fackler)
durin42 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/D1004

AFFECTED FILES
  mercurial/bdiff.h

CHANGE DETAILS

diff --git a/mercurial/bdiff.h b/mercurial/bdiff.h
--- a/mercurial/bdiff.h
+++ b/mercurial/bdiff.h
@@ -15,7 +15,7 @@
 
 int bdiff_splitlines(const char *a, ssize_t len, struct bdiff_line **lr);
 int bdiff_diff(struct bdiff_line *a, int an, struct bdiff_line *b, int bn,
-   struct bdiff_hunk *base);
+   struct bdiff_hunk *base);
 void bdiff_freehunks(struct bdiff_hunk *l);
 
 #endif



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


D1007: bdiff: re-wrap lines per clang-format

2017-10-11 Thread durin42 (Augie Fackler)
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  A few too-wide lines corrected, and some places where clang-format
  prefers to wrap after the binary operator instead of before. I don't
  feel strongly, so I'm leaving the auto-format result as "after the
  binary operator".

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -79,7 +79,8 @@
 
 static inline int cmp(struct bdiff_line *a, struct bdiff_line *b)
 {
-   return a->hash != b->hash || a->len != b->len || memcmp(a->l, b->l, 
a->len);
+   return a->hash != b->hash || a->len != b->len ||
+  memcmp(a->l, b->l, a->len);
 }
 
 static int equatelines(struct bdiff_line *a, int an, struct bdiff_line *b,
@@ -211,8 +212,7 @@
}
 
/* expand match to include subsequent popular lines */
-   while (mi + mk < a2 && mj + mk < b2 &&
-  a[mi + mk].e == b[mj + mk].e)
+   while (mi + mk < a2 && mj + mk < b2 && a[mi + mk].e == b[mj + mk].e)
mk++;
 
*omi = mi;
@@ -238,7 +238,8 @@
if (!l)
return NULL;
 
-   l->next = (struct bdiff_hunk *)malloc(sizeof(struct 
bdiff_hunk));
+   l->next =
+   (struct bdiff_hunk *)malloc(sizeof(struct bdiff_hunk));
if (!l->next)
return NULL;
 
@@ -274,7 +275,8 @@
return -1;
 
/* sentinel end hunk */
-   curr->next = (struct bdiff_hunk *)malloc(sizeof(struct 
bdiff_hunk));
+   curr->next =
+   (struct bdiff_hunk *)malloc(sizeof(struct bdiff_hunk));
if (!curr->next)
return -1;
curr = curr->next;
@@ -293,10 +295,9 @@
break;
 
if (curr->a2 == next->a1 || curr->b2 == next->b1)
-   while (curr->a2 < an && curr->b2 < bn
-  && next->a1 < next->a2
-  && next->b1 < next->b2
-  && !cmp(a + curr->a2, b + curr->b2)) {
+   while (curr->a2 < an && curr->b2 < bn &&
+  next->a1 < next->a2 && next->b1 < next->b2 &&
+  !cmp(a + curr->a2, b + curr->b2)) {
curr->a2++;
next->a1++;
curr->b2++;



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


D1009: bdiff: remove trailing newlines

2017-10-11 Thread durin42 (Augie Fackler)
durin42 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/D1009

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -318,5 +318,3 @@
free(l);
}
 }
-
-



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


D1008: bdiff: rewrap function prototypes per clang-format

2017-10-11 Thread durin42 (Augie Fackler)
durin42 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/D1008

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -84,7 +84,7 @@
 }
 
 static int equatelines(struct bdiff_line *a, int an, struct bdiff_line *b,
-   int bn)
+   int bn)
 {
int i, j, buckets = 1, t, scale;
struct pos *h = NULL;
@@ -150,8 +150,8 @@
 }
 
 static int longest_match(struct bdiff_line *a, struct bdiff_line *b,
-   struct pos *pos,
-int a1, int a2, int b1, int b2, int *omi, int *omj)
+ struct pos *pos, int a1, int a2, int b1, int b2,
+ int *omi, int *omj)
 {
int mi = a1, mj = b1, mk = 0, i, j, k, half, bhalf;
 
@@ -222,8 +222,8 @@
 }
 
 static struct bdiff_hunk *recurse(struct bdiff_line *a, struct bdiff_line *b,
-   struct pos *pos,
-   int a1, int a2, int b1, int b2, struct bdiff_hunk 
*l)
+  struct pos *pos, int a1, int a2, int b1,
+  int b2, struct bdiff_hunk *l)
 {
int i, j, k;
 
@@ -256,8 +256,8 @@
}
 }
 
-int bdiff_diff(struct bdiff_line *a, int an, struct bdiff_line *b,
-   int bn, struct bdiff_hunk *base)
+int bdiff_diff(struct bdiff_line *a, int an, struct bdiff_line *b, int bn,
+   struct bdiff_hunk *base)
 {
struct bdiff_hunk *curr;
struct pos *pos;



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


D1005: bdiff: fix misplaced comma in macro definition with clang-format

2017-10-11 Thread durin42 (Augie Fackler)
durin42 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/D1005

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -19,7 +19,7 @@
 
 /* Hash implementation from diffutils */
 #define ROL(v, n) ((v) << (n) | (v) >> (sizeof(v) * CHAR_BIT - (n)))
-#define HASH(h, c) ((c) + ROL(h ,7))
+#define HASH(h, c) ((c) + ROL(h, 7))
 
 struct pos {
int pos, len;



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


D1003: bdiff: sort includes using clang-format

2017-10-11 Thread durin42 (Augie Fackler)
durin42 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/D1003

AFFECTED FILES
  mercurial/bdiff.c

CHANGE DETAILS

diff --git a/mercurial/bdiff.c b/mercurial/bdiff.c
--- a/mercurial/bdiff.c
+++ b/mercurial/bdiff.c
@@ -9,13 +9,13 @@
  Based roughly on Python difflib
 */
 
+#include 
 #include 
 #include 
-#include 
 
+#include "bdiff.h"
+#include "bitmanipulation.h"
 #include "compat.h"
-#include "bitmanipulation.h"
-#include "bdiff.h"
 
 /* Hash implementation from diffutils */
 #define ROL(v, n) ((v) << (n) | (v) >> (sizeof(v) * CHAR_BIT - (n)))



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


D987: copies: add a config to limit the number of candidates to check in heuristics

2017-10-11 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added a comment.
This revision now requires changes to proceed.


  Oops, the default value (5 vs 100) wasn't my point. I doubt if taking the 
first n
  candidates would be a good "heuristic."
  
  If I understand correctly, it may miss the copy information only if the file 
is
  out of the n-candidates list. I think it would be hard for users to understand
  why the copy wasn't detected. That's my concern.
  
  (marked as "request changes" to flag discussion is ongoing. no new version is 
requested.)

REPOSITORY
  rHG Mercurial

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

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


D821: unamend: move fb extension unamend to core

2017-10-11 Thread ryanmce (Ryan McElroy)
ryanmce added inline comments.

INLINE COMMENTS

> ryanmce wrote in uncommit.py:260
> Test test

Tested nested comments, sorry for the spam.

REPOSITORY
  rHG Mercurial

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

To: pulkit, #hg-reviewers, durham
Cc: ryanmce, singhsrb, durham, 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 V3] strip: take branch into account when selecting update target (issue5540)

2017-10-11 Thread Paul Morelle
On 10/11/2017 03:01 PM, Yuya Nishihara wrote:
> On Tue, 10 Oct 2017 11:44:43 +0200, Paul Morelle wrote:
>>  if (util.safehasattr(repo, 'mq') and p2 != nullid
>>  and p2 in [x.node for x in repo.mq.applied]):
>>  unode = p2
>> +elif current_branch != repo[unode].branch():
>> +pwdir = 'parents(wdir())'
>> +revset = ('max(((parents(%ln::{0}) + {0}) - %ln::{0})'
>> +  ' and branch(%s))'
>> + ).format(pwdir)
> bytes.format() isn't available on Python 3. Instead, you can use %r to embed
> a revset expression.
Oh, something new to know about Mercurial and Python3.
Today I have learned that all the strings are transformed into bytes in
mercurial in Python3.
I will push a V4 including your remarks.
Thank you very much!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 4 of 4 v3] log: add -L/--line-range option to follow file history by line range

2017-10-11 Thread Yuya Nishihara
On Tue, 10 Oct 2017 17:37:27 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde 
> # Date 1507290475 -7200
> #  Fri Oct 06 13:47:55 2017 +0200
> # Node ID a05d3b45319a9ec28205f19dd7012b206a2b200f
> # Parent  86a055d1c06f55daeb5d725187b61522974d24e3
> # Available At http://hg.logilab.org/users/dlaxalde/hg
> #  hg pull http://hg.logilab.org/users/dlaxalde/hg -r a05d3b45319a
> # EXP-Topic followlines-cli/v2
> log: add -L/--line-range option to follow file history by line range

The series generally looks good to me in functionality POV. Some nits follow.

So, do we really like this UI?

> We add a -L/--line-range option to 'hg log' taking file patterns along with a
> line range using the (new) FILE,FROMLINE-TOLINE syntax where FILE may be a
> pattern (matching exactly one file). The resulting history is similar to what
> the "followlines" revset except that, if --patch is specified, only diff hunks
> within specified line range are shown (it's also more convenient to type).
> 
> Basically, this brings the CLI on par with what currently only exists in hgweb
> through line selection in "file" and "annotate" views resulting in a file log
> with filtered patch to only display followed line range.
> 
> The option may be specified multiple times and can be combined with --rev to
> futher restrict revisions. Revisions are shown in descending order and
> renames are followed (sort of implying --follow).
> Only the --graph option is currently not supported.
> 
> Some debatable UI choices (I did not think too much about this for now).
> 
> *   "," as a separator between the FILE and line range information; the idea
> is to avoid confusion with file pattern syntax which uses ":".
> 
> *   "-" in the line range information may not be the best choice; in
> particular, we might want to add support for an offset +/- syntax.

Perhaps ":" would be better for consistency with the followlines() revset.

> +def getloglinerangerevs(repo, userrevs, opts):
> +"""Return (revs, filematcher, hunksfilter).
> +
> +"revs" are revisions obtained by processing "line-range" log options and
> +walking block ancestors of each specified file/line-range.
> +
> +"filematcher(rev) -> match" is a factory function returning a match 
> object
> +for a given revision for file patterns specified in --line-range option.
> +If neither --stat nor --patch options are passed, "filematcher" is None.
> +
> +"hunksfilter(rev) -> filterfn(fctx, hunks)" is a factory function
> +returning a hunks filtering function.
> +If neither --stat nor --patch options are passed, "filterhunks" is None.
> +"""
> +wctx = repo[None]
> +
> +# Two-levels map of "rev -> file ctx -> [line range]".
> +linerangesbyrev = {}
> +for fname, (fromline, toline) in _parselinerangelogopt(repo, opts):
> +fctx = wctx.filectx(fname)
> +for fctx, linerange in dagop.blockancestors(fctx, fromline, toline):
> +if fctx.rev() not in userrevs:
> +continue
> +linerangesbyrev.setdefault(
> +fctx.rev(), {}).setdefault(

I'm not sure, but it might be fctx.introrev() since this function seems quite
similar to _makefollowlogfilematcher().

> +fctx, []).append(linerange)

Perhaps it's better to not cache fctx for long. IIUC, we only need
(rev or node, path).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D945: fsmonitor: update to match new dirstate refactor

2017-10-11 Thread durham (Durham Goode)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG7259f0ddfc0f: fsmonitor: update to match new dirstate 
refactor (authored by durham, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D945?vs=2536=2583

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

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -251,7 +251,7 @@
 
 matchfn = match.matchfn
 matchalways = match.always()
-dmap = self._map
+dmap = self._map._map
 nonnormalset = getattr(self, '_nonnormalset', None)
 
 copymap = self._map.copymap



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


[PATCH 4 of 5 V2] phase: add a dedicated txnclose-phase hook

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507477846 -7200
#  Sun Oct 08 17:50:46 2017 +0200
# Node ID cc17c721c2116252d988ee9fa6c35cb99f7e93c7
# Parent  60ba6d338a3b56a0ea5b759a71701bdda35b9645
# EXP-Topic b2.phases.hooks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
cc17c721c211
phase: add a dedicated txnclose-phase hook

The new 'txnclose-phase' hook expose the phase movement information stored in
'tr.changes['phases]'. To provide a simple and straightforward hook API to the
users, we introduce a new hook called for each revision affected.  Since a
transaction can affect the phase of multiple changesets, updating the existing
'txnclose' hook to expose that information would be more complex. The data for
all moves will not fit in environment variables and iterations over each move
would be cumbersome. So the introduction of a new dedicated hook is
preferred in this changesets.

This does not exclude the addition of the full phase movement information to
the existing 'txnclose' in the future to help write more complex hooks.

diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1002,6 +1002,16 @@
   is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
   about available variables.
 
+``txnclose-phase``
+  Run after any phase change has been committed. At this point, the
+  transaction can no longer be rolled back. The hook will run after the lock
+  is released.
+  The affected node is available in ``$HG_NODE``, the new phase will be
+  available in ``$HG_PHASE`` while the previous phase will be available in
+  ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE`` will be empty.  In
+  addition, the reason for the transaction opening will be in ``$HG_TXNNAME``,
+  and a unique identifier for the transaction will be in ``HG_TXNID``.
+
 ``txnabort``
   Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
   for details about available variables.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1299,6 +1299,16 @@
 repo.hook('txnclose-bookmark', throw=False,
   txnname=desc, **pycompat.strkwargs(args))
 
+if hook.hashook(repo.ui, 'txnclose-phase'):
+cl = repo.unfiltered().changelog
+phasemv = sorted(tr.changes['phases'].items())
+for rev, (old, new) in phasemv:
+args = tr.hookargs.copy()
+node = hex(cl.node(rev))
+args.update(phases.preparehookargs(node, old, new))
+repo.hook('txnclose-phase', throw=False, txnname=desc,
+  **pycompat.strkwargs(args))
+
 repo.hook('txnclose', throw=False, txnname=desc,
   **pycompat.strkwargs(hookargs))
 reporef()._afterlock(hookfunc)
diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -632,3 +632,12 @@
 def hassecret(repo):
 """utility function that check if a repo have any secret changeset."""
 return bool(repo._phasecache.phaseroots[2])
+
+def preparehookargs(node, old, new):
+if old is None:
+old = ''
+else:
+old = '%s' % old
+return {'node': node,
+'oldphase': old,
+'phase': '%s' % new}
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -2,6 +2,8 @@
   $ cat >> $HGRCPATH << EOF
   > [extensions]
   > phasereport=$TESTDIR/testlib/ext-phase-report.py
+  > [hooks]
+  > txnclose-phase.test = echo "test-hook-close-phase: \$HG_NODE:  
\$HG_OLDPHASE -> \$HG_PHASE"
   > EOF
 
   $ hglog() { hg log --template "{rev} {phaseidx} {desc}\n" $*; }
@@ -26,6 +28,7 @@
 
   $ mkcommit A
   test-debug-phase: new rev 0:  x -> 1
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> 1
 
 New commit are draft by default
 
@@ -36,6 +39,7 @@
 
   $ mkcommit B
   test-debug-phase: new rev 1:  x -> 1
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:   -> 1
 
   $ hglog
   1 1 B
@@ -46,6 +50,8 @@
   $ hg phase --public .
   test-debug-phase: move rev 0: 1 -> 0
   test-debug-phase: move rev 1: 1 -> 0
+  test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:  1 -> 0
+  test-hook-close-phase: 27547f69f25460a52fff66ad004e58da7ad3fb56:  1 -> 0
   $ hg phase
   1: public
   $ hglog
@@ -54,8 +60,10 @@
 
   $ mkcommit C
   test-debug-phase: new rev 2:  x -> 1
+  test-hook-close-phase: f838bfaca5c7226600ebcfd84f3c3c13a28d3757:   -> 1
   $ mkcommit D
   test-debug-phase: new rev 3:  x -> 1
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:   -> 1
 

[PATCH 3 of 5 V2] bookmark: add a dedicated pretxnclose-bookmark hook

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507481414 -7200
#  Sun Oct 08 18:50:14 2017 +0200
# Node ID 60ba6d338a3b56a0ea5b759a71701bdda35b9645
# Parent  03a0d02653cb1ab9957890f527144d1d0fed48b0
# EXP-Topic b2.phases.hooks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
60ba6d338a3b
bookmark: add a dedicated pretxnclose-bookmark hook

This new hook mirror the newly introduced 'txnclose-bookmark' but can abort the
transaction.

diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -976,6 +976,20 @@
   phase changes will set ``HG_BOOKMARK_MOVED`` and ``HG_PHASES_MOVED`` to ``1``
   respectively, etc.
 
+``pretxnclose-bookmark``
+  Run right before a bookmark change is actually finalized. Any repository
+  change will be visible to the hook program. This lets you validate the
+  transaction content or change it. Exit status 0 allows the commit to
+  proceed. A non-zero status will cause the transaction to be rolled back.
+  The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
+  bookmark location will be available in ``$HG_NODE`` while the previous
+  location will be available in ``$HG_OLDNODE``. In case of a bookmark
+  creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
+  will be empty.
+  In addition, the reason for the transaction opening will be in
+  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
+  ``HG_TXNID``.
+
 ``txnclose``
   Run after any repository transaction has been committed. At this
   point, the transaction can no longer be rolled back. The hook will run
@@ -985,14 +999,8 @@
 ``txnclose-bookmark``
   Run after any bookmark change has been committed. At this point, the
   transaction can no longer be rolled back. The hook will run after the lock
-  is released.
-  The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
-  bookmark location will be available in ``$HG_NODE`` while the previous
-  location will be available in ``$HG_OLDNODE``. In case of a bookmark
-  creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
-  will be empty. In addition, the reason for the transaction opening will be
-  in ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
-  ``HG_TXNID``.
+  is released. See :hg:`help config.hooks.pretxnclose-bookmark` for details
+  about available variables.
 
 ``txnabort``
   Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1235,8 +1235,17 @@
 # This will have to be fixed before we remove the experimental
 # gating.
 tracktags(tr2)
-reporef().hook('pretxnclose', throw=True,
-   txnname=desc, **pycompat.strkwargs(tr.hookargs))
+repo = reporef()
+if hook.hashook(repo.ui, 'pretxnclose-bookmark'):
+for name, (old, new) in 
sorted(tr.changes['bookmarks'].items()):
+args = tr.hookargs.copy()
+args.update(bookmarks.preparehookargs(name, old, new))
+repo.hook('pretxnclose-bookmark', throw=True,
+  txnname=desc,
+  **pycompat.strkwargs(args))
+
+repo.hook('pretxnclose', throw=True,
+  txnname=desc, **pycompat.strkwargs(tr.hookargs))
 def releasefn(tr, success):
 repo = reporef()
 if success:
diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -1113,3 +1113,100 @@
   rollback completed
   abort: pretxnclose hook exited with status 1
   [255]
+
+Check pretxnclose-bookmark can abort a transaction
+--
+
+add hooks:
+
+* to prevent NEW bookmark on a non-public changeset
+* to prevent non-forward move of NEW bookmark
+
+  $ cat << EOF >> .hg/hgrc
+  > [hooks]
+  > pretxnclose-bookmark.force-public  = (echo \$HG_BOOKMARK| grep -v NEW > 
/dev/null) || [ -z "\$HG_NODE" ] || (hg log -r "\$HG_NODE" -T '{phase}' | grep 
public > /dev/null)
+  > pretxnclose-bookmark.force-forward = (echo \$HG_BOOKMARK| grep -v NEW > 
/dev/null) || [ -z "\$HG_NODE" ] || (hg log -r "max(\$HG_OLDNODE::\$HG_NODE)" 
-T 'MATCH' | grep MATCH > /dev/null)
+  > EOF
+
+  $ hg log -G -T phases
+  @  changeset:   6:81dcce76aa0b
+  |  tag: tip
+  |  phase:   draft
+  |  parent:  4:125c9a1d6df6
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: xx
+  |
+  | o  changeset:   5:5fb12f0f2d51
+  | |  branch:  test
+  | |  bookmark:Z
+  | |  phase:   draft
+  | |  parent:  3:9ba5f110a0b3
+  | | 

[PATCH 2 of 5 V2] bookmark: add a dedicated txnclose-bookmark hook

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507650822 -7200
#  Tue Oct 10 17:53:42 2017 +0200
# Node ID 03a0d02653cb1ab9957890f527144d1d0fed48b0
# Parent  1a64b2bcd0209ea3b906f458818db6f29cebbcd7
# EXP-Topic b2.phases.hooks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
03a0d02653cb
bookmark: add a dedicated txnclose-bookmark hook

The new 'txnclose-bookmark' hook expose the bookmark movement information
stored in 'tr.changes['bookmarks]'. To provide a simple and straightforward
hook API to the users, we introduce a new hook called for each bookmark
touched. Since a transaction can affect multiple bookmarks, updating the
existing 'txnclose' hook to expose that information would be more complex. The
data for all moves might not fit in environment variables and iterations over
each move would be cumbersome. So the introduction of a new dedicated hook is
preferred in this changeset.

This does not exclude the addition to the full bookmark information to the
existing 'txnclose' in the future to help write more complex hooks.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -846,3 +846,12 @@
 
 bmarks[bmark] = (n, prefix, label)
 _printbookmarks(ui, repo, bmarks, **opts)
+
+def preparehookargs(name, old, new):
+if new is None:
+new = ''
+if old is None:
+old = ''
+return {'bookmark': name,
+'node': hex(new),
+'oldnode': hex(old)}
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -982,6 +982,18 @@
   after the lock is released. See :hg:`help config.hooks.pretxnclose` for
   details about available variables.
 
+``txnclose-bookmark``
+  Run after any bookmark change has been committed. At this point, the
+  transaction can no longer be rolled back. The hook will run after the lock
+  is released.
+  The name of the bookmark will be available in ``$HG_BOOKMARK``, the new
+  bookmark location will be available in ``$HG_NODE`` while the previous
+  location will be available in ``$HG_OLDNODE``. In case of a bookmark
+  creation ``$HG_OLDNODE`` will be empty. In case of deletion ``$HG_NODE``
+  will be empty. In addition, the reason for the transaction opening will be
+  in ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
+  ``HG_TXNID``.
+
 ``txnabort``
   Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
   for details about available variables.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1280,10 +1280,19 @@
 # fixes the function accumulation.
 hookargs = tr2.hookargs
 
-def hook():
-reporef().hook('txnclose', throw=False, txnname=desc,
-   **pycompat.strkwargs(hookargs))
-reporef()._afterlock(hook)
+def hookfunc():
+repo = reporef()
+if hook.hashook(repo.ui, 'txnclose-bookmark'):
+bmchanges = sorted(tr.changes['bookmarks'].items())
+for name, (old, new) in bmchanges:
+args = tr.hookargs.copy()
+args.update(bookmarks.preparehookargs(name, old, new))
+repo.hook('txnclose-bookmark', throw=False,
+  txnname=desc, **pycompat.strkwargs(args))
+
+repo.hook('txnclose', throw=False, txnname=desc,
+  **pycompat.strkwargs(hookargs))
+reporef()._afterlock(hookfunc)
 tr.addfinalize('txnclose-hook', txnclosehook)
 tr.addpostclose('warms-cache', self._buildcacheupdater(tr))
 def txnaborthook(tr2):
diff --git a/tests/test-bookmarks-pushpull.t b/tests/test-bookmarks-pushpull.t
--- a/tests/test-bookmarks-pushpull.t
+++ b/tests/test-bookmarks-pushpull.t
@@ -7,6 +7,8 @@
   > publish=False
   > [experimental]
   > stabilization=createmarkers,exchange
+  > [hooks]
+  > txnclose-bookmark.test = echo "test-hook-bookmark: \$HG_BOOKMARK:  
\$HG_OLDNODE -> \$HG_NODE"
   > EOF
 
 initialize
@@ -20,14 +22,18 @@
 set bookmarks
 
   $ hg bookmark X
+  test-hook-bookmark: X:   -> 4e3505fd95835d721066b76e75dbb8cc554d7f77
   $ hg bookmark Y
+  test-hook-bookmark: Y:   -> 4e3505fd95835d721066b76e75dbb8cc554d7f77
   $ hg bookmark Z
+  test-hook-bookmark: Z:   -> 4e3505fd95835d721066b76e75dbb8cc554d7f77
 
 import bookmark by name
 
   $ hg init ../b
   $ cd ../b
   $ hg book Y
+  test-hook-bookmark: Y:   -> 
   $ hg book
* Y -1:
   $ hg pull ../a
@@ -40,6 +46,9 @@
   adding remote bookmark X
   updating bookmark Y
   adding remote bookmark Z
+  

[PATCH 5 of 5 V2] phase: add a dedicated pretxnclose-phase hook

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507476198 -7200
#  Sun Oct 08 17:23:18 2017 +0200
# Node ID dd84b948c43b4891af9427ae892c4a17d6c9b22f
# Parent  cc17c721c2116252d988ee9fa6c35cb99f7e93c7
# EXP-Topic b2.phases.hooks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
dd84b948c43b
phase: add a dedicated pretxnclose-phase hook

This new hook mirror the newly introduced 'txnclose-phase' but can abort the
transaction.

diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -990,6 +990,17 @@
   ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
   ``HG_TXNID``.
 
+``pretxnclose-phase``
+  Run right before a phase change is actually finalized. Any repository change
+  will be visible to the hook program. This lets you validate the transaction
+  content or change it. Exit status 0 allows the commit to proceed.  A non-zero
+  status will cause the transaction to be rolled back.
+  The affected node is available in ``$HG_NODE``, the phase in ``$HG_PHASE``
+  while the previous ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE``
+  will be empty.  In addition, the reason for the transaction opening will be 
in
+  ``$HG_TXNNAME``, and a unique identifier for the transaction will be in
+  ``HG_TXNID``.
+
 ``txnclose``
   Run after any repository transaction has been committed. At this
   point, the transaction can no longer be rolled back. The hook will run
@@ -1005,12 +1016,8 @@
 ``txnclose-phase``
   Run after any phase change has been committed. At this point, the
   transaction can no longer be rolled back. The hook will run after the lock
-  is released.
-  The affected node is available in ``$HG_NODE``, the new phase will be
-  available in ``$HG_PHASE`` while the previous phase will be available in
-  ``$HG_OLDPHASE``. In case of new node, ``$HG_OLDPHASE`` will be empty.  In
-  addition, the reason for the transaction opening will be in ``$HG_TXNNAME``,
-  and a unique identifier for the transaction will be in ``HG_TXNID``.
+  is released. See :hg:`help config.hooks.pretxnclose-phase` for details about
+  available variables.
 
 ``txnabort``
   Run when a transaction is aborted. See :hg:`help config.hooks.pretxnclose`
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1243,6 +1243,14 @@
 repo.hook('pretxnclose-bookmark', throw=True,
   txnname=desc,
   **pycompat.strkwargs(args))
+if hook.hashook(repo.ui, 'pretxnclose-phase'):
+cl = repo.unfiltered().changelog
+for rev, (old, new) in tr.changes['phases'].items():
+args = tr.hookargs.copy()
+node = hex(cl.node(rev))
+args.update(phases.preparehookargs(node, old, new))
+repo.hook('pretxnclose-phase', throw=True, txnname=desc,
+  **pycompat.strkwargs(args))
 
 repo.hook('pretxnclose', throw=True,
   txnname=desc, **pycompat.strkwargs(tr.hookargs))
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -730,3 +730,94 @@
   rollback completed
   abort: pretxnclose hook exited with status 1
   [255]
+
+Check that pretxnclose-phase hook can control phase movement
+
+  $ hg phase --force b3325c91a4d9 --secret
+  test-debug-phase: move rev 3: 0 -> 2
+  test-debug-phase: move rev 4: 0 -> 2
+  test-debug-phase: move rev 5: 1 -> 2
+  test-debug-phase: move rev 7: 0 -> 2
+  test-hook-close-phase: b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e:  0 -> 2
+  test-hook-close-phase: a603bfb5a83e312131cebcd05353c217d4d21dde:  0 -> 2
+  test-hook-close-phase: a030c6be5127abc010fcbff1851536552e6951a8:  1 -> 2
+  test-hook-close-phase: 17a481b3bccb796c0521ae97903d81c52bfee4af:  0 -> 2
+  $ hg log -G -T phases
+  @changeset:   7:17a481b3bccb
+  |\   tag: tip
+  | |  phase:   secret
+  | |  parent:  6:cf9fe039dfd6
+  | |  parent:  4:a603bfb5a83e
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: merge B' and E
+  | |
+  | o  changeset:   6:cf9fe039dfd6
+  | |  phase:   public
+  | |  parent:  1:27547f69f254
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: B'
+  | |
+  o |  changeset:   4:a603bfb5a83e
+  | |  phase:   secret
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: E
+  | |
+  o |  changeset:   3:b3325c91a4d9
+  | |  phase:   secret
+  | |  user:test
+  | |  date:Thu Jan 01 00:00:00 1970 +
+  | |  summary: D
+  | |
+  o |  changeset:   2:f838bfaca5c7
+  |/   phase:   

[PATCH 1 of 5 V2] hook: add a 'hashook' function to test for hook existence

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507460911 -7200
#  Sun Oct 08 13:08:31 2017 +0200
# Node ID 1a64b2bcd0209ea3b906f458818db6f29cebbcd7
# Parent  4a6a337f9c682bdf1659295f871dc43ff33677ca
# EXP-Topic b2.phases.hooks
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
1a64b2bcd020
hook: add a 'hashook' function to test for hook existence

Preparing the data for some hooks can be expensive. Add a function to check if
a hook exists so we can skip useless preparation if no hook is configured.

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -189,6 +189,15 @@
 global _redirect
 _redirect = state
 
+def hashook(ui, htype):
+"""return True if a hook is configured for 'htype'"""
+if not ui.callhooks:
+return False
+for hname, cmd in _allhooks(ui):
+if hname.split('.')[0] == htype and cmd:
+return True
+return False
+
 def hook(ui, repo, htype, throw=False, **args):
 if not ui.callhooks:
 return False
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D945: fsmonitor: update to match new dirstate refactor

2017-10-11 Thread ryanmce (Ryan McElroy)
ryanmce accepted this revision.
ryanmce added a comment.


  queued

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH] misc: rename README to README.rst

2017-10-11 Thread Yuya Nishihara
On Tue, 26 Sep 2017 08:37:23 +0200, David Demelier wrote:
> # HG changeset patch
> # User David Demelier 
> # Date 1506407837 -7200
> #  Tue Sep 26 08:37:17 2017 +0200
> # Node ID 49c0882e2c32ac1a4df10a3f7f51171ab1b677be
> # Parent  4f969b9e0cf5d4f2cfb7392cef7f43b74d17c5e4
> misc: rename README to README.rst

There's no -1 for weeks, so queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 01 of 13] configitems: register the 'blackbox.track' config

2017-10-11 Thread Boris Feld
On Tue, 2017-10-10 at 23:23 -0700, Martin von Zweigbergk wrote:
> On Mon, Oct 9, 2017 at 1:21 AM, Boris Feld 
> wrote:
> > # HG changeset patch
> > 
> > # User Boris Feld 
> > 
> > # Date 1507486294 -7200
> > 
> > #      Sun Oct 08 20:11:34 2017 +0200
> > 
> > # Node ID cdac8099d6c07e3d96e1c7c8fadab713f2111bd7
> > 
> > # Parent  8cef8f7d51d0f1e99889779ec1320d5c9c3b91de
> > 
> > # EXP-Topic config.register
> > 
> > # Available At https://bitbucket.org/octobus/mercurial-devel/
> > 
> > #              hg pull https://bitbucket.org/octobus/mercurial-deve
> > l/ -r cdac8099d6c0
> > 
> > configitems: register the 'blackbox.track' config
> > 
> > 
> > 
> > diff -r 8cef8f7d51d0 -r cdac8099d6c0 hgext/blackbox.py
> > 
> > --- a/hgext/blackbox.py Thu Oct 05 20:41:50 2017 -0700
> > 
> > +++ b/hgext/blackbox.py Sun Oct 08 20:11:34 2017 +0200
> > 
> > @@ -70,6 +70,9 @@
> > 
> >  configitem('blackbox', 'logsource',
> > 
> >      default=False,
> > 
> >  )
> > 
> > +configitem('blackbox', 'track',
> > 
> > +    default=['*'],
> > 
> > +)
> 
> Should not use mutable value as default. See 77e666f943a6
> (configitems: support callable as a default value, 2017-06-28).
> Right?
> 
> The patch is pretty deep in the stack of queued commits, so I'll
> accept, but please send a followup.

You are definitely right! I just sent a followup, thank you for
catching it.
> > 
> >  lastui = None
> > 
> > 
> > 
> > @@ -121,7 +124,7 @@
> > 
> > 
> > 
> >          @util.propertycache
> > 
> >          def track(self):
> > 
> > -            return self.configlist('blackbox', 'track', ['*'])
> > 
> > +            return self.configlist('blackbox', 'track')
> > 
> > 
> > 
> >          def log(self, event, *msg, **opts):
> > 
> >              global lastui
> > 
> > ___
> > 
> > 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] configitems: fix registration for 'blackbox.track' config

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507728357 -7200
#  Wed Oct 11 15:25:57 2017 +0200
# Node ID 0ae4811261aa53efb6372572dae546fdd98b8f58
# Parent  4a6a337f9c682bdf1659295f871dc43ff33677ca
# EXP-Topic config.fixup.blackbox
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
0ae4811261aa
configitems: fix registration for 'blackbox.track' config

Default mutable values could be problematic. Use a lambda that returns the
value instead.

Thanks to martin for catching this bug.

diff --git a/hgext/blackbox.py b/hgext/blackbox.py
--- a/hgext/blackbox.py
+++ b/hgext/blackbox.py
@@ -71,7 +71,7 @@
 default=False,
 )
 configitem('blackbox', 'track',
-default=['*'],
+default=lambda: ['*'],
 )
 
 lastui = None
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 10 of 11 V2] log: add obsfate by default in changeset printer

2017-10-11 Thread Yuya Nishihara
On Wed, 11 Oct 2017 14:09:56 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1507209918 -7200
> #  Thu Oct 05 15:25:18 2017 +0200
> # Node ID 79dd127e09281ca88332be9791016cf92936e4e8
> # Parent  4162251414fe06aec0bbe559a0262d8fdd49129a
> # EXP-Topic obsfatekeyword
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 79dd127e0928
> log: add obsfate by default in changeset printer

> +elif ctx.obsolete():
> +self.showobsfate(ctx)

Nit: could be marked as a private function.

> +def showobsfate(self, ctx):
> +obsfate = templatekw.showobsfate(repo=self.repo, ctx=ctx, ui=self.ui)
> +
> +if obsfate:
> +for obsfateline in obsfate:
> +self.ui.write(_("obsfate: %s\n") % obsfateline,
> +  label='log.obsfate')

Nit: please add '# i18n: column positioning for "hg log"' comment
(FWIW, I don't know how the word "obsfate" would be translated.)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 07 of 11 V2] ui: add the possibility to returns None as username in ui

2017-10-11 Thread Yuya Nishihara
On Wed, 11 Oct 2017 14:09:53 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1507299827 -7200
> #  Fri Oct 06 16:23:47 2017 +0200
> # Node ID b6b6cb2b16cb2c44b10113134e212bae5b47adb0
> # Parent  c6979350fac712aae8bd776553b3c7692a8136cf
> # EXP-Topic obsfatekeyword
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> b6b6cb2b16cb
> ui: add the possibility to returns None as username in ui
> 
> In a later patch we want to retrieve the current username or None if it isn't
> defined. Add the allowempty parameter instead of catching Abort.

Nit: s/allow/accept/ ?

> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -758,13 +758,15 @@
>  return feature not in exceptions
>  return True
>  
> -def username(self):
> +def username(self, acceptempty=False):
>  """Return default username to be used in commits.
>  
>  Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
>  and stop searching if one of these is set.
>  If not found and ui.askusername is True, ask the user, else use
>  ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
> +If no username could be found, raise an Abort error or returns None 
> if
> +acceptempty is True.
>  """
>  user = encoding.environ.get("HGUSER")
>  if user is None:
> @@ -782,6 +784,9 @@
>  except KeyError:
>  pass
>  if not user:
> +if acceptempty:
> +return user

Perhaps we'll need to suppress warning and prompt as well.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 04 of 11 V2] test: use current user in the multi-user amend scenario

2017-10-11 Thread Yuya Nishihara
On Wed, 11 Oct 2017 14:09:50 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1507530955 -7200
> #  Mon Oct 09 08:35:55 2017 +0200
> # Node ID 8447ccc2c5c91520ca75e6bbdc57100af8d0e931
> # Parent  30f0f979da9ca8adceaba48fddfb146f5b9cea78
> # EXP-Topic obsfatekeyword
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 8447ccc2c5c9
> test: use current user in the multi-user amend scenario

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


Re: [PATCH 05 of 11 V2] templatekw: introduce obsfate keyword

2017-10-11 Thread Yuya Nishihara
On Wed, 11 Oct 2017 14:09:51 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1507218176 -7200
> #  Thu Oct 05 17:42:56 2017 +0200
> # Node ID 34bb2af8638432dea3052eabd4b6eb12a1777e19
> # Parent  8447ccc2c5c91520ca75e6bbdc57100af8d0e931
> # EXP-Topic obsfatekeyword
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 34bb2af86384
> templatekw: introduce obsfate keyword

> +def obsfateprinter(successors, markers, ui):
> +""" Build a obsfate string for a single successorset using all obsfate
> +related function defined in obsutil
> +"""
> +line = []
> +
> +# Verb
> +line.append(successorsetverb(successors))
> +
> +# Operations
> +operations = markersoperations(markers)
> +if operations:
> +line.append(" using %s" % ", ".join(operations))
> +
> +# Successors
> +if successors:
> +fmtsuccessors = [successors.joinfmt(succ) for succ in successors]
> +line.append(" as %s" % ", ".join(fmtsuccessors))
> +
> +# Users
> +users = markersusers(markers)
> +
> +if users:
> +line.append(" by %s" % ", ".join(users))
> +
> +# Date
> +dates = markersdates(markers)
> +
> +min_date = min(dates)
> +max_date = max(dates)
> +
> +if min_date == max_date:
> +fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
> +line.append(" (at %s)" % fmtmin_date)
> +else:
> +fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
> +fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
> +line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
> +
> +return "".join(line)
> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -580,6 +580,19 @@
>  # rev and node are completely different from changeset's.
>  return _mappable(f, f, lambda: {'rev': mrev, 'node': mhex})
>  
> +@templatekeyword('obsfate')
> +def showobsfate(**args):
> +succsandmarkers = showsuccsandmarkers(**args)

Ugh, there's templatekw.defaulttempl which provides the default template
fragments to all stock/user templates. Maybe we can (ab)use it to define
the default '{obsfate}' template.

I'm so sorry I didn't mention it before. It totally slipped my mind.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 V3] strip: take branch into account when selecting update target (issue5540)

2017-10-11 Thread Yuya Nishihara
On Tue, 10 Oct 2017 11:44:43 +0200, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle 
> # Date 1507212785 -7200
> #  Thu Oct 05 16:13:05 2017 +0200
> # Node ID 7681cb8ad2b5bca779551e84676cd70d67366cdf
> # Parent  adaf1c0e81c0d4f1f9dcf5c98de4410e21d76966
> # EXP-Topic issue-5540
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> 7681cb8ad2b5
> strip: take branch into account when selecting update target (issue5540)
> 
> Test contributed by Matt Harbison
> 
> Keep the same behavior in most cases (i.e. first parent of the first root of
> stripped changsets), but if the branch differs from wdir's, try to find 
> another
> parent of stripped commits that is on the same branch.
> 
> diff -r adaf1c0e81c0 -r 7681cb8ad2b5 hgext/strip.py
> --- a/hgext/strip.py  Thu Oct 05 15:11:34 2017 +0200
> +++ b/hgext/strip.py  Thu Oct 05 16:13:05 2017 +0200
> @@ -60,10 +60,20 @@
>  
>  def _findupdatetarget(repo, nodes):
>  unode, p2 = repo.changelog.parents(nodes[0])
> +current_branch = repo[None].branch()

Nit: currentbranch per coding style.

>  if (util.safehasattr(repo, 'mq') and p2 != nullid
>  and p2 in [x.node for x in repo.mq.applied]):
>  unode = p2
> +elif current_branch != repo[unode].branch():
> +pwdir = 'parents(wdir())'
> +revset = ('max(((parents(%ln::{0}) + {0}) - %ln::{0})'
> +  ' and branch(%s))'
> + ).format(pwdir)

bytes.format() isn't available on Python 3. Instead, you can use %r to embed
a revset expression.

> +branch_target = repo.revs(revset, nodes, nodes, current_branch)
> +if branch_target:

Nit: s/branch_target/branchtarget/

> +cl = repo.changelog
> +unode = cl.node(branch_target.first())
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 1 of 2 V3] strip: factor out update target selection

2017-10-11 Thread Yuya Nishihara
On Tue, 10 Oct 2017 11:44:42 +0200, Paul Morelle wrote:
> # HG changeset patch
> # User Paul Morelle 
> # Date 1507209094 -7200
> #  Thu Oct 05 15:11:34 2017 +0200
> # Node ID adaf1c0e81c0d4f1f9dcf5c98de4410e21d76966
> # Parent  8cef8f7d51d0f1e99889779ec1320d5c9c3b91de
> # EXP-Topic issue-5540
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> adaf1c0e81c0
> strip: factor out update target selection

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


D1000: contrib: add check-code rule banning use of readlink

2017-10-11 Thread mitrandir (Mateusz Jakub Kwapich)
mitrandir added a comment.


  Wow, it's https://phab.mercurial-scm.org/D1000 :D
  partysnake 


REPOSITORY
  rHG Mercurial

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

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


[PATCH 09 of 11 V2] obsfate: only display date in verbose mode

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507556066 -7200
#  Mon Oct 09 15:34:26 2017 +0200
# Node ID 4162251414fe06aec0bbe559a0262d8fdd49129a
# Parent  0b833ca139b7afeaf63f38e2a06474b5a9699457
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
4162251414fe
obsfate: only display date in verbose mode

The date is also not that helpful in most cases but we show it in verbose mode.

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -822,15 +822,16 @@
 # Date
 dates = markersdates(markers)
 
-min_date = min(dates)
-max_date = max(dates)
+if verbose:
+min_date = min(dates)
+max_date = max(dates)
 
-if min_date == max_date:
-fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
-line.append(" (at %s)" % fmtmin_date)
-else:
-fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
-fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
-line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
+if min_date == max_date:
+fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
+line.append(" (at %s)" % fmtmin_date)
+else:
+fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
+fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
+line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
 
 return "".join(line)
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
@@ -100,7 +100,7 @@
   o  d004c8f274b9
   |
   | @  471f378eab4c
-  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2 
(between 2001-04-19 04:25 + and 2009-02-13 23:31 +)
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2
   o  ea207398892e
   
   $ hg up 'desc(A1)' --hidden
@@ -219,18 +219,18 @@
   @  d004c8f274b9
   |
   | x  a468dc9b3633
-  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 (at 2001-04-19 04:25 
+)
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9
   | x  471f378eab4c
-  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 (at 2009-02-13 23:31 
+)
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633
   o  ea207398892e
   
   $ hg fatelogkw --hidden
   @  d004c8f274b9
   |
   | x  a468dc9b3633
-  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2 (at 
2001-04-19 04:25 +)
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2
   | x  471f378eab4c
-  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 (at 2009-02-13 23:31 
+)
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633
   o  ea207398892e
   
   $ hg fatelogkw --hidden -v
@@ -394,7 +394,7 @@
   o  337fec4d2edc
   |
   | x  471597cad322
-  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a (at 1970-01-01 00:00 
+)
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a
   o  ea207398892e
   
   $ hg fatelogkw --hidden
@@ -403,7 +403,7 @@
   o  337fec4d2edc
   |
   | x  471597cad322
-  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a (at 1970-01-01 00:00 
+)
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a
   o  ea207398892e
   
   $ hg fatelogkw --hidden -v
@@ -594,18 +594,18 @@
   @  eb5a0daa2192
   |
   | x  0dec01379d3b
-  | |Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
+  | |Obsfate: rewritten as 3:eb5a0daa2192
   | x  471f378eab4c
-  |/ Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
+  |/ Obsfate: rewritten as 3:eb5a0daa2192
   o  ea207398892e
   
   $ hg fatelogkw --hidden
   @  eb5a0daa2192
   |
   | x  0dec01379d3b
-  | |Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
+  | |Obsfate: rewritten as 3:eb5a0daa2192
   | x  471f378eab4c
-  |/ Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
+  |/ Obsfate: rewritten as 3:eb5a0daa2192
   o  ea207398892e
   
   $ hg fatelogkw --hidden -v
@@ -824,24 +824,24 @@
   o  019fadeab383
   |
   | x  65b757b745b9
-  |/ Obsfate: rewritten using amend as 4:019fadeab383 (at 1970-01-01 00:00 
+)
+  |/ Obsfate: rewritten using amend as 4:019fadeab383
   | @  fdf9bde5129a
   |/
   | x  471f378eab4c
-  |/ Obsfate: rewritten using amend as 2:fdf9bde5129a (at 1970-01-01 00:00 
+)
-  |  Obsfate: rewritten using amend as 3:65b757b745b9 (at 1970-01-01 00:00 
+)
+  |/ Obsfate: rewritten using amend as 2:fdf9bde5129a
+  |  Obsfate: rewritten using amend as 3:65b757b745b9
   o  ea207398892e
   
   $ hg fatelogkw --hidden
   o  019fadeab383
   |
   | x  65b757b745b9
-  |/ Obsfate: rewritten using amend as 4:019fadeab383 (at 1970-01-01 00:00 
+)
+ 

[PATCH 08 of 11 V2] obsfate: filter out current user if not in verbose

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507556052 -7200
#  Mon Oct 09 15:34:12 2017 +0200
# Node ID 0b833ca139b7afeaf63f38e2a06474b5a9699457
# Parent  b6b6cb2b16cb2c44b10113134e212bae5b47adb0
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
0b833ca139b7
obsfate: filter out current user if not in verbose

Obsolescence is sometimes used only locally so the obs-marker users is always
the same. Showing the user in this case does not bring much values.

In the case where multiple users rewrite the commit, display the full list of
users. Also show all users in verbose mode.

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -788,6 +788,10 @@
 """ Build a obsfate string for a single successorset using all obsfate
 related function defined in obsutil
 """
+quiet = ui.quiet
+verbose = ui.verbose
+normal = not verbose and not quiet
+
 line = []
 
 # Verb
@@ -805,8 +809,14 @@
 
 # Users
 users = markersusers(markers)
+# Filter out current user in not verbose mode to reduce amount of
+# information
+if not verbose:
+currentuser = ui.username(acceptempty=True)
+if len(users) == 1 and currentuser in users:
+users = None
 
-if users:
+if (verbose or normal) and users:
 line.append(" by %s" % ", ".join(users))
 
 # Date
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
@@ -219,9 +219,9 @@
   @  d004c8f274b9
   |
   | x  a468dc9b3633
-  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2 (at 
2001-04-19 04:25 +)
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 (at 2001-04-19 04:25 
+)
   | x  471f378eab4c
-  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 
2009-02-13 23:31 +)
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 (at 2009-02-13 23:31 
+)
   o  ea207398892e
   
   $ hg fatelogkw --hidden
@@ -230,7 +230,7 @@
   | x  a468dc9b3633
   |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2 (at 
2001-04-19 04:25 +)
   | x  471f378eab4c
-  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 
2009-02-13 23:31 +)
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 (at 2009-02-13 23:31 
+)
   o  ea207398892e
   
   $ hg fatelogkw --hidden -v
@@ -394,7 +394,7 @@
   o  337fec4d2edc
   |
   | x  471597cad322
-  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 
1970-01-01 00:00 +)
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a (at 1970-01-01 00:00 
+)
   o  ea207398892e
   
   $ hg fatelogkw --hidden
@@ -403,7 +403,7 @@
   o  337fec4d2edc
   |
   | x  471597cad322
-  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 
1970-01-01 00:00 +)
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a (at 1970-01-01 00:00 
+)
   o  ea207398892e
   
   $ hg fatelogkw --hidden -v
@@ -594,18 +594,18 @@
   @  eb5a0daa2192
   |
   | x  0dec01379d3b
-  | |Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 
+)
+  | |Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
   | x  471f378eab4c
-  |/ Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 
+)
+  |/ Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
   o  ea207398892e
   
   $ hg fatelogkw --hidden
   @  eb5a0daa2192
   |
   | x  0dec01379d3b
-  | |Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 
+)
+  | |Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
   | x  471f378eab4c
-  |/ Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 
+)
+  |/ Obsfate: rewritten as 3:eb5a0daa2192 (at 1970-01-01 00:00 +)
   o  ea207398892e
   
   $ hg fatelogkw --hidden -v
@@ -824,24 +824,24 @@
   o  019fadeab383
   |
   | x  65b757b745b9
-  |/ Obsfate: rewritten using amend as 4:019fadeab383 by test (at 
1970-01-01 00:00 +)
+  |/ Obsfate: rewritten using amend as 4:019fadeab383 (at 1970-01-01 00:00 
+)
   | @  fdf9bde5129a
   |/
   | x  471f378eab4c
-  |/ Obsfate: rewritten using amend as 2:fdf9bde5129a by test (at 
1970-01-01 00:00 +)
-  |  Obsfate: rewritten using amend as 3:65b757b745b9 by test (at 
1970-01-01 00:00 +)
+  |/ Obsfate: rewritten using amend as 2:fdf9bde5129a (at 1970-01-01 00:00 
+)
+  |  Obsfate: rewritten using amend as 3:65b757b745b9 (at 1970-01-01 00:00 
+)
   o  ea207398892e
   
   $ hg fatelogkw --hidden
   o  019fadeab383
   |
   | x  65b757b745b9
-  |/ Obsfate: rewritten using amend as 4:019fadeab383 by test (at 
1970-01-01 00:00 +)
+  |/ Obsfate: rewritten using amend as 

[PATCH 10 of 11 V2] log: add obsfate by default in changeset printer

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507209918 -7200
#  Thu Oct 05 15:25:18 2017 +0200
# Node ID 79dd127e09281ca88332be9791016cf92936e4e8
# Parent  4162251414fe06aec0bbe559a0262d8fdd49129a
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
79dd127e0928
log: add obsfate by default in changeset printer

Having an obsfate by default in log will be useful for users to understand why
they have obsolete and unstable changesets. Obsfate will only be shown for
obsolete changesets, which only happens if people opt-in to experimental 
feature.

But when obsolete changeset are visible, it is very useful to understand where
they are. Having it in log could be sufficient for most people, so they don't
have to learn a new command (like obslog which is itself useful in case of
divergences).

For example, when pulling and working directory parent become obsolete:

  $ hg pull
  ...
  working directory parent is obsolete! (f936c1697205)

This message comes from the Evolve extension.

Obsfate would comes handy:

  $ hg log -G
  o  changeset:   2:6f91013c5136
  |  tag: tip
  |  parent:  0:4ef7b558f3ec
  |  user:Boris Feld 
  |  date:Mon Oct 09 16:00:27 2017 +0200
  |  summary: A
  |
  | @  changeset:   1:f936c1697205
  |/   user:Boris Feld 
  |date:Mon Oct 09 16:00:27 2017 +0200
  |obsfate: rewritten using amend as 2:6f91013c5136
  |summary: -A
  |
  o  changeset:   0:feb4dd822b8c
 user:Boris Feld 
 date:Tue Oct 09 16:00:00 2017 +0200
 summary: ROOT

And once we update, we don't have an obsolete changeset in the log anymore so
we don't show obsfate anymore, most users won't see obsfate often if they
don't have obsolete changeset often:

  @  changeset:   2:6f91013c5136
  |  tag: tip
  |  parent:  0:4ef7b558f3ec
  |  user:Boris Feld 
  |  date:Mon Oct 09 16:00:27 2017 +0200
  |  summary: A
  |
  o  changeset:   0:feb4dd822b8c
 user:Boris Feld 
 date:Tue Oct 09 16:00:00 2017 +0200
 summary: ROOT

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1684,6 +1684,9 @@
 self.ui.write(_("instability: %s\n") % ', '.join(instabilities),
   label='log.instability')
 
+elif ctx.obsolete():
+self.showobsfate(ctx)
+
 self._exthook(ctx)
 
 if self.ui.debugflag:
@@ -1732,6 +1735,14 @@
 
 self.showpatch(ctx, matchfn)
 
+def showobsfate(self, ctx):
+obsfate = templatekw.showobsfate(repo=self.repo, ctx=ctx, ui=self.ui)
+
+if obsfate:
+for obsfateline in obsfate:
+self.ui.write(_("obsfate: %s\n") % obsfateline,
+  label='log.obsfate')
+
 def _exthook(self, ctx):
 '''empty method used by extension as a hook point
 '''
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -535,6 +535,7 @@
   tag: tip
   user:test
   date:Thu Jan 01 00:00:00 1970 +
+  obsfate: pruned
   summary: .
   
   changeset:   0:eff892de26ec
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
@@ -58,11 +58,13 @@
   |/   parent:  0:ea207398892e
   |user:test
   |date:Thu Jan 01 00:00:00 1970 +
+  |obsfate: rewritten using amend as 3:d004c8f274b9 by test2
   |summary: A1
   |
   | x  changeset:   1:471f378eab4c
   |/   user:test
   |date:Thu Jan 01 00:00:00 1970 +
+  |obsfate: rewritten using amend as 2:a468dc9b3633
   |summary: A0
   |
   o  changeset:   0:ea207398892e
@@ -103,6 +105,26 @@
   |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2
   o  ea207398892e
   
+
+  $ hg log -G --config ui.logtemplate=
+  o  changeset:   3:d004c8f274b9
+  |  tag: tip
+  |  parent:  0:ea207398892e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: A2
+  |
+  | @  changeset:   1:471f378eab4c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsfate: rewritten using amend as 3:d004c8f274b9 by test2
+  |summary: A0
+  |
+  o  changeset:   0:ea207398892e
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: ROOT
+  
   $ hg up 'desc(A1)' --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -294,6 +316,7 @@
   | x  changeset:   

[PATCH 11 of 11 V2] obsfate: add obsfate to default mapfile

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507305216 -7200
#  Fri Oct 06 17:53:36 2017 +0200
# Node ID 8961471c54fcabd92a8568adb563f02c2475fe0f
# Parent  79dd127e09281ca88332be9791016cf92936e4e8
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
8961471c54fc
obsfate: add obsfate to default mapfile

Use the verbosity aware template keyword introduced earlier. It has the nice
property of being verbosity dependent but in order to customize the obsfate
part, users will need to replace the lobsfate definition from default mapfile
with the one using template functions (by copying the one from test-obsmarker-
template.t for example).

As it's a more advanced use-case, I'm more inclined to have the same code for
the {obsfate} keyword, in the changeset printer and in the default mapfile for
consistency.

But, the definition in default mapfile could be replaced with one based on
template filter to obsfate output customization if it is a big need for users.

diff --git a/mercurial/templates/map-cmdline.default 
b/mercurial/templates/map-cmdline.default
--- a/mercurial/templates/map-cmdline.default
+++ b/mercurial/templates/map-cmdline.default
@@ -1,9 +1,9 @@
 # Base templates. Due to name clashes with existing keywords, we have
 # to replace some keywords with 'lkeyword', for 'labelled keyword'
-changeset = 
'{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{summary}\n'
+changeset = 
'{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lobsfate}{summary}\n'
 changeset_quiet = '{lnode}'
-changeset_verbose = 
'{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lfiles}{lfile_copies_switch}{description}\n'
-changeset_debug = 
'{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{ltroubles}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n'
+changeset_verbose = 
'{cset}{branches}{bookmarks}{tags}{parents}{user}{ldate}{ltroubles}{lobsfate}{lfiles}{lfile_copies_switch}{description}\n'
+changeset_debug = 
'{fullcset}{branches}{bookmarks}{tags}{lphase}{parents}{manifest}{user}{ldate}{ltroubles}{lobsfate}{lfile_mods}{lfile_adds}{lfile_dels}{lfile_copies_switch}{extras}{description}\n'
 
 # File templates
 lfiles = '{if(files,
@@ -80,3 +80,6 @@
'{desc|strip}')}\n\n")}'
 
 status = '{status} {path}\n{if(copy, "  {copy}\n")}'
+
+# Obsfate templates
+lobsfate = '{if(obsfate, "{label('log.obsfate', '{obsfate % "obsfate: 
{fate}\n"}')}")}'
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
@@ -117,7 +117,27 @@
   | @  changeset:   1:471f378eab4c
   |/   user:test
   |date:Thu Jan 01 00:00:00 1970 +
-  |obsfate: rewritten using amend as 3:d004c8f274b9 by test2
+  |obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2
+  |summary: A0
+  |
+  o  changeset:   0:ea207398892e
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: ROOT
+  
+
+  $ hg log -G -T "default"
+  o  changeset:   3:d004c8f274b9
+  |  tag: tip
+  |  parent:  0:ea207398892e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: A2
+  |
+  | @  changeset:   1:471f378eab4c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2
   |summary: A0
   |
   o  changeset:   0:ea207398892e
@@ -264,6 +284,71 @@
   |/ Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 
2009-02-13 23:31 +)
   o  ea207398892e
   
+
+  $ hg log -G -T "default" --hidden
+  @  changeset:   3:d004c8f274b9
+  |  tag: tip
+  |  parent:  0:ea207398892e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  summary: A2
+  |
+  | x  changeset:   2:a468dc9b3633
+  |/   parent:  0:ea207398892e
+  |user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsfate: rewritten using amend as 3:d004c8f274b9 by test2
+  |summary: A1
+  |
+  | x  changeset:   1:471f378eab4c
+  |/   user:test
+  |date:Thu Jan 01 00:00:00 1970 +
+  |obsfate: rewritten using amend as 2:a468dc9b3633
+  |summary: A0
+  |
+  o  changeset:   0:ea207398892e
+ user:test
+ date:Thu Jan 01 00:00:00 1970 +
+ summary: ROOT
+  
+  $ hg log -G -T "default" --hidden -v
+  @  changeset:   3:d004c8f274b9
+  |  tag: tip
+  |  parent:  0:ea207398892e
+  |  user:test
+  |  date:Thu Jan 01 00:00:00 1970 +
+  |  files:   A0
+  |  description:
+  |  A2
+  |
+  |
+  | x  changeset:   2:a468dc9b3633
+  |/   

[PATCH 03 of 11 V2] test: cleanup verbosity variant from fatelog test

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507302319 -7200
#  Fri Oct 06 17:05:19 2017 +0200
# Node ID 30f0f979da9ca8adceaba48fddfb146f5b9cea78
# Parent  be07c4e68161b95e9a083ec940f3b02d494edda7
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
30f0f979da9c
test: cleanup verbosity variant from fatelog test

Unlike the '{obsfate}' keyword defined in 'hg-evolve', the definition of hg
fatelog in test-obsmarker-template.t is not verbosity dependent. Remove useless
call to fatelog -v and fatelog -q.

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
@@ -87,13 +87,6 @@
   |  json: [["d004c8f274b9ec480a47a93c10dac5eee63adb78"]]
   o  ea207398892e
   
-  $ hg fatelog -q --traceback
-  o  d004c8f274b9
-  |
-  | @  471f378eab4c
-  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test1, test2 
(between 2001-04-19 04:25 + and 2009-02-13 23:31 +);
-  o  ea207398892e
-  
   $ hg fatelog
   o  d004c8f274b9
   |
@@ -101,13 +94,6 @@
   |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test1, test2 
(between 2001-04-19 04:25 + and 2009-02-13 23:31 +);
   o  ea207398892e
   
-  $ hg fatelog -v
-  o  d004c8f274b9
-  |
-  | @  471f378eab4c
-  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test1, test2 
(between 2001-04-19 04:25 + and 2009-02-13 23:31 +);
-  o  ea207398892e
-  
   $ hg up 'desc(A1)' --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -124,7 +110,7 @@
   |  json: [["d004c8f274b9ec480a47a93c10dac5eee63adb78"]]
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fatelog
   o  d004c8f274b9
   |
   | @  a468dc9b3633
@@ -153,7 +139,7 @@
   |  json: [["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]]
   o  ea207398892e
   
-  $ hg fatelog --hidden -q
+  $ hg fatelog --hidden
   o  d004c8f274b9
   |
   | @  a468dc9b3633
@@ -192,13 +178,13 @@
   |  json: [["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]]
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fatelog
   @  d004c8f274b9
   |
   o  ea207398892e
   
 
-  $ hg fatelog -v --hidden
+  $ hg fatelog --hidden
   @  d004c8f274b9
   |
   | x  a468dc9b3633
@@ -1624,11 +1610,6 @@
   |Obsfate: pruned by test (at 1970-01-01 00:00 +);
   o  ea207398892e
   
-  $ hg fatelog -v
-  @  471f378eab4c
-  |Obsfate: pruned by test (at 1970-01-01 00:00 +);
-  o  ea207398892e
-  
 Test templates with multiple pruned commits
 ===
 
@@ -1665,7 +1646,7 @@
   |Obsfate: pruned;
   o  ea207398892e
   
-  $ hg fatelog -v --hidden
+  $ hg fatelog --hidden
   x  65b757b745b9
   |Obsfate: pruned by test (at 1970-01-01 00:00 +);
   | x  fdf9bde5129a
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 07 of 11 V2] ui: add the possibility to returns None as username in ui

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507299827 -7200
#  Fri Oct 06 16:23:47 2017 +0200
# Node ID b6b6cb2b16cb2c44b10113134e212bae5b47adb0
# Parent  c6979350fac712aae8bd776553b3c7692a8136cf
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
b6b6cb2b16cb
ui: add the possibility to returns None as username in ui

In a later patch we want to retrieve the current username or None if it isn't
defined. Add the allowempty parameter instead of catching Abort.

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -758,13 +758,15 @@
 return feature not in exceptions
 return True
 
-def username(self):
+def username(self, acceptempty=False):
 """Return default username to be used in commits.
 
 Searched in this order: $HGUSER, [ui] section of hgrcs, $EMAIL
 and stop searching if one of these is set.
 If not found and ui.askusername is True, ask the user, else use
 ($LOGNAME or $USER or $LNAME or $USERNAME) + "@full.hostname".
+If no username could be found, raise an Abort error or returns None if
+acceptempty is True.
 """
 user = encoding.environ.get("HGUSER")
 if user is None:
@@ -782,6 +784,9 @@
 except KeyError:
 pass
 if not user:
+if acceptempty:
+return user
+
 raise error.Abort(_('no username supplied'),
  hint=_("use 'hg config --edit' "
 'to set your username'))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 05 of 11 V2] templatekw: introduce obsfate keyword

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507218176 -7200
#  Thu Oct 05 17:42:56 2017 +0200
# Node ID 34bb2af8638432dea3052eabd4b6eb12a1777e19
# Parent  8447ccc2c5c91520ca75e6bbdc57100af8d0e931
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
34bb2af86384
templatekw: introduce obsfate keyword

Introduce an obsfate printer that uses all helpers functions defined in
obsutil to get all the obsfate-related data and format a string according to
the current format in test-obsmarker-template.t.

Then, introduce an obsfate templatekw that uses the obsfateprinter to return a
list of strings.

The goal is not to replace existing obsfate template functions but to propose
a default, good-enough and easily usable obsfate definition for end-users that
don't want to customize it. Such output would ultimately get included in the
default log output.

Here are some output examples for a commit amended:

rewritten using amend as 5:a9b1f8652753 by test (at 1970-01-01 00:00 +)

Next patches will make the output dependent on the verbosity.

Exemple of use-cases:

For having the obsfate on a single-line between brackets:

  {if(obsfate, " [{join(obsfate, "; ")}]")}

For having the obsfate in several lines:

  {if(obsfate, "{obsfate % "  Obsfate: {fate}\n"}")}

diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -783,3 +783,44 @@
  if meta.get('operation'))
 
 return sorted(operations)
+
+def obsfateprinter(successors, markers, ui):
+""" Build a obsfate string for a single successorset using all obsfate
+related function defined in obsutil
+"""
+line = []
+
+# Verb
+line.append(successorsetverb(successors))
+
+# Operations
+operations = markersoperations(markers)
+if operations:
+line.append(" using %s" % ", ".join(operations))
+
+# Successors
+if successors:
+fmtsuccessors = [successors.joinfmt(succ) for succ in successors]
+line.append(" as %s" % ", ".join(fmtsuccessors))
+
+# Users
+users = markersusers(markers)
+
+if users:
+line.append(" by %s" % ", ".join(users))
+
+# Date
+dates = markersdates(markers)
+
+min_date = min(dates)
+max_date = max(dates)
+
+if min_date == max_date:
+fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
+line.append(" (at %s)" % fmtmin_date)
+else:
+fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
+fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
+line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
+
+return "".join(line)
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -580,6 +580,19 @@
 # rev and node are completely different from changeset's.
 return _mappable(f, f, lambda: {'rev': mrev, 'node': mhex})
 
+@templatekeyword('obsfate')
+def showobsfate(**args):
+succsandmarkers = showsuccsandmarkers(**args)
+
+ui = args['ui']
+
+values = []
+
+for x in succsandmarkers:
+values.append(obsutil.obsfateprinter(x['successors'], x['markers'], 
ui))
+
+return showlist("fate", values, args)
+
 def shownames(namespace, **args):
 """helper method to generate a template keyword for a namespace"""
 args = pycompat.byteskwargs(args)
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -7,7 +7,7 @@
 
   $ cat >> $HGRCPATH << EOF
   > [ui]
-  > logtemplate = {rev}:{node|short} {desc}\n
+  > logtemplate = {rev}:{node|short} {desc}{if(obsfate, " [{join(obsfate, "; 
")}]")}\n
   > [experimental]
   > stabilization=createmarkers
   > [extensions]
@@ -66,7 +66,7 @@
   |
   | o  2:82623d38b9ba A_1
   |/
-  | x  1:007dc284c1f8 A_0
+  | x  1:007dc284c1f8 A_0 [rewritten as 2:82623d38b9ba by test (at 1970-01-01 
00:00 +); rewritten as 3:392fd25390da by test (at 1970-01-01 00:00 +)]
   |/
   @  0:d20a80d4def3 base
   
@@ -127,11 +127,11 @@
   $ hg log -G --hidden
   @  4:01f36c5a8fda A_3
   |
-  | x  3:392fd25390da A_2
+  | x  3:392fd25390da A_2 [rewritten as 4:01f36c5a8fda by test (at 1970-01-01 
00:00 +)]
   |/
   | o  2:82623d38b9ba A_1
   |/
-  | x  1:007dc284c1f8 A_0
+  | x  1:007dc284c1f8 A_0 [rewritten as 2:82623d38b9ba by test (at 1970-01-01 
00:00 +); rewritten as 3:392fd25390da by test (at 1970-01-01 00:00 +)]
   |/
   o  0:d20a80d4def3 base
   
@@ -185,7 +185,7 @@
   |
   | o  2:82623d38b9ba A_1
   |/
-  | x  1:007dc284c1f8 A_0
+  | x  1:007dc284c1f8 A_0 [rewritten as 2:82623d38b9ba by test (at 1970-01-01 
00:00 +); rewritten as 3:392fd25390da by test (at 1970-01-01 00:00 +)]
   |/
   @  0:d20a80d4def3 base
   
@@ -259,11 +259,11 @@
 

[PATCH 06 of 11 V2] test: test obfate template keyword in test-obsmarker-template.t

2017-10-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1507302949 -7200
#  Fri Oct 06 17:15:49 2017 +0200
# Node ID c6979350fac712aae8bd776553b3c7692a8136cf
# Parent  34bb2af8638432dea3052eabd4b6eb12a1777e19
# EXP-Topic obsfatekeyword
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
c6979350fac7
test: test obfate template keyword in test-obsmarker-template.t

These test updates are pretty big by themselves so put it in a separate patch
for easing the review process.

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
@@ -29,6 +29,7 @@
   > {if(successorssets, "\n  json: {successorssets|json}")}\n'
   > fatelog = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: 
{succsandmarkers % "{obsfatetempl}"} \n" )}'
   > fatelogjson = log -G -T '{node|short}\n{if(succsandmarkers, "  Obsfate: 
{succsandmarkers|json}\n")}'
+  > fatelogkw = log -G -T '{node|short}\n{if(obsfate, "{obsfate % "  Obsfate: 
{fate}\n"}")}'
   > EOF
 
 Test templates on amended commit
@@ -94,6 +95,14 @@
   |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2 
(between 2001-04-19 04:25 + and 2009-02-13 23:31 +);
   o  ea207398892e
   
+
+  $ hg fatelogkw
+  o  d004c8f274b9
+  |
+  | @  471f378eab4c
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2 
(between 2001-04-19 04:25 + and 2009-02-13 23:31 +)
+  o  ea207398892e
+  
   $ hg up 'desc(A1)' --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
@@ -202,6 +211,37 @@
   |/ Obsfate: [{"markers": [["471f378eab4c5e25f6c77f785b27c936efb22874", 
["a468dc9b36338b14fdb7825f55ce3df4e71517ad"], 0, [["operation", "amend"], 
["user", "test"]], [1234567890.0, 0], null]], "successors": 
["a468dc9b36338b14fdb7825f55ce3df4e71517ad"]}]
   o  ea207398892e
   
+
+Check other fatelog implementations
+---
+
+  $ hg fatelogkw --hidden -q
+  @  d004c8f274b9
+  |
+  | x  a468dc9b3633
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2 (at 
2001-04-19 04:25 +)
+  | x  471f378eab4c
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 
2009-02-13 23:31 +)
+  o  ea207398892e
+  
+  $ hg fatelogkw --hidden
+  @  d004c8f274b9
+  |
+  | x  a468dc9b3633
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2 (at 
2001-04-19 04:25 +)
+  | x  471f378eab4c
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 
2009-02-13 23:31 +)
+  o  ea207398892e
+  
+  $ hg fatelogkw --hidden -v
+  @  d004c8f274b9
+  |
+  | x  a468dc9b3633
+  |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test2 (at 
2001-04-19 04:25 +)
+  | x  471f378eab4c
+  |/ Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 
2009-02-13 23:31 +)
+  o  ea207398892e
+  
 Test templates with splitted commit
 ===
 
@@ -345,6 +385,37 @@
   |/ Obsfate: [{"markers": [["471597cad322d1f659bb169751be9133dad92ef3", 
["337fec4d2edcf0e7a467e35f818234bc620068b5", 
"f257fde29c7a847c9b607f6e958656d0df0fb15c"], 0, [["user", "test"]], [0.0, 0], 
null]], "successors": ["337fec4d2edcf0e7a467e35f818234bc620068b5", 
"f257fde29c7a847c9b607f6e958656d0df0fb15c"]}]
   o  ea207398892e
   
+Check other fatelog implementations
+---
+
+  $ hg fatelogkw --hidden -q
+  @  f257fde29c7a
+  |
+  o  337fec4d2edc
+  |
+  | x  471597cad322
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 
1970-01-01 00:00 +)
+  o  ea207398892e
+  
+  $ hg fatelogkw --hidden
+  @  f257fde29c7a
+  |
+  o  337fec4d2edc
+  |
+  | x  471597cad322
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 
1970-01-01 00:00 +)
+  o  ea207398892e
+  
+  $ hg fatelogkw --hidden -v
+  @  f257fde29c7a
+  |
+  o  337fec4d2edc
+  |
+  | x  471597cad322
+  |/ Obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a by test (at 
1970-01-01 00:00 +)
+  o  ea207398892e
+  
+
 Test templates with folded commit
 =
 
@@ -516,6 +587,36 @@
   |/ Obsfate: [{"markers": [["471f378eab4c5e25f6c77f785b27c936efb22874", 
["eb5a0daa21923bbf8caeb2c42085b9e463861fd0"], 0, [["user", "test"]], [0.0, 0], 
null]], "successors": ["eb5a0daa21923bbf8caeb2c42085b9e463861fd0"]}]
   o  ea207398892e
   
+Check other fatelog implementations
+---
+
+  $ hg fatelogkw --hidden -q
+  @  eb5a0daa2192
+  |
+  | x  0dec01379d3b
+  | |Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 
+)
+  | x  471f378eab4c
+  |/ Obsfate: rewritten as 3:eb5a0daa2192 by test (at 1970-01-01 00:00 
+)
+  o  ea207398892e
+  
+  $ hg fatelogkw --hidden
+  @  eb5a0daa2192
+  |
+  | x  0dec01379d3b
+  | |Obsfate: rewritten as 

D999: tests: use readlink.py instead of readlink

2017-10-11 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd6d10771950c: tests: use readlink.py instead of readlink 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D999?vs=2565=2582

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

AFFECTED FILES
  tests/test-pathconflicts-update.t

CHANGE DETAILS

diff --git a/tests/test-pathconflicts-update.t 
b/tests/test-pathconflicts-update.t
--- a/tests/test-pathconflicts-update.t
+++ b/tests/test-pathconflicts-update.t
@@ -59,8 +59,8 @@
   a/b: replacing untracked file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark dir)
-  $ readlink a/b.orig
-  x
+  $ readlink.py a/b.orig
+  a/b.orig -> x
   $ rm a/b.orig
 
 Update - local directory conflicts with remote file
@@ -94,8 +94,8 @@
   a/b: replacing untracked files in directory
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark link)
-  $ readlink a/b
-  c
+  $ readlink.py a/b
+  a/b -> c
   $ test -d a/b.orig
   $ rm -rf a/b.orig
 



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


D996: tests: use readlink.py instead of readlink

2017-10-11 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe304fd82c718: tests: use readlink.py instead of readlink 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D996?vs=2562=2579

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

AFFECTED FILES
  tests/test-convert-p4-filetypes.t

CHANGE DETAILS

diff --git a/tests/test-convert-p4-filetypes.t 
b/tests/test-convert-p4-filetypes.t
--- a/tests/test-convert-p4-filetypes.t
+++ b/tests/test-convert-p4-filetypes.t
@@ -746,10 +746,10 @@
   $Header$$Header$Header$
 
 crazy_symlink
-  $ readlink crazy_symlink+k
-  target_$Header: //depot/test-mercurial-import/crazy_symlink+k#1 $
-  $ readlink dst/crazy_symlink+k
-  target_$Header$
+  $ readlink.py crazy_symlink+k
+  crazy_symlink+k -> target_$Header: 
//depot/test-mercurial-import/crazy_symlink+k#1 $
+  $ readlink.py dst/crazy_symlink+k
+  dst/crazy_symlink+k -> target_$Header$
 
 exit trap:
   stopping the p4 server



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


D998: tests: use readlink.py instead of readlink

2017-10-11 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG75bd034a1e00: tests: use readlink.py instead of readlink 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D998?vs=2564=2581

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

AFFECTED FILES
  tests/test-pathconflicts-merge.t

CHANGE DETAILS

diff --git a/tests/test-pathconflicts-merge.t b/tests/test-pathconflicts-merge.t
--- a/tests/test-pathconflicts-merge.t
+++ b/tests/test-pathconflicts-merge.t
@@ -121,8 +121,8 @@
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to 
abandon
   [1]
   $ hg mv a/b~2ea68033e3be a/b.old
-  $ readlink a/b.old
-  c
+  $ readlink.py a/b.old
+  a/b.old -> c
   $ hg resolve --mark a/b
   (no more unresolved files)
   $ hg commit -m "merge link (rename link)"



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


D997: tests: use readlink.py instead of readlink

2017-10-11 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGdbb2027f4974: tests: use readlink.py instead of readlink 
(authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D997?vs=2563=2580

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

AFFECTED FILES
  tests/test-origbackup-conflict.t

CHANGE DETAILS

diff --git a/tests/test-origbackup-conflict.t b/tests/test-origbackup-conflict.t
--- a/tests/test-origbackup-conflict.t
+++ b/tests/test-origbackup-conflict.t
@@ -80,8 +80,8 @@
   b: replacing untracked file
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark b1)
-  $ readlink .hg/origbackups/b
-  ../../../sym-link-target
+  $ readlink.py .hg/origbackups/b
+  .hg/origbackups/b -> ../../../sym-link-target
 
 Perform an update that causes b/c to be backed up again - it should not go 
into the target dir
 



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


D1000: contrib: add check-code rule banning use of readlink

2017-10-11 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGac80a8d105ec: contrib: add check-code rule banning use of 
readlink (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1000?vs=2566=2578

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

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -203,6 +203,7 @@
  'use test -f to test for file existence'),
 (r'^  diff -[^ -]*p',
  "don't use (external) diff with -p for portability"),
+(r' readlink ', 'use readlink.py instead of readlink'),
 (r'^  [-+][-+][-+] .* [-+] \(glob\)',
  "glob timezone field in diff output for portability"),
 (r'^  @@ -[0-9]+ [+][0-9]+,[0-9]+ @@',



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


D1001: ui: recommend tweakdefaults in the default hgrc template

2017-10-11 Thread durin42 (Augie Fackler)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG63c19b7fa100: ui: recommend tweakdefaults in the default 
hgrc template (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1001?vs=2567=2577

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

AFFECTED FILES
  mercurial/ui.py

CHANGE DETAILS

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -66,6 +66,11 @@
 # username = Jane Doe 
 username =
 
+# We recommend enabling tweakdefaults to get slight improvements to
+# the UI over time. Make sure to set HGPLAIN in the environment when
+# writing scripts!
+# tweakdefaults = True
+
 # uncomment to disable color in command output
 # (see 'hg help color' for details)
 # color = never



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


D1000: contrib: add check-code rule banning use of readlink

2017-10-11 Thread ryanmce (Ryan McElroy)
ryanmce accepted this revision.
ryanmce added a comment.
This revision is now accepted and ready to land.


  queued

REPOSITORY
  rHG Mercurial

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

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


D1001: ui: recommend tweakdefaults in the default hgrc template

2017-10-11 Thread ryanmce (Ryan McElroy)
ryanmce added a comment.


  queued

REPOSITORY
  rHG Mercurial

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

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


D1001: ui: recommend tweakdefaults in the default hgrc template

2017-10-11 Thread ryanmce (Ryan McElroy)
ryanmce accepted this revision.
ryanmce added a comment.
This revision is now accepted and ready to land.


  yay!

REPOSITORY
  rHG Mercurial

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

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


D990: dispatch: when --pager=no is passed, also disable pager on req.repo.ui

2017-10-11 Thread lothiraldan (Boris Feld)
lothiraldan accepted this revision.
lothiraldan added a comment.


  LGTM, I was wondering if lui was special and if we should disable its pager 
or not.

REPOSITORY
  rHG Mercurial

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

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


mercurial@34529: 21 new changesets

2017-10-11 Thread Mercurial Commits
21 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/e21f274cccea
changeset:   34509:e21f274cccea
user:Augie Fackler 
date:Thu Oct 05 14:12:51 2017 -0400
summary: hgweb: in protocol adapter, avoid control reaching end of non-void 
function

https://www.mercurial-scm.org/repo/hg/rev/c23fa3103925
changeset:   34510:c23fa3103925
user:Augie Fackler 
date:Thu Oct 05 14:13:20 2017 -0400
summary: hgweb: in protocol adapter, look for bytes instances, not str

https://www.mercurial-scm.org/repo/hg/rev/67873ec0f4ce
changeset:   34511:67873ec0f4ce
user:Augie Fackler 
date:Thu Oct 05 14:17:50 2017 -0400
summary: hgweb: produce native string for etag value

https://www.mercurial-scm.org/repo/hg/rev/482d6f6dba91
changeset:   34512:482d6f6dba91
user:Augie Fackler 
date:Thu Oct 05 14:22:02 2017 -0400
summary: hgweb: when constructing or adding to a wsgi environ dict, use 
native strs

https://www.mercurial-scm.org/repo/hg/rev/34fcb0f66837
changeset:   34513:34fcb0f66837
user:Augie Fackler 
date:Thu Oct 05 14:26:09 2017 -0400
summary: request: use trivial iterator over dictionary keys

https://www.mercurial-scm.org/repo/hg/rev/528b21b853aa
changeset:   34514:528b21b853aa
user:Augie Fackler 
date:Thu Oct 05 14:27:21 2017 -0400
summary: request: coerce content-type to native str

https://www.mercurial-scm.org/repo/hg/rev/8afc25e7effc
changeset:   34515:8afc25e7effc
user:Augie Fackler 
date:Thu Oct 05 14:29:13 2017 -0400
summary: hgweb: extract function for loading style from request context

https://www.mercurial-scm.org/repo/hg/rev/e79b3611223b
changeset:   34516:e79b3611223b
user:Pulkit Goyal <7895pul...@gmail.com>
date:Sun Oct 08 04:39:42 2017 +0530
summary: copies: add docs for config 
`experimental.copytrace.sourcecommitlimit`

https://www.mercurial-scm.org/repo/hg/rev/49b72b6f6d66
changeset:   34517:49b72b6f6d66
user:Boris Feld 
date:Sun Oct 08 20:11:34 2017 +0200
summary: configitems: register the 'blackbox.track' config

https://www.mercurial-scm.org/repo/hg/rev/592a3cc1ebc4
changeset:   34518:592a3cc1ebc4
user:Boris Feld 
date:Sun Oct 08 20:16:09 2017 +0200
summary: configitems: register the 'commands.show.aliasprefix' config

https://www.mercurial-scm.org/repo/hg/rev/0314e02efa25
changeset:   34519:0314e02efa25
user:Boris Feld 
date:Sun Oct 08 20:42:19 2017 +0200
summary: configitems: register the 'experimental.maxdeltachainspan' config

https://www.mercurial-scm.org/repo/hg/rev/ca5b833ce756
changeset:   34520:ca5b833ce756
user:Boris Feld 
date:Sun Oct 08 20:43:46 2017 +0200
summary: configitems: register the 'experimental.mmapindexthreshold' config

https://www.mercurial-scm.org/repo/hg/rev/aacb17cc0ee4
changeset:   34521:aacb17cc0ee4
user:Boris Feld 
date:Sun Oct 08 21:47:14 2017 +0200
summary: configitems: register the 'diff.*' config

https://www.mercurial-scm.org/repo/hg/rev/bed1d2eaa108
changeset:   34522:bed1d2eaa108
user:Boris Feld 
date:Sun Oct 08 21:48:40 2017 +0200
summary: configitems: register 'merge.checkunknown' and 'merge.checkignored'

https://www.mercurial-scm.org/repo/hg/rev/486dbd6afa57
changeset:   34523:486dbd6afa57
user:Boris Feld 
date:Sun Oct 08 21:41:10 2017 +0200
summary: configitems: register the 'devel.warn-config' config

https://www.mercurial-scm.org/repo/hg/rev/99c5922b1641
changeset:   34524:99c5922b1641
user:Boris Feld 
date:Sun Oct 08 21:36:26 2017 +0200
summary: configitems: register the 'devel.warn-config-default' config

https://www.mercurial-scm.org/repo/hg/rev/100f0ddb029b
changeset:   34525:100f0ddb029b
user:Boris Feld 
date:Sun Oct 08 21:41:22 2017 +0200
summary: configitems: register the 'devel.cache-vfs' config

https://www.mercurial-scm.org/repo/hg/rev/3999b74b6765
changeset:   34526:3999b74b6765
user:Boris Feld 
date:Sun Oct 08 21:41:37 2017 +0200
summary: configitems: register the 'devel.empty-changegroup' config

https://www.mercurial-scm.org/repo/hg/rev/d5362671993b
changeset:   34527:d5362671993b
user:Boris Feld 
date:Sun Oct 08 22:06:35 2017 +0200
summary: configitems: register the 'experimental.graphstyle.parent' config

https://www.mercurial-scm.org/repo/hg/rev/23783463d720
changeset:   34528:23783463d720
user:Boris Feld 
date:Sun Oct 08 22:07:21 

Re: [PATCH 01 of 13] configitems: register the 'blackbox.track' config

2017-10-11 Thread Martin von Zweigbergk via Mercurial-devel
On Mon, Oct 9, 2017 at 1:21 AM, Boris Feld  wrote:

> # HG changeset patch
> # User Boris Feld 
> # Date 1507486294 -7200
> #  Sun Oct 08 20:11:34 2017 +0200
> # Node ID cdac8099d6c07e3d96e1c7c8fadab713f2111bd7
> # Parent  8cef8f7d51d0f1e99889779ec1320d5c9c3b91de
> # EXP-Topic config.register
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> cdac8099d6c0
> configitems: register the 'blackbox.track' config
>
> diff -r 8cef8f7d51d0 -r cdac8099d6c0 hgext/blackbox.py
> --- a/hgext/blackbox.py Thu Oct 05 20:41:50 2017 -0700
> +++ b/hgext/blackbox.py Sun Oct 08 20:11:34 2017 +0200
> @@ -70,6 +70,9 @@
>  configitem('blackbox', 'logsource',
>  default=False,
>  )
> +configitem('blackbox', 'track',
> +default=['*'],
> +)
>

Should not use mutable value as default. See 77e666f943a6 (configitems:
support callable as a default value, 2017-06-28). Right?

The patch is pretty deep in the stack of queued commits, so I'll accept,
but please send a followup.


>  lastui = None
>
> @@ -121,7 +124,7 @@
>
>  @util.propertycache
>  def track(self):
> -return self.configlist('blackbox', 'track', ['*'])
> +return self.configlist('blackbox', 'track')
>
>  def log(self, event, *msg, **opts):
>  global lastui
> ___
> 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