[PATCH] revset: add default error messages to getintrange()

2019-02-05 Thread Anton Shestakov
# HG changeset patch
# User Anton Shestakov 
# Date 1549432950 -28800
#  Wed Feb 06 14:02:30 2019 +0800
# Node ID e87cf73bbbffd69efa77b93fa4190d8e0987f339
# Parent  a5493a251ad3a724b0a7a1bff21248c39611c6de
revset: add default error messages to getintrange()

Looks like it's the default values that will vary from one subscript relation
function to another, but the currently used error messages work for most cases
(the function is called "getintrange", after all). Let's make it possible to
reuse these messages.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -259,8 +259,6 @@ def generationsrel(repo, subset, x, rel,
 # TODO: rewrite tests, and drop startdepth argument from ancestors() and
 # descendants() predicates
 a, b = getintrange(z,
-   _('relation subscript must be an integer or a range'),
-   _('relation subscript bounds must be integers'),
deffirst=-(dagop.maxlogdepth - 1),
deflast=+(dagop.maxlogdepth - 1))
 (ancstart, ancstop), (descstart, descstop) = _splitrange(a, b)
diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -240,16 +240,20 @@ def getrange(x, err):
 return None, None
 raise error.ParseError(err)
 
-def getintrange(x, err1, err2, deffirst=_notset, deflast=_notset):
+def getintrange(x, err1=None, err2=None, deffirst=_notset, deflast=_notset):
 """Get [first, last] integer range (both inclusive) from a parsed tree
 
 If any of the sides omitted, and if no default provided, ParseError will
 be raised.
 """
+if err1 is None:
+err1 = _('relation subscript must be an integer or a range')
 if x and (x[0] == 'string' or x[0] == 'symbol'):
 n = getinteger(x, err1)
 return n, n
 a, b = getrange(x, err1)
+if err2 is None:
+err2 = _('relation subscript bounds must be integers'),
 return getinteger(a, err2, deffirst), getinteger(b, err2, deflast)
 
 def getargs(x, min, max, err):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread mharbison72 (Matt Harbison)
mharbison72 added a comment.


  Maybe a py3 thing?
  
$ py -3 run-tests.py --local test-http.t
running 1 tests using 1 parallel processes

--- c:/Users/Matt/hg/tests/test-http.t
+++ c:/Users/Matt/hg/tests/test-http.t.err
@@ -1,58 +1,262 @@
 #require serve

   $ hg init test
+  ** unknown exception encountered, please report by visiting
+  ** https://mercurial-scm.org/wiki/BugTracker
+  ** Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 
64 bit (AMD64)]
+  ** Mercurial Distributed SCM (version 4.9+253-acd3eda2aa5b)
+  ** Extensions loaded:
+  Traceback (most recent call last):\r (esc)
+File "c:\\Users\\Matt\\hg\\hg", line 43, in \r (esc)
+  dispatch.run()\r (esc)
+File "c:\\Users\\Matt\\hg\\mercurial\\dispatch.py", line 99, in run\r 
(esc)
+  status = dispatch(req)\r (esc)
+File "c:\\Users\\Matt\\hg\\mercurial\\dispatch.py", line 225, in 
dispatch\r (esc)
+  ret = _runcatch(req) or 0\r (esc)
+File "c:\\Users\\Matt\\hg\\mercurial\\dispatch.py", line 376, in 
_runcatch\r (esc)
+  return _callcatch(ui, _runcatchfunc)\r (esc)
+File "c:\\Users\\Matt\\hg\\mercurial\\dispatch.py", line 384, in 
_callcatch\r (esc)
+  return scmutil.callcatch(ui, func)\r (esc)
+File "C:\\Program Files\\Python37\\Lib\\importlib\\util.py", line 245, 
in __getattribute__\r (esc)
+  self.__spec__.loader.exec_module(self)\r (esc)
+File "", line 724, in 
exec_module\r (esc)
+File "", line 860, in get_code\r 
(esc)
+File "c:\\Users\\Matt\\hg\\mercurial\\__init__.py", line 295, in 
source_to_code\r (esc)
+  return super(hgloader, self).source_to_code(data, path)\r (esc)
+File "", line 791, in 
source_to_code\r (esc)
+File "", line 219, in 
_call_with_frames_removed\r (esc)
+File "c:\\Users\\Matt\\hg\\mercurial\\scmutil.py", line 741\r (esc)
+  "\r (esc)
+  SyntaxError: cannot mix bytes and nonbytes literals\r (esc)
+  [1]
   $ cd test

REPOSITORY
  rHG Mercurial

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

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


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz marked an inline comment as done.
martinvonz added inline comments.

INLINE COMMENTS

> mharbison72 wrote in scmutil.py:741
> 2 too many quotes here are causing stacktraces.

Fixed in the hg-committed repo.

What kind of stacktraces? I'm curious why I didn't see them.

REPOSITORY
  rHG Mercurial

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

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


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread mharbison72 (Matt Harbison)
mharbison72 added inline comments.

INLINE COMMENTS

> scmutil.py:741
> +of what ui.relative-paths is set to.
> +"
> +if forcerelativevalue is not None:

2 too many quotes here are causing stacktraces.

REPOSITORY
  rHG Mercurial

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

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


[PATCH 6 of 6] py3: ensure the HTTP password manager returns strings, not bytes

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549404160 18000
#  Tue Feb 05 17:02:40 2019 -0500
# Node ID c0d3c5f3c5ebd2db2a73b68d20c90df741831cb9
# Parent  766e1b887a85c352e10381e30f3caaae320483e2
py3: ensure the HTTP password manager returns strings, not bytes

The digest handler calls into the password manager on its own, and it apparently
expects strings.  Perhaps the Basic authentication handler didn't hit this
because of its manual password fetch and format in retry_http_basic_auth().

The `pycompat.bytesurl()` on the user and password just above the first url.py
diff seems unnecessary, because the password proxy in ui is converting to bytes
IIUC.

diff --git a/mercurial/url.py b/mercurial/url.py
--- a/mercurial/url.py
+++ b/mercurial/url.py
@@ -65,7 +65,7 @@ class passwordmgr(object):
 user, passwd = pycompat.bytesurl(user), pycompat.bytesurl(passwd)
 if user and passwd:
 self._writedebug(user, passwd)
-return (user, passwd)
+return (pycompat.strurl(user), pycompat.strurl(passwd))
 
 if not user or not passwd:
 res = httpconnectionmod.readauthforuri(self.ui, authuri, user)
@@ -93,7 +93,7 @@ class passwordmgr(object):
 
 self.passwddb.add_password(realm, authuri, user, passwd)
 self._writedebug(user, passwd)
-return (user, passwd)
+return (pycompat.strurl(user), pycompat.strurl(passwd))
 
 def _writedebug(self, user, passwd):
 msg = _('http auth: user %s, password %s\n')
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -225,9 +225,8 @@ test http authentication
   > return opener
   > EOF
 
-  $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py || 
true
-  abort: HTTP Error 403: bad user (py3 !)
-  5fed3813f7f5 (no-py3 !)
+  $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py
+  5fed3813f7f5
 
 #if no-reposimplestore
   $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
@@ -383,14 +382,13 @@ test http authentication
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
   "GET /?cmd=capabilities HTTP/1.1" 401 - x-hgtest-authtype:Digest
-  "GET /?cmd=capabilities HTTP/1.1" 403 - x-hgtest-authtype:Digest (py3 !)
-  "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest (no-py3 !)
-  "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
-  "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
-  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
-  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
-  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
-  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest
+  "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+  "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest
+  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest
+  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest
+  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest
+  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest
   "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
   "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore 
!)
@@ -461,7 +459,6 @@ check error log
   $ cat error.log
 
   $ cat errors2.log
-  $LOCALIP - - [$ERRDATE$] HG error:  No hash found for user/realm 
"b'user'/mercurial" (glob) (py3 !)
 
 check abort error rep

[PATCH 5 of 6] tests: enable HTTP digest testing

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549403239 18000
#  Tue Feb 05 16:47:19 2019 -0500
# Node ID 766e1b887a85c352e10381e30f3caaae320483e2
# Parent  1a4bd7696b7e12673ddc46733babd15151f00e05
tests: enable HTTP digest testing

I suppose we could spin the client side extension off to a *.py file if it gets
more use.  I was basically just looking to avoid killing the server and
relaunching it just to change authentication schemes, because that doesn't
always work on Windows.

The test changes capture the problem with py3.

diff --git a/tests/httpserverauth.py b/tests/httpserverauth.py
--- a/tests/httpserverauth.py
+++ b/tests/httpserverauth.py
@@ -85,8 +85,24 @@ class digestauthserver(object):
 
 return True
 
+digest = digestauthserver()
+
 def perform_authentication(hgweb, req, op):
 auth = req.headers.get(b'Authorization')
+
+if req.headers.get(b'X-HgTest-AuthType') == b'Digest':
+global digest
+
+if not auth:
+challenge = digest.makechallenge(b'mercurial')
+raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
+[(b'WWW-Authenticate', b'Digest %s' % challenge)])
+
+if not digest.checkauth(req, auth[7:]):
+raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
+
+return
+
 if not auth:
 raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
 [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
@@ -96,3 +112,6 @@ def perform_authentication(hgweb, req, o
 
 def extsetup(ui):
 common.permhooks.insert(0, perform_authentication)
+
+global digest
+digest.adduser(b'user', b'pass', b'mercurial')
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -173,7 +173,7 @@ test http authentication
   $ cd test
 
   $ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -p $HGPORT2 -d \
-  >--pid-file=pid --config server.preferuncompressed=True \
+  >--pid-file=pid --config server.preferuncompressed=True -E 
../errors2.log \
   >--config web.push_ssl=False --config web.allow_push=* -A ../access.log
   $ cat pid >> $DAEMON_PIDS
 
@@ -209,6 +209,26 @@ test http authentication
   $ hg id http://user@localhost:$HGPORT2/
   5fed3813f7f5
 
+  $ cat > use_digests.py << EOF
+  > from mercurial import (
+  > exthelper,
+  > url,
+  > )
+  > 
+  > eh = exthelper.exthelper()
+  > uisetup = eh.finaluisetup
+  > 
+  > @eh.wrapfunction(url, 'opener')
+  > def urlopener(orig, *args, **kwargs):
+  > opener = orig(*args, **kwargs)
+  > opener.addheaders.append((r'X-HgTest-AuthType', r'Digest'))
+  > return opener
+  > EOF
+
+  $ hg id http://localhost:$HGPORT2/ --config extensions.x=use_digests.py || 
true
+  abort: HTTP Error 403: bad user (py3 !)
+  5fed3813f7f5 (no-py3 !)
+
 #if no-reposimplestore
   $ hg clone http://user:pass@localhost:$HGPORT2/ dest 2>&1
   streaming all changes
@@ -362,6 +382,15 @@ test http authentication
   "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
   "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull
+  "GET /?cmd=capabilities HTTP/1.1" 401 - x-hgtest-authtype:Digest
+  "GET /?cmd=capabilities HTTP/1.1" 403 - x-hgtest-authtype:Digest (py3 !)
+  "GET /?cmd=capabilities HTTP/1.1" 200 - x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=lookup HTTP/1.1" 401 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=lookup HTTP/1.1" 200 - x-hgarg-1:key=tip x-hgproto-1:0.1 0.2 
comp=$USUAL_COMPRESSIONS$ partial-pull x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=namespaces 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=listkeys HTTP/1.1" 401 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
+  "GET /?cmd=listkeys HTTP/1.1" 200 - x-hgarg-1:namespace=bookmarks 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull 
x-hgtest-authtype:Digest (no-py3 !)
   "GET /?cmd=capabilities HTTP/1.1" 401 - (no-reposimplestore !)
   "GET /?cmd=capabilities HTTP/1.1" 200 - (no-reposimplestore !)
   "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=heads+%3Bknown+nodes%3D 
x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (no-reposimplestore 
!)
@@ -431,6 +460,9 @@ check error log
 
   $ cat error.log
 
+  $ cat errors2.log
+  $LOCALIP - - [$ERRDATE$] HG error:  No hash found for u

[PATCH 4 of 6] wsgiheaders: make sure __repr__() returns a string

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549401374 18000
#  Tue Feb 05 16:16:14 2019 -0500
# Node ID 1a4bd7696b7e12673ddc46733babd15151f00e05
# Parent  576aec428b05a88584505b9c4af541e273e1014a
wsgiheaders: make sure __repr__() returns a string

When printing `req.headers` on the server side to debug, it complained that '%b'
needed to take a string, not bytes.  Changing '%s' to '%r' caused it to complain
that __repr__ didn't return a string.

diff --git a/mercurial/hgweb/wsgiheaders.py b/mercurial/hgweb/wsgiheaders.py
--- a/mercurial/hgweb/wsgiheaders.py
+++ b/mercurial/hgweb/wsgiheaders.py
@@ -127,7 +127,7 @@ class Headers(object):
 return self._headers[:]
 
 def __repr__(self):
-return "%s(%r)" % (self.__class__.__name__, self._headers)
+return r"%s(%r)" % (self.__class__.__name__, self._headers)
 
 def __str__(self):
 """str() returns the formatted headers, complete with end line,
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 6] tests: add code to handle HTTP digests on the server side

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549391559 18000
#  Tue Feb 05 13:32:39 2019 -0500
# Node ID 576aec428b05a88584505b9c4af541e273e1014a
# Parent  4bad819762856a2a6b5c9faeb52a15fa63b1ca9e
tests: add code to handle HTTP digests on the server side

It's not hooked up yet.  Mostly this was cargoculted and simplified from some
python.org code[1].  It's not trying to test the security as much as it is
trying to make sure that clients are sending out the right data when challenged.
(And they aren't on py3.)

[1] http://svn.python.org/projects/sandbox/trunk/digestauth/digestauth.py

diff --git a/tests/httpserverauth.py b/tests/httpserverauth.py
--- a/tests/httpserverauth.py
+++ b/tests/httpserverauth.py
@@ -1,8 +1,89 @@
 from __future__ import absolute_import
 
 import base64
+import hashlib
 
 from mercurial.hgweb import common
+from mercurial import (
+node,
+)
+
+def parse_keqv_list(req, l):
+"""Parse list of key=value strings where keys are not duplicated."""
+parsed = {}
+for elt in l:
+k, v = elt.split(b'=', 1)
+if v[0:1] == b'"' and v[-1:] == b'"':
+v = v[1:-1]
+parsed[k] = v
+return parsed
+
+class digestauthserver(object):
+def __init__(self):
+self._user_hashes = {}
+
+def gethashers(self):
+def _md5sum(x):
+m = hashlib.md5()
+m.update(x)
+return node.hex(m.digest())
+
+h = _md5sum
+
+kd = lambda s, d, h=h: h(b"%s:%s" % (s, d))
+return h, kd
+
+def adduser(self, user, password, realm):
+h, kd = self.gethashers()
+a1 = h(b'%s:%s:%s' % (user, realm, password))
+self._user_hashes[(user, realm)] = a1
+
+def makechallenge(self, realm):
+# We aren't testing the protocol here, just that the bytes make the
+# proper round trip.  So hardcoded seems fine.
+nonce = b'064af982c5b571cea6450d8eda91c20d'
+return b'realm="%s", nonce="%s", algorithm=MD5, qop="auth"' % (realm,
+   nonce)
+
+def checkauth(self, req, header):
+log = req.rawenv[b'wsgi.errors']
+
+h, kd = self.gethashers()
+resp = parse_keqv_list(req, header.split(b', '))
+
+if resp.get(b'algorithm', b'MD5').upper() != b'MD5':
+log.write(b'Unsupported algorithm: %s' % resp.get(b'algorithm'))
+raise common.ErrorResponse(common.HTTP_FORBIDDEN,
+   b"unknown algorithm")
+user = resp[b'username']
+realm = resp[b'realm']
+nonce = resp[b'nonce']
+
+ha1 = self._user_hashes.get((user, realm))
+if not ha1:
+log.write(b'No hash found for user/realm "%s/%s"' % (user, realm))
+raise common.ErrorResponse(common.HTTP_FORBIDDEN, b"bad user")
+
+qop = resp.get(b'qop', b'auth')
+if qop != b'auth':
+log.write(b"Unsupported qop: %s" % qop)
+raise common.ErrorResponse(common.HTTP_FORBIDDEN, b"bad qop")
+
+cnonce, ncvalue = resp.get(b'cnonce'), resp.get(b'nc')
+if not cnonce or not ncvalue:
+log.write(b'No cnonce (%s) or ncvalue (%s)' % (cnonce, ncvalue))
+raise common.ErrorResponse(common.HTTP_FORBIDDEN, b"no cnonce")
+
+a2 = b'%s:%s' % (req.method, resp[b'uri'])
+noncebit = b"%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, h(a2))
+
+respdig = kd(ha1, noncebit)
+if respdig != resp[b'response']:
+log.write(b'User/realm "%s/%s" gave %s, but expected %s'
+  % (user, realm, resp[b'response'], respdig))
+return False
+
+return True
 
 def perform_authentication(hgweb, req, op):
 auth = req.headers.get(b'Authorization')
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 6] run-tests: allow spaces in the --view tool

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549391448 18000
#  Tue Feb 05 13:30:48 2019 -0500
# Node ID 4bad819762856a2a6b5c9faeb52a15fa63b1ca9e
# Parent  e68578660449146a4b77089e8419542a61a3dc1c
run-tests: allow spaces in the --view tool

Most tools on Windows are in Program Files, and not necessarily on PATH.

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1902,8 +1902,9 @@ class TestResult(unittest._TextTestResul
 pass
 elif self._options.view:
 v = self._options.view
-os.system(r"%s %s %s" %
-  (v, _strpath(test.refpath), _strpath(test.errpath)))
+subprocess.call(r'"%s" "%s" "%s"' %
+(v, _strpath(test.refpath),
+_strpath(test.errpath)), shell=True)
 else:
 servefail, lines = getdiff(expected, got,
test.refpath, test.errpath)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 1 of 6] tests: extract the http server authentication extension to a single module

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549377443 18000
#  Tue Feb 05 09:37:23 2019 -0500
# Node ID e68578660449146a4b77089e8419542a61a3dc1c
# Parent  13f7a6a4f0dba217789055f6dc240d41be8dd65b
tests: extract the http server authentication extension to a single module

We had 4 copy/pastes of this, and no coverage for http digests (which are
currently broken on py3).

diff --git a/tests/httpserverauth.py b/tests/httpserverauth.py
new file mode 100644
--- /dev/null
+++ b/tests/httpserverauth.py
@@ -0,0 +1,17 @@
+from __future__ import absolute_import
+
+import base64
+
+from mercurial.hgweb import common
+
+def perform_authentication(hgweb, req, op):
+auth = req.headers.get(b'Authorization')
+if not auth:
+raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
+[(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
+
+if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
+raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
+
+def extsetup(ui):
+common.permhooks.insert(0, perform_authentication)
diff --git a/tests/test-http-bundle1.t b/tests/test-http-bundle1.t
--- a/tests/test-http-bundle1.t
+++ b/tests/test-http-bundle1.t
@@ -175,22 +175,9 @@ test http authentication
 + use the same server to test server side streaming preference
 
   $ cd test
-  $ cat << EOT > userpass.py
-  > import base64
-  > from mercurial.hgweb import common
-  > def perform_authentication(hgweb, req, op):
-  > auth = req.headers.get(b'Authorization')
-  > if not auth:
-  > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
-  > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
-  > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user',
-  > b'pass']:
-  > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup(ui):
-  > common.permhooks.insert(0, perform_authentication)
-  > EOT
-  $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
-  >--config server.preferuncompressed=True \
+
+  $ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -p $HGPORT2 -d \
+  >--pid-file=pid --config server.preferuncompressed=True \
   >--config web.push_ssl=False --config web.allow_push=* -A ../access.log
   $ cat pid >> $DAEMON_PIDS
 
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -171,21 +171,9 @@ test http authentication
 + use the same server to test server side streaming preference
 
   $ cd test
-  $ cat << EOT > userpass.py
-  > import base64
-  > from mercurial.hgweb import common
-  > def perform_authentication(hgweb, req, op):
-  > auth = req.headers.get(b'Authorization')
-  > if not auth:
-  > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
-  > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
-  > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', 
b'pass']:
-  > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup(ui):
-  > common.permhooks.insert(0, perform_authentication)
-  > EOT
-  $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
-  >--config server.preferuncompressed=True \
+
+  $ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -p $HGPORT2 -d \
+  >--pid-file=pid --config server.preferuncompressed=True \
   >--config web.push_ssl=False --config web.allow_push=* -A ../access.log
   $ cat pid >> $DAEMON_PIDS
 
diff --git a/tests/test-largefiles-wireproto.t 
b/tests/test-largefiles-wireproto.t
--- a/tests/test-largefiles-wireproto.t
+++ b/tests/test-largefiles-wireproto.t
@@ -420,20 +420,8 @@ a large file from the server rather than
   $ rm "${USERCACHE}"/*
 
   $ cd ..
-  $ cat << EOT > userpass.py
-  > import base64
-  > from mercurial.hgweb import common
-  > def perform_authentication(hgweb, req, op):
-  > auth = req.headers.get(b'Authorization')
-  > if not auth:
-  > raise common.ErrorResponse(common.HTTP_UNAUTHORIZED, b'who',
-  > [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
-  > if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', 
b'pass']:
-  > raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup(ui):
-  > common.permhooks.insert(0, perform_authentication)
-  > EOT
-  $ hg serve --config extensions.x=userpass.py -R credentialmain \
+
+  $ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -R 
credentialmain \
   >  -d -p $HGPORT --pid-file hg.pid -A access.log
   $ cat hg.pid >> $DAEMON_PIDS
   $ cat << EOF > get_pass.py
diff --git a/tests/test-lfs-serve-access.t b/tests/test-lfs-serve-access.t
--- a/tests/test-lfs-serve-access.t
+++ b/tests/test-lfs-serve-access.t
@@ -393,22 +393,7 @@ the GET/PUT request.
   > l.password=pass
   > EOF
 
-  $ 

Re: [PATCH STABLE] subrepo: avoid false unsafe path detection on Windows

2019-02-05 Thread Matt Harbison
On Tue, 05 Feb 2019 21:04:00 -0500, Matt Harbison   
wrote:



# HG changeset patch
# User Matt Harbison 
# Date 1549417854 18000
#  Tue Feb 05 20:50:54 2019 -0500
# Branch stable
# Node ID 0e18c6ec895542394c0ad18c380bf3bbd4ba4d9b
# Parent  8b2892d5a9f2c06c998c977015a9ad3e3a3c9b5f
subrepo: avoid false unsafe path detection on Windows


The fixes a last minute breakage in 4.9.  It doesn't look like TortoiseHg  
or the MSI installer has been generated yet, but the Inno installer is  
already posted.  Maybe this needs a 4.9.1?

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


[PATCH STABLE] subrepo: avoid false unsafe path detection on Windows

2019-02-05 Thread Matt Harbison
# HG changeset patch
# User Matt Harbison 
# Date 1549417854 18000
#  Tue Feb 05 20:50:54 2019 -0500
# Branch stable
# Node ID 0e18c6ec895542394c0ad18c380bf3bbd4ba4d9b
# Parent  8b2892d5a9f2c06c998c977015a9ad3e3a3c9b5f
subrepo: avoid false unsafe path detection on Windows

Subrepo paths are not normalized for the OS, so what was happening in the
subsequent root path check was:

root  -> $TESTTMP\issue1852a\sub/repo
util.expandpath(...)  -> $TESTTMP\issue1852a\sub/repo
os.path.realpath(...) -> $TESTTMP\issue1852a\sub\repo

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -405,7 +405,7 @@ class hgsubrepo(abstractsubrepo):
 super(hgsubrepo, self).__init__(ctx, path)
 self._state = state
 r = ctx.repo()
-root = r.wjoin(path)
+root = os.path.realpath(r.wjoin(path))
 create = allowcreate and not r.wvfs.exists('%s/.hg' % path)
 # repository constructor does expand variables in path, which is
 # unsafe since subrepo path might come from untrusted source.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5869: largefiles: use wrappedfunction() in overriderevert()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -78,22 +78,6 @@
 m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
 return m
 
-def installmatchfn(f):
-'''monkey patch the scmutil module with a custom match function.
-Warning: it is monkey patching the _module_ on runtime! Not thread safe!'''
-oldmatch = scmutil.match
-setattr(f, 'oldmatch', oldmatch)
-scmutil.match = f
-return oldmatch
-
-def restorematchfn():
-'''restores scmutil.match to what it was before installmatchfn
-was called.  no-op if scmutil.match is its original function.
-
-Note that n calls to installmatchfn will require n calls to
-restore the original matchfn.'''
-scmutil.match = getattr(scmutil.match, 'oldmatch')
-
 def addlargefiles(ui, repo, isaddremove, matcher, **opts):
 large = opts.get(r'large')
 lfsize = lfutil.getminsize(
@@ -756,11 +740,11 @@
 
 oldstandins = lfutil.getstandinsstate(repo)
 
-def overridematch(mctx, pats=(), opts=None, globbed=False,
+def overridematch(orig, mctx, pats=(), opts=None, globbed=False,
 default='relpath', badfn=None):
 if opts is None:
 opts = {}
-match = oldmatch(mctx, pats, opts, globbed, default, badfn=badfn)
+match = orig(mctx, pats, opts, globbed, default, badfn=badfn)
 m = copy.copy(match)
 
 # revert supports recursing into subrepos, and though largefiles
@@ -791,11 +775,8 @@
 return origmatchfn(f)
 m.matchfn = matchfn
 return m
-oldmatch = installmatchfn(overridematch)
-try:
+with extensions.wrappedfunction(scmutil, 'match', overridematch):
 orig(ui, repo, ctx, parents, *pats, **opts)
-finally:
-restorematchfn()
 
 newstandins = lfutil.getstandinsstate(repo)
 filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)



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


D5868: largefiles: use wrappedfunction() for "normal files match" in overridecopy()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -78,16 +78,6 @@
 m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
 return m
 
-def installnormalfilesmatchfn(manifest):
-'''installmatchfn with a matchfn that ignores all largefiles'''
-def overridematch(ctx, pats=(), opts=None, globbed=False,
-default='relpath', badfn=None):
-if opts is None:
-opts = {}
-match = oldmatch(ctx, pats, opts, globbed, default, badfn=badfn)
-return composenormalfilematcher(match, manifest)
-oldmatch = installmatchfn(overridematch)
-
 def installmatchfn(f):
 '''monkey patch the scmutil module with a custom match function.
 Warning: it is monkey patching the _module_ on runtime! Not thread safe!'''
@@ -616,17 +606,22 @@
 # match largefiles and run it again.
 nonormalfiles = False
 nolfiles = False
-installnormalfilesmatchfn(repo[None].manifest())
-try:
-result = orig(ui, repo, pats, opts, rename)
-except error.Abort as e:
-if pycompat.bytestr(e) != _('no files to copy'):
-raise e
-else:
-nonormalfiles = True
-result = 0
-finally:
-restorematchfn()
+manifest = repo[None].manifest()
+def normalfilesmatchfn(orig, ctx, pats=(), opts=None, globbed=False,
+default='relpath', badfn=None):
+if opts is None:
+opts = {}
+match = orig(ctx, pats, opts, globbed, default, badfn=badfn)
+return composenormalfilematcher(match, manifest)
+with extensions.wrappedfunction(scmutil, 'match', normalfilesmatchfn):
+try:
+result = orig(ui, repo, pats, opts, rename)
+except error.Abort as e:
+if pycompat.bytestr(e) != _('no files to copy'):
+raise e
+else:
+nonormalfiles = True
+result = 0
 
 # The first rename can cause our current working directory to be removed.
 # In that case there is nothing left to copy/rename so just quit.



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


D5867: largefiles: use wrappedfunction() for match() override in overridecopy()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This reduced the time that the override is in place, but I that it's
  correct this way (only for the duration of the orig() call).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -652,7 +652,7 @@
 wlock = repo.wlock()
 
 manifest = repo[None].manifest()
-def overridematch(ctx, pats=(), opts=None, globbed=False,
+def overridematch(orig, ctx, pats=(), opts=None, globbed=False,
 default='relpath', badfn=None):
 if opts is None:
 opts = {}
@@ -664,7 +664,7 @@
 newpats.append(pat.replace(lfutil.shortname, ''))
 else:
 newpats.append(pat)
-match = oldmatch(ctx, newpats, opts, globbed, default, badfn=badfn)
+match = orig(ctx, newpats, opts, globbed, default, badfn=badfn)
 m = copy.copy(match)
 lfile = lambda f: lfutil.standin(f) in manifest
 m._files = [lfutil.standin(f) for f in m._files if lfile(f)]
@@ -678,7 +678,6 @@
 None)
 m.matchfn = matchfn
 return m
-oldmatch = installmatchfn(overridematch)
 listpats = []
 for pat in pats:
 if matchmod.patkind(pat) is not None:
@@ -696,7 +695,8 @@
   _('destination largefile already exists'))
 copiedfiles.append((src, dest))
 orig(src, dest, *args, **kwargs)
-with extensions.wrappedfunction(util, 'copyfile', overridecopyfile):
+with extensions.wrappedfunction(util, 'copyfile', overridecopyfile), \
+ extensions.wrappedfunction(scmutil, 'match', overridematch):
 result += orig(ui, repo, listpats, opts, rename)
 
 lfdirstate = lfutil.openlfdirstate(ui, repo)
@@ -727,7 +727,6 @@
 else:
 nolfiles = True
 finally:
-restorematchfn()
 wlock.release()
 
 if nolfiles and nonormalfiles:



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


D5866: largefiles: use wrappedfunction() for util.copyfile() override

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -686,23 +686,18 @@
 else:
 listpats.append(makestandin(pat))
 
-try:
-origcopyfile = util.copyfile
-copiedfiles = []
-def overridecopyfile(src, dest, *args, **kwargs):
-if (lfutil.shortname in src and
-dest.startswith(repo.wjoin(lfutil.shortname))):
-destlfile = dest.replace(lfutil.shortname, '')
-if not opts['force'] and os.path.exists(destlfile):
-raise IOError('',
-_('destination largefile already exists'))
-copiedfiles.append((src, dest))
-origcopyfile(src, dest, *args, **kwargs)
-
-util.copyfile = overridecopyfile
+copiedfiles = []
+def overridecopyfile(orig, src, dest, *args, **kwargs):
+if (lfutil.shortname in src and
+dest.startswith(repo.wjoin(lfutil.shortname))):
+destlfile = dest.replace(lfutil.shortname, '')
+if not opts['force'] and os.path.exists(destlfile):
+raise IOError('',
+  _('destination largefile already exists'))
+copiedfiles.append((src, dest))
+orig(src, dest, *args, **kwargs)
+with extensions.wrappedfunction(util, 'copyfile', overridecopyfile):
 result += orig(ui, repo, listpats, opts, rename)
-finally:
-util.copyfile = origcopyfile
 
 lfdirstate = lfutil.openlfdirstate(ui, repo)
 for (src, dest) in copiedfiles:



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


D5865: largefiles: use wrappedfunction() for matchandpats() override in overridelog()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/overrides.py

CHANGE DETAILS

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -24,6 +24,7 @@
 copies as copiesmod,
 error,
 exchange,
+extensions,
 exthelper,
 filemerge,
 hg,
@@ -103,22 +104,6 @@
 restore the original matchfn.'''
 scmutil.match = getattr(scmutil.match, 'oldmatch')
 
-def installmatchandpatsfn(f):
-oldmatchandpats = scmutil.matchandpats
-setattr(f, 'oldmatchandpats', oldmatchandpats)
-scmutil.matchandpats = f
-return oldmatchandpats
-
-def restorematchandpatsfn():
-'''restores scmutil.matchandpats to what it was before
-installmatchandpatsfn was called. No-op if scmutil.matchandpats
-is its original function.
-
-Note that n calls to installmatchandpatsfn will require n calls
-to restore the original matchfn.'''
-scmutil.matchandpats = getattr(scmutil.matchandpats, 'oldmatchandpats',
-scmutil.matchandpats)
-
 def addlargefiles(ui, repo, isaddremove, matcher, **opts):
 large = opts.get(r'large')
 lfsize = lfutil.getminsize(
@@ -324,17 +309,16 @@
 
 @eh.wrapcommand('log')
 def overridelog(orig, ui, repo, *pats, **opts):
-def overridematchandpats(ctx, pats=(), opts=None, globbed=False,
+def overridematchandpats(orig, ctx, pats=(), opts=None, globbed=False,
 default='relpath', badfn=None):
 """Matcher that merges root directory with .hglf, suitable for log.
 It is still possible to match .hglf directly.
 For any listed files run log on the standin too.
 matchfn tries both the given filename and with .hglf stripped.
 """
 if opts is None:
 opts = {}
-matchandpats = oldmatchandpats(ctx, pats, opts, globbed, default,
-   badfn=badfn)
+matchandpats = orig(ctx, pats, opts, globbed, default, badfn=badfn)
 m, p = copy.copy(matchandpats)
 
 if m.always():
@@ -414,20 +398,18 @@
 # (2) to determine what files to print out diffs for.
 # The magic matchandpats override should be used for case (1) but not for
 # case (2).
-def overridemakefilematcher(repo, pats, opts, badfn=None):
+oldmatchandpats = scmutil.matchandpats
+def overridemakefilematcher(orig, repo, pats, opts, badfn=None):
 wctx = repo[None]
 match, pats = oldmatchandpats(wctx, pats, opts, badfn=badfn)
 return lambda ctx: match
 
-oldmatchandpats = installmatchandpatsfn(overridematchandpats)
-oldmakefilematcher = logcmdutil._makenofollowfilematcher
-setattr(logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
-
-try:
+wrappedmatchandpats = extensions.wrappedfunction(scmutil, 'matchandpats',
+ overridematchandpats)
+wrappedmakefilematcher = extensions.wrappedfunction(
+logcmdutil, '_makenofollowfilematcher', overridemakefilematcher)
+with wrappedmatchandpats, wrappedmakefilematcher:
 return orig(ui, repo, *pats, **opts)
-finally:
-restorematchandpatsfn()
-setattr(logcmdutil, '_makenofollowfilematcher', oldmakefilematcher)
 
 @eh.wrapcommand('verify',
 opts=[('', 'large', None,



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


mercurial@41564: 8 new changesets

2019-02-05 Thread Mercurial Commits
8 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/3a01ce246ece
changeset:   41557:3a01ce246ece
user:Kyle Lippincott 
date:Mon Jan 28 18:05:05 2019 -0800
summary: commit: ignore diff whitespace settings when doing `commit -i` 
(issue5839)

https://www.mercurial-scm.org/repo/hg/rev/901ebc81ffb3
changeset:   41558:901ebc81ffb3
user:Kyle Lippincott 
date:Thu Jan 31 14:27:25 2019 -0800
summary: config: extract diff-related coreconfigitem()s to a helper method

https://www.mercurial-scm.org/repo/hg/rev/78b270a55dc6
changeset:   41559:78b270a55dc6
user:Kyle Lippincott 
date:Thu Jan 31 14:29:24 2019 -0800
summary: diff: when looking for diff configs, support a configurable prefix

https://www.mercurial-scm.org/repo/hg/rev/66399f2e92aa
changeset:   41560:66399f2e92aa
user:Kyle Lippincott 
date:Thu Jan 31 14:47:34 2019 -0800
summary: commit: if interactive, look elsewhere for whitespace settings (BC)

https://www.mercurial-scm.org/repo/hg/rev/59638c6fcb70
changeset:   41561:59638c6fcb70
user:Yuya Nishihara 
date:Sun Jan 27 13:18:53 2019 +0900
summary: revset: extract a helper to parse integer range

https://www.mercurial-scm.org/repo/hg/rev/1c04894e8fe1
changeset:   41562:1c04894e8fe1
user:Yuya Nishihara 
date:Sun Jan 27 13:28:45 2019 +0900
summary: revset: allow to parse single integer as a range

https://www.mercurial-scm.org/repo/hg/rev/13f7a6a4f0db
changeset:   41563:13f7a6a4f0db
user:Yuya Nishihara 
date:Sun Jan 27 13:37:37 2019 +0900
summary: revset: leverage getintrange() helper in relation-subscript 
operation (API)

https://www.mercurial-scm.org/repo/hg/rev/a5493a251ad3
changeset:   41564:a5493a251ad3
bookmark:@
tag: tip
user:Gregory Szorc 
date:Mon Feb 04 09:10:07 2019 -0800
summary: attr: make some docstrings raw strings

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


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc56d80871eac: config: introduce a new value for 
ui.relative-paths getting old behavior (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5800?vs=13811&id=13836

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -725,9 +725,32 @@
 return []
 return parents
 
-def getuipathfn(repo, relative=None):
-if relative is None:
-relative = repo.ui.configbool('ui', 'relative-paths')
+def getuipathfn(repo, legacyrelativevalue=False, forcerelativevalue=None):
+"""Return a function that produced paths for presenting to the user.
+
+The returned function takes a repo-relative path and produces a path
+that can be presented in the UI.
+
+Depending on the value of ui.relative-paths, either a repo-relative or
+cwd-relative path will be produced.
+
+legacyrelativevalue is the value to use if ui.relative-paths=legacy
+
+If forcerelativevalue is not None, then that value will be used regardless
+of what ui.relative-paths is set to.
+"
+if forcerelativevalue is not None:
+relative = forcerelativevalue
+else:
+config = repo.ui.config('ui', 'relative-paths')
+if config == 'legacy':
+relative = legacyrelativevalue
+else:
+relative = stringutil.parsebool(config)
+if relative is None:
+raise error.ConfigError(
+_("ui.relative-paths is not a boolean ('%s')") % config)
+
 if relative:
 cwd = repo.getcwd()
 pathto = repo.pathto
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1207,7 +1207,7 @@
 default=False,
 )
 coreconfigitem('ui', 'relative-paths',
-default=False,
+default='legacy',
 )
 coreconfigitem('ui', 'remotecmd',
 default='hg',
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5421,7 +5421,7 @@
 relative = True
 elif ui.hasconfig('commands', 'status.relative'):
 relative = ui.configbool('commands', 'status.relative')
-uipathfn = scmutil.getuipathfn(repo, relative)
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=relative)
 
 if opts.get('print0'):
 end = '\0'



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


D5802: status: if ui.relative-paths=no, don't use relative paths even with patterns

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG31ece2290403: status: if ui.relative-paths=no, don't 
use relative paths even with patterns (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5802?vs=13813&id=13838

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

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

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -132,18 +132,21 @@
 
 relative paths can be requested
 
-  $ cat >> $HGRCPATH < [ui]
-  > relative-paths = True
-  > EOF
-  $ hg status --cwd a
+  $ hg status --cwd a --config ui.relative-paths=yes
   ? 1/in_a_1
   ? in_a
   ? ../b/1/in_b_1
   ? ../b/2/in_b_2
   ? ../b/in_b
   ? ../in_root
 
+  $ hg status --cwd a . --config ui.relative-paths=legacy
+  ? 1/in_a_1
+  ? in_a
+  $ hg status --cwd a . --config ui.relative-paths=no
+  ? a/1/in_a_1
+  ? a/in_a
+
 commands.status.relative overrides ui.relative-paths
 
   $ cat >> $HGRCPATH 

D5801: files: respect ui.relative-paths

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGce0a4ed25ebc: files: respect ui.relative-paths (authored by 
martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5801?vs=13812&id=13837

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-locate.t

CHANGE DETAILS

diff --git a/tests/test-locate.t b/tests/test-locate.t
--- a/tests/test-locate.t
+++ b/tests/test-locate.t
@@ -123,6 +123,24 @@
   ../t.h
   ../t/e.h
   ../t/x
+  $ hg files --config ui.relative-paths=yes
+  ../b
+  ../dir.h/foo
+  ../t.h
+  ../t/e.h
+  ../t/x
+  $ hg files --config ui.relative-paths=no
+  b
+  dir.h/foo
+  t.h
+  t/e.h
+  t/x
+  $ hg files --config ui.relative-paths=legacy
+  ../b
+  ../dir.h/foo
+  ../t.h
+  ../t/e.h
+  ../t/x
 
   $ hg locate b
   ../b
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2164,14 +2164,15 @@
 ret = 1
 
 needsfctx = ui.verbose or {'size', 'flags'} & fm.datahint()
+uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
 for f in ctx.matches(m):
 fm.startitem()
 fm.context(ctx=ctx)
 if needsfctx:
 fc = ctx[f]
 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
 fm.data(path=f)
-fm.plain(fmt % m.rel(f))
+fm.plain(fmt % uipathfn(f))
 ret = 0
 
 for subpath in sorted(ctx.substate):



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


D5864: py3: use pycompat.bytestr() on extra values because it can be int

2019-02-05 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGb436059c1cca: py3: use pycompat.bytestr() on extra values 
because it can be int (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5864?vs=13831&id=13835

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

AFFECTED FILES
  contrib/python3-whitelist
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -70,7 +70,10 @@
 
 def encodeextra(d):
 # keys must be sorted to produce a deterministic changelog entry
-items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
+items = [
+_string_escape('%s:%s' % (k, pycompat.bytestr(d[k])))
+for k in sorted(d)
+]
 return "\0".join(items)
 
 def stripdesc(desc):
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -121,6 +121,7 @@
 test-convert-hg-sink.t
 test-convert-hg-source.t
 test-convert-hg-startrev.t
+test-convert-mtn.t
 test-convert-splicemap.t
 test-convert-svn-sink.t
 test-convert-tagsbranch-topology.t



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


D5863: py3: add some b'' prefixes in hgext/convert/monotone.py

2019-02-05 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG83d62df28ab6: py3: add some b'' prefixes in 
hgext/convert/monotone.py (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5863?vs=13830&id=13834

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

AFFECTED FILES
  hgext/convert/monotone.py

CHANGE DETAILS

diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -219,8 +219,8 @@
 m = self.cert_re.match(e)
 if m:
 name, value = m.groups()
-value = value.replace(r'\"', '"')
-value = value.replace(r'\\', '\\')
+value = value.replace(br'\"', '"')
+value = value.replace(br'\\', '\\')
 certs[name] = value
 # Monotone may have subsecond dates: 2005-02-05T09:39:12.364306
 # and all times are stored in UTC



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


D5862: py3: use '%d' for integers instead of '%s'

2019-02-05 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9b4a142a2035: py3: use '%d' for integers instead 
of '%s' (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5862?vs=13829&id=13833

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

AFFECTED FILES
  hgext/convert/monotone.py

CHANGE DETAILS

diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -154,7 +154,7 @@
 retval = []
 while True:
 commandnbr, stream, length, output = self.mtnstdioreadpacket()
-self.ui.debug('mtn: read packet %s:%s:%s\n' %
+self.ui.debug('mtn: read packet %s:%s:%d\n' %
 (commandnbr, stream, length))
 
 if stream == 'l':



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


D5861: py3: add 1 new passing test found by buildbot

2019-02-05 Thread pulkit (Pulkit Goyal)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf9ad1b65d3c3: py3: add 1 new passing test found by buildbot 
(authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5861?vs=13828&id=13832

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

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -760,5 +760,6 @@
 test-wireproto-serverreactor.py
 test-wireproto.py
 test-wireproto.t
+test-worker.t
 test-wsgirequest.py
 test-xdg.t



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


D5813: revset: add expect to check the size of a set

2019-02-05 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   > You can try out some combinations of `expect(5:0) & 1:10` and
  >   >  `10:1 & expect(0:5)`.
  >   
  >   I got into many errors while using this. I might be not understanding 
this correctly. Could you please elaborate?
  
  Can you share your failed attempt?
  
  Maybe you can get how revset works by testing expression with
  `hg debugrevspec -v`.

REPOSITORY
  rHG Mercurial

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

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


Re: D5813: revset: add expect to check the size of a set

2019-02-05 Thread Yuya Nishihara
>   > You can try out some combinations of `expect(5:0) & 1:10` and
>   >  `10:1 & expect(0:5)`.
>   
>   I got into many errors while using this. I might be not understanding this 
> correctly. Could you please elaborate?

Can you share your failed attempt?

Maybe you can get how revset works by testing expression with
`hg debugrevspec -v`.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5417: rust: translated random test of missingancestors

2019-02-05 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   @yuja we don't need a seed to reproduce: failed examples contain all the 
information (that's a difference with the Python version)
  
  Yes, but isn't it handy if we can run the same test with some debugging aids?
  
  I didn't carefully look through the original patch, so maybe I miss the point.
  But IIRC, this test had some parameters we would probably want to tune. The
  random seed is just an example.

REPOSITORY
  rHG Mercurial

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

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


Re: D5417: rust: translated random test of missingancestors

2019-02-05 Thread Yuya Nishihara
>   @yuja we don't need a seed to reproduce: failed examples contain all the 
> information (that's a difference with the Python version)

Yes, but isn't it handy if we can run the same test with some debugging aids?

I didn't carefully look through the original patch, so maybe I miss the point.
But IIRC, this test had some parameters we would probably want to tune. The
random seed is just an example.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: Google Summer of Code 2019.

2019-02-05 Thread Sushil Khanchi
Hi,

As I was Google Summer of Code student last year I know how much important
it is for a student to have a mentor who will review the patches or provide
pointer to the right person for a particular topic. I would love to work
with a student and happy to see a new contributor in mercurial community.
If there is a project where I can be a part of mentoring, I am very much
interested to have that opportunity.

Thanks
Sushil

On Tue, Feb 5, 2019 at 9:24 PM Pulkit Goyal <7895pul...@gmail.com> wrote:

> Hey everyone,
>
> I hope you're doing well.
>
> We missed the initial deadline for application to PSF for Google Summer of
> Code. Don't be scared, things are fine. Once google announces the list of
> organizations, PSF can accept more sub-orgs. Google will announce list of
> orgs on 26th Feb.
>
> So let's get ourselves prepared till then. I am happy to manage things for
> us this year too. But if someone else wants to take up, I am happy to share
> the load.
>
> That said, we need project ideas and mentors.
>
> The coding period is of roughly three months. Hence project should not be
> very small. Projects can be big and we can put initial part of that in
> summer of code and if student wants to continue contributing, they can
> maybe complete that.
> In past years, we had project ideas like python3-porting, releasenotes
> extension, improvement to largefiles, improving grep etc.
> If you have any such project idea, please reply to this email. Good
> project ideas will help us get more applications.
>
> We also need people to mentor. Quoting from summer of code webiste:
>
> Mentors are people from the community who volunteer to work with a
> student. Mentors provide guidance such as pointers to useful documentation,
> code reviews, etc. In addition to providing students with feedback and
> pointers, a mentor acts as an ambassador to help student contributors
> integrate into their project’s community.
>
> If you are willing to mentor, please reply to this email.
>
> Thanks and regards
> Pulkit
>
> ___
> 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


D5862: py3: use '%d' for integers instead of '%s'

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I think this is the last of these occurences because I have got the test 
passing
  on python3 in a later patch.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/convert/monotone.py

CHANGE DETAILS

diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -154,7 +154,7 @@
 retval = []
 while True:
 commandnbr, stream, length, output = self.mtnstdioreadpacket()
-self.ui.debug('mtn: read packet %s:%s:%s\n' %
+self.ui.debug('mtn: read packet %s:%s:%d\n' %
 (commandnbr, stream, length))
 
 if stream == 'l':



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


D5864: py3: use pycompat.bytestr() on extra values because it can be int

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One such example is {'close': 1} which marks a branch as closed.
  
  This makes test-convert-mtn.t pass on Python 3.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist
  mercurial/changelog.py

CHANGE DETAILS

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -70,7 +70,10 @@
 
 def encodeextra(d):
 # keys must be sorted to produce a deterministic changelog entry
-items = [_string_escape('%s:%s' % (k, d[k])) for k in sorted(d)]
+items = [
+_string_escape('%s:%s' % (k, pycompat.bytestr(d[k])))
+for k in sorted(d)
+]
 return "\0".join(items)
 
 def stripdesc(desc):
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -121,6 +121,7 @@
 test-convert-hg-sink.t
 test-convert-hg-source.t
 test-convert-hg-startrev.t
+test-convert-mtn.t
 test-convert-splicemap.t
 test-convert-svn-sink.t
 test-convert-tagsbranch-topology.t



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


D5863: py3: add some b'' prefixes in hgext/convert/monotone.py

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  1. skip-blame because just b'' prefixes

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/convert/monotone.py

CHANGE DETAILS

diff --git a/hgext/convert/monotone.py b/hgext/convert/monotone.py
--- a/hgext/convert/monotone.py
+++ b/hgext/convert/monotone.py
@@ -219,8 +219,8 @@
 m = self.cert_re.match(e)
 if m:
 name, value = m.groups()
-value = value.replace(r'\"', '"')
-value = value.replace(r'\\', '\\')
+value = value.replace(br'\"', '"')
+value = value.replace(br'\\', '\\')
 certs[name] = value
 # Monotone may have subsecond dates: 2005-02-05T09:39:12.364306
 # and all times are stored in UTC



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


D5849: merge: don't unnecessarily calculate absolute path

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1f2714052d7e: merge: don't unnecessarily calculate 
absolute path (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5849?vs=13810&id=13827

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1499,13 +1499,14 @@
 # If a file or directory exists with the same name, back that
 # up.  Otherwise, look to see if there is a file that conflicts
 # with a directory this file is in, and if so, back that up.
-absf = repo.wjoin(f)
+conflicting = f
 if not repo.wvfs.lexists(f):
 for p in util.finddirs(f):
 if repo.wvfs.isfileorlink(p):
-absf = repo.wjoin(p)
+conflicting = p
 break
-if repo.wvfs.lexists(absf):
+if repo.wvfs.lexists(conflicting):
+absf = repo.wjoin(conflicting)
 orig = scmutil.origpath(ui, repo, absf)
 util.rename(absf, orig)
 wctx[f].clearunknown()



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


D5853: revert: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz added inline comments.

INLINE COMMENTS

> cmdutil.py:3017-3018
> +bakname = scmutil.backuppath(ui, repo, abs)
>  ui.note(_('saving current version of %s as 
> %s\n') %
>  (rel, bakname))
>  if not opts.get('dry_run'):

Sorry, there is a regression here: if you're in a subdirectory, this used to 
say "saving current version of foo as foo.orig", but now it will say "saving 
current version of foo as dir/foo.orig". So please don't queue this yet. I'll 
need to insert some patches earlier in the series.

REPOSITORY
  rHG Mercurial

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

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


D5861: py3: add 1 new passing test found by buildbot

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will make py3 buildbot green again.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/python3-whitelist

CHANGE DETAILS

diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -760,5 +760,6 @@
 test-wireproto-serverreactor.py
 test-wireproto.py
 test-wireproto.t
+test-worker.t
 test-wsgirequest.py
 test-xdg.t



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


D5848: merge: don't unnecessarily calculate backup path

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGef2295651351: merge: don't unnecessarily calculate 
backup path (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5848?vs=13809&id=13826

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1505,8 +1505,8 @@
 if repo.wvfs.isfileorlink(p):
 absf = repo.wjoin(p)
 break
-orig = scmutil.origpath(ui, repo, absf)
 if repo.wvfs.lexists(absf):
+orig = scmutil.origpath(ui, repo, absf)
 util.rename(absf, orig)
 wctx[f].clearunknown()
 atomictemp = ui.configbool("experimental", "update.atomic-file")



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


D5847: largefiles: drop "rel" prefix from filename variables

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG641c8b66a825: largefiles: drop "rel" prefix from 
filename variables (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5847?vs=13801&id=13825

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

AFFECTED FILES
  hgext/largefiles/lfcommands.py

CHANGE DETAILS

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -464,27 +464,26 @@
 wvfs = repo.wvfs
 wctx = repo[None]
 for lfile in lfiles:
-rellfile = lfile
-rellfileorig = os.path.relpath(
-scmutil.origpath(ui, repo, wvfs.join(rellfile)),
+lfileorig = os.path.relpath(
+scmutil.origpath(ui, repo, wvfs.join(lfile)),
 start=repo.root)
-relstandin = lfutil.standin(lfile)
-relstandinorig = os.path.relpath(
-scmutil.origpath(ui, repo, wvfs.join(relstandin)),
+standin = lfutil.standin(lfile)
+standinorig = os.path.relpath(
+scmutil.origpath(ui, repo, wvfs.join(standin)),
 start=repo.root)
-if wvfs.exists(relstandin):
-if (wvfs.exists(relstandinorig) and
-wvfs.exists(rellfile)):
-shutil.copyfile(wvfs.join(rellfile),
-wvfs.join(rellfileorig))
-wvfs.unlinkpath(relstandinorig)
-expecthash = lfutil.readasstandin(wctx[relstandin])
+if wvfs.exists(standin):
+if (wvfs.exists(standinorig) and
+wvfs.exists(lfile)):
+shutil.copyfile(wvfs.join(lfile),
+wvfs.join(lfileorig))
+wvfs.unlinkpath(standinorig)
+expecthash = lfutil.readasstandin(wctx[standin])
 if expecthash != '':
 if lfile not in wctx: # not switched to normal file
-if repo.dirstate[relstandin] != '?':
-wvfs.unlinkpath(rellfile, ignoremissing=True)
+if repo.dirstate[standin] != '?':
+wvfs.unlinkpath(lfile, ignoremissing=True)
 else:
-dropped.add(rellfile)
+dropped.add(lfile)
 
 # use normallookup() to allocate an entry in largefiles
 # dirstate to prevent lfilesrepo.status() from reporting
@@ -496,9 +495,9 @@
 # lfile is added to the repository again. This happens when a
 # largefile is converted back to a normal file: the standin
 # disappears, but a new (normal) file appears as the lfile.
-if (wvfs.exists(rellfile) and
+if (wvfs.exists(lfile) and
 repo.dirstate.normalize(lfile) not in wctx):
-wvfs.unlinkpath(rellfile)
+wvfs.unlinkpath(lfile)
 removed += 1
 
 # largefile processing might be slow and be interrupted - be prepared
@@ -532,19 +531,18 @@
 
 # copy the exec mode of largefile standin from the repository's
 # dirstate to its state in the lfdirstate.
-rellfile = lfile
-relstandin = lfutil.standin(lfile)
-if wvfs.exists(relstandin):
+standin = lfutil.standin(lfile)
+if wvfs.exists(standin):
 # exec is decided by the users permissions using mask 0o100
-standinexec = wvfs.stat(relstandin).st_mode & 0o100
-st = wvfs.stat(rellfile)
+standinexec = wvfs.stat(standin).st_mode & 0o100
+st = wvfs.stat(lfile)
 mode = st.st_mode
 if standinexec != mode & 0o100:
 # first remove all X bits, then shift all R bits to X
 mode &= ~0o111
 if standinexec:
 mode |= (mode >> 2) & 0o111 & ~util.umask
-wvfs.chmod(rellfile, mode)
+wvfs.chmod(lfile, mode)
 update1 = 1
 
 updated += update1



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


D5858: resolve: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4971,7 +4971,7 @@
 if complete:
 try:
 util.rename(a + ".resolve",
-scmutil.origpath(ui, repo, a))
+repo.wjoin(scmutil.backuppath(ui, repo, 
f)))
 except OSError as inst:
 if inst.errno != errno.ENOENT:
 raise
@@ -4997,7 +4997,8 @@
 # replace filemerge's .orig file with our resolve file
 a = repo.wjoin(f)
 try:
-util.rename(a + ".resolve", scmutil.origpath(ui, repo, a))
+util.rename(a + ".resolve",
+repo.wjoin(scmutil.backuppath(ui, repo, f)))
 except OSError as inst:
 if inst.errno != errno.ENOENT:
 raise



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


D5860: scmutil: delete now-unused origpath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D5860#85771, @pulkit wrote:
  
  > This should be marked as API IIUC, right?
  
  
  Yes, good point, I'll do that.

REPOSITORY
  rHG Mercurial

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

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


D5860: scmutil: delete now-unused origpath()

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  This should be marked as API IIUC, right?

REPOSITORY
  rHG Mercurial

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

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


D5816: global: make some docstrings raw strings

2019-02-05 Thread indygreg (Gregory Szorc)
indygreg added a comment.


  In https://phab.mercurial-scm.org/D5816#85618, @pulkit wrote:
  
  > Should we add `# skip-blame` to this and rest of the series as they are 
just adding of r'' prefixes?
  
  
  I'm not sure. If there are `\` in the string, adding the `r''` can change the 
value of the string. If we introduce a bug through these changes, using 
`skip-blame` will make it harder to find that change. It's probably safe to do 
though, as we should be able to count on review to find any meaningful value 
changes.

REPOSITORY
  rHG Mercurial

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

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


D5860: scmutil: delete now-unused origpath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It has been replaced by backuppath().

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -875,41 +875,6 @@
 
 return origvfs.join(filepath)
 
-def origpath(ui, repo, filepath):
-'''customize where .orig files are created
-
-Fetch user defined path from config file: [ui] origbackuppath = 
-Fall back to default (filepath with .orig suffix) if not specified
-'''
-origvfs = getorigvfs(ui, repo)
-if origvfs is None:
-return filepath + ".orig"
-
-# Convert filepath from an absolute path into a path inside the repo.
-filepathfromroot = util.normpath(os.path.relpath(filepath,
- start=repo.root))
-
-origbackupdir = origvfs.dirname(filepathfromroot)
-if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
-ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
-
-# Remove any files that conflict with the backup file's path
-for f in reversed(list(util.finddirs(filepathfromroot))):
-if origvfs.isfileorlink(f):
-ui.note(_('removing conflicting file: %s\n')
-% origvfs.join(f))
-origvfs.unlink(f)
-break
-
-origvfs.makedirs(origbackupdir)
-
-if origvfs.isdir(filepathfromroot) and not 
origvfs.islink(filepathfromroot):
-ui.note(_('removing conflicting directory: %s\n')
-% origvfs.join(filepathfromroot))
-origvfs.rmtree(filepathfromroot, forcibly=True)
-
-return origvfs.join(filepathfromroot)
-
 class _containsnode(object):
 """proxy __contains__(node) to container.__contains__ which accepts revs"""
 



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


D5859: subrepo: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/subrepo.py

CHANGE DETAILS

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -1828,11 +1828,10 @@
 if origvfs is None:
 origvfs = self.wvfs
 for name in names:
-bakname = scmutil.origpath(self.ui, self._subparent, name)
+bakname = scmutil.backuppath(self.ui, self._subparent, name)
 self.ui.note(_('saving current version of %s as %s\n') %
 (name, bakname))
-name = self.wvfs.join(name)
-origvfs.rename(name, bakname)
+origvfs.rename(self.wvfs.join(name), self.wvfs.join(bakname))
 
 if not opts.get(r'dry_run'):
 self.get(substate, overwrite=True)



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


D5855: mq: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/mq.py

CHANGE DETAILS

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -738,10 +738,10 @@
 for f in sorted(files):
 absf = repo.wjoin(f)
 if os.path.lexists(absf):
+orig = scmutil.backuppath(self.ui, repo, f)
 self.ui.note(_('saving current version of %s as %s\n') %
- (f, scmutil.origpath(self.ui, repo, f)))
-
-absorig = scmutil.origpath(self.ui, repo, absf)
+ (f, orig))
+absorig = repo.wjoin(orig)
 if copy:
 util.copyfile(absf, absorig)
 else:



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


D5857: merge: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1506,9 +1506,8 @@
 conflicting = p
 break
 if repo.wvfs.lexists(conflicting):
-absf = repo.wjoin(conflicting)
-orig = scmutil.origpath(ui, repo, absf)
-util.rename(absf, orig)
+orig = scmutil.backuppath(ui, repo, conflicting)
+util.rename(repo.wjoin(conflicting), repo.wjoin(orig))
 wctx[f].clearunknown()
 atomictemp = ui.configbool("experimental", "update.atomic-file")
 wctx[f].write(fctx(f).data(), flags, backgroundclose=True,



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


D5853: revert: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2999,8 +2999,6 @@
 )
 
 for abs, (rel, exact) in sorted(names.items()):
-# target file to be touch on disk (relative to cwd)
-target = repo.wjoin(abs)
 # search the entry in the dispatch table.
 # if the file is in any of these sets, it was touched in the 
working
 # directory parent and we are sure it needs to be reverted.
@@ -3015,14 +3013,15 @@
 if dobackup == backupinteractive:
 tobackup.add(abs)
 elif (backup <= dobackup or wctx[abs].cmp(ctx[abs])):
-bakname = scmutil.origpath(ui, repo, rel)
+bakname = scmutil.backuppath(ui, repo, abs)
 ui.note(_('saving current version of %s as %s\n') %
 (rel, bakname))
 if not opts.get('dry_run'):
+target = repo.wjoin(abs)
 if interactive:
-util.copyfile(target, bakname)
+util.copyfile(target, repo.wjoin(bakname))
 else:
-util.rename(target, bakname)
+util.rename(target, repo.wjoin(bakname))
 if opts.get('dry_run'):
 if ui.verbose or not exact:
 ui.status(msg % rel)
@@ -3165,8 +3164,8 @@
 # Create a backup file only if this hunk should be backed up
 if c.header.filename() in tobackup:
 target = repo.wjoin(abs)
-bakname = scmutil.origpath(repo.ui, repo, m.rel(abs))
-util.copyfile(target, bakname)
+bakname = scmutil.backuppath(repo.ui, repo, abs)
+util.copyfile(target, repo.wjoin(bakname))
 tobackup.remove(abs)
 c.write(fp)
 dopatch = fp.tell()



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


D5856: filemerge: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/filemerge.py

CHANGE DETAILS

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -743,8 +743,7 @@
 # TODO: Break this import cycle somehow. (filectx -> ctx -> fileset ->
 # merge -> filemerge). (I suspect the fileset import is the weakest link)
 from . import context
-a = _workingpath(repo, fcd)
-back = scmutil.origpath(ui, repo, a)
+back = repo.wjoin(scmutil.backuppath(ui, repo, fcd.path()))
 inworkingdir = (back.startswith(repo.wvfs.base) and not
 back.startswith(repo.vfs.base))
 if isinstance(fcd, context.overlayworkingfilectx) and inworkingdir:
@@ -764,6 +763,7 @@
 if isinstance(fcd, context.overlayworkingfilectx):
 util.writefile(back, fcd.data())
 else:
+a = _workingpath(repo, fcd)
 util.copyfile(a, back)
 # A arbitraryfilectx is returned, so we can run the same functions on
 # the backup context regardless of where it lives.



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


D5852: shelve: fix broken backup of conflicting untracked file

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/shelve.py
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -139,22 +139,13 @@
   0 files updated, 0 files merged, 2 files removed, 0 files unresolved
   $ echo z > e
   $ mkdir dir
-BROKEN: should work the same as when not using --cwd
   $ hg unshelve --cwd dir
   unshelving change 'default'
-  abort: $ENOENT$
-  [255]
   $ rmdir dir
   $ cat e
-  z
+  e
   $ cat e.orig
-  cat: e.orig: $ENOENT$
-  [1]
-restore broken state
-  $ touch d
-  $ echo e > e
-  $ hg add d e
-  $ hg shelve --delete default
+  z
 
 unshelve and conflicts with tracked and untracked files
 
diff --git a/hgext/shelve.py b/hgext/shelve.py
--- a/hgext/shelve.py
+++ b/hgext/shelve.py
@@ -679,7 +679,8 @@
 # revert will overwrite unknown files, so move them out of the way
 for file in repo.status(unknown=True).unknown:
 if file in files:
-util.rename(file, scmutil.origpath(ui, repo, file))
+util.rename(repo.wjoin(file),
+repo.wjoin(scmutil.backuppath(ui, repo, file)))
 ui.pushbuffer(True)
 cmdutil.revert(ui, repo, shelvectx, repo.dirstate.parents(),
*pathtofiles(repo, files),



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


D5854: largefiles: migrate to scmutil.backuppath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It seems unnecessary to convert the paths here back to repo-relative
  paths, but I'll leave that for someone else to clean up.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  hgext/largefiles/lfcommands.py

CHANGE DETAILS

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -465,11 +465,11 @@
 wctx = repo[None]
 for lfile in lfiles:
 lfileorig = os.path.relpath(
-scmutil.origpath(ui, repo, wvfs.join(lfile)),
+repo.wjoin(scmutil.backuppath(ui, repo, lfile)),
 start=repo.root)
 standin = lfutil.standin(lfile)
 standinorig = os.path.relpath(
-scmutil.origpath(ui, repo, wvfs.join(standin)),
+repo.wjoin(scmutil.backuppath(ui, repo, standin)),
 start=repo.root)
 if wvfs.exists(standin):
 if (wvfs.exists(standinorig) and



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


D5851: scmutil: introduce a new backuppath() to replace origpath()

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Unlike most functions in our codebase, origpath() takes a path that is
  relative to cwd. This commit introduces a replacement for
  origpath(). The new function takes a path that is relative to the repo
  root. There is a lot of duplication between the two, but I intend to
  remove origpath() within the next few commits, so it won't be a
  maintenance burden.
  
  origpath() is also a little weird in that it returns either a a
  cwd-relative path or an absolute path. It needs to be able to return a
  path outside the repo, so it makes sense that it can return an
  absolute path. However, it would be simpler to always return an
  absolute path. At first I attempted to change that too in the new
  function. That wasn't trivial since the returned path often gets
  displayed to the user (things like "moving file dir/file to
  dir/file.orig") and we don't want to always display absolute paths
  there. It should probably be the caller's responsibility to convert
  back to repo-relative, or cwd-relative, path if desirable. However, we
  can safely do that as a follow-up later, since the caller has to call
  repo.wjoin() on the result anyway.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -838,6 +838,43 @@
 return None
 return vfs.vfs(repo.wvfs.join(origbackuppath))
 
+def backuppath(ui, repo, filepath):
+'''customize where working copy backup files (.orig files) are created
+
+Fetch user defined path from config file: [ui] origbackuppath = 
+Fall back to default (filepath with .orig suffix) if not specified
+
+filepath is repo-relative
+
+Returns a repo-relative path *or* an absolute path. The caller is thus
+expected to call repo.wjoin() on the result before passing it to e.g.
+util.rename().
+'''
+origvfs = getorigvfs(ui, repo)
+if origvfs is None:
+return filepath + ".orig"
+
+origbackupdir = origvfs.dirname(filepath)
+if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
+ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
+
+# Remove any files that conflict with the backup file's path
+for f in reversed(list(util.finddirs(filepath))):
+if origvfs.isfileorlink(f):
+ui.note(_('removing conflicting file: %s\n')
+% origvfs.join(f))
+origvfs.unlink(f)
+break
+
+origvfs.makedirs(origbackupdir)
+
+if origvfs.isdir(filepath) and not origvfs.islink(filepath):
+ui.note(_('removing conflicting directory: %s\n')
+% origvfs.join(filepath))
+origvfs.rmtree(filepath, forcibly=True)
+
+return origvfs.join(filepath)
+
 def origpath(ui, repo, filepath):
 '''customize where .orig files are created
 



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


D5850: tests: demonstrate broken unshelve when backing up untracked file

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-shelve2.t

CHANGE DETAILS

diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t
--- a/tests/test-shelve2.t
+++ b/tests/test-shelve2.t
@@ -130,13 +130,37 @@
   e
   $ cat e.orig
   z
+  $ rm e.orig
 
+restores backup of unknown file to right directory
+
+  $ hg shelve
+  shelved as default
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ echo z > e
+  $ mkdir dir
+BROKEN: should work the same as when not using --cwd
+  $ hg unshelve --cwd dir
+  unshelving change 'default'
+  abort: $ENOENT$
+  [255]
+  $ rmdir dir
+  $ cat e
+  z
+  $ cat e.orig
+  cat: e.orig: $ENOENT$
+  [1]
+restore broken state
+  $ touch d
+  $ echo e > e
+  $ hg add d e
+  $ hg shelve --delete default
 
 unshelve and conflicts with tracked and untracked files
 
  preparing:
 
-  $ rm *.orig
+  $ rm -f *.orig
   $ hg ci -qm 'commit stuff'
   $ hg phase -p null:
 



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


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13811.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5800?vs=13732&id=13811

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

AFFECTED FILES
  mercurial/commands.py
  mercurial/configitems.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -725,9 +725,32 @@
 return []
 return parents
 
-def getuipathfn(repo, relative=None):
-if relative is None:
-relative = repo.ui.configbool('ui', 'relative-paths')
+def getuipathfn(repo, legacyrelativevalue=False, forcerelativevalue=None):
+"""Return a function that produced paths for presenting to the user.
+
+The returned function takes a repo-relative path and produces a path
+that can be presented in the UI.
+
+Depending on the value of ui.relative-paths, either a repo-relative or
+cwd-relative path will be produced.
+
+legacyrelativevalue is the value to use if ui.relative-paths=legacy
+
+If forcerelativevalue is not None, then that value will be used regardless
+of what ui.relative-paths is set to.
+"
+if forcerelativevalue is not None:
+relative = forcerelativevalue
+else:
+config = repo.ui.config('ui', 'relative-paths')
+if config == 'legacy':
+relative = legacyrelativevalue
+else:
+relative = stringutil.parsebool(config)
+if relative is None:
+raise error.ConfigError(
+_("ui.relative-paths is not a boolean ('%s')") % config)
+
 if relative:
 cwd = repo.getcwd()
 pathto = repo.pathto
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -1234,7 +1234,7 @@
 default=False,
 )
 coreconfigitem('ui', 'relative-paths',
-default=False,
+default='legacy',
 )
 coreconfigitem('ui', 'remotecmd',
 default='hg',
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -5421,7 +5421,7 @@
 relative = True
 elif ui.hasconfig('commands', 'status.relative'):
 relative = ui.configbool('commands', 'status.relative')
-uipathfn = scmutil.getuipathfn(repo, relative)
+uipathfn = scmutil.getuipathfn(repo, forcerelativevalue=relative)
 
 if opts.get('print0'):
 end = '\0'



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


D5802: status: if ui.relative-paths=no, don't use relative paths even with patterns

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13813.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5802?vs=13734&id=13813

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

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

CHANGE DETAILS

diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -132,18 +132,21 @@
 
 relative paths can be requested
 
-  $ cat >> $HGRCPATH < [ui]
-  > relative-paths = True
-  > EOF
-  $ hg status --cwd a
+  $ hg status --cwd a --config ui.relative-paths=yes
   ? 1/in_a_1
   ? in_a
   ? ../b/1/in_b_1
   ? ../b/2/in_b_2
   ? ../b/in_b
   ? ../in_root
 
+  $ hg status --cwd a . --config ui.relative-paths=legacy
+  ? 1/in_a_1
+  ? in_a
+  $ hg status --cwd a . --config ui.relative-paths=no
+  ? a/1/in_a_1
+  ? a/in_a
+
 commands.status.relative overrides ui.relative-paths
 
   $ cat >> $HGRCPATH 

D5801: files: respect ui.relative-paths

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz updated this revision to Diff 13812.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5801?vs=13733&id=13812

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

AFFECTED FILES
  mercurial/cmdutil.py
  tests/test-locate.t

CHANGE DETAILS

diff --git a/tests/test-locate.t b/tests/test-locate.t
--- a/tests/test-locate.t
+++ b/tests/test-locate.t
@@ -123,6 +123,24 @@
   ../t.h
   ../t/e.h
   ../t/x
+  $ hg files --config ui.relative-paths=yes
+  ../b
+  ../dir.h/foo
+  ../t.h
+  ../t/e.h
+  ../t/x
+  $ hg files --config ui.relative-paths=no
+  b
+  dir.h/foo
+  t.h
+  t/e.h
+  t/x
+  $ hg files --config ui.relative-paths=legacy
+  ../b
+  ../dir.h/foo
+  ../t.h
+  ../t/e.h
+  ../t/x
 
   $ hg locate b
   ../b
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2162,14 +2162,15 @@
 ret = 1
 
 needsfctx = ui.verbose or {'size', 'flags'} & fm.datahint()
+uipathfn = scmutil.getuipathfn(ctx.repo(), legacyrelativevalue=True)
 for f in ctx.matches(m):
 fm.startitem()
 fm.context(ctx=ctx)
 if needsfctx:
 fc = ctx[f]
 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags())
 fm.data(path=f)
-fm.plain(fmt % m.rel(f))
+fm.plain(fmt % uipathfn(f))
 ret = 0
 
 for subpath in sorted(ctx.substate):



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


D5849: merge: don't unnecessarily calculate absolute path

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D5849#85665, @pulkit wrote:
  
  > > I think this also makes the code clearer (and prepares for the next
  > >  patch).
  >
  > I don't see a next patch.
  
  
  Oops, true. I'll rephase to be more vague :)

REPOSITORY
  rHG Mercurial

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

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


D5849: merge: don't unnecessarily calculate absolute path

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit accepted this revision.
pulkit added a comment.


  > I think this also makes the code clearer (and prepares for the next
  >  patch).
  
  I don't see a next patch.

REPOSITORY
  rHG Mercurial

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

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


D5813: revset: add expect to check the size of a set

2019-02-05 Thread navaneeth.suresh (Navaneeth Suresh)
navaneeth.suresh added a comment.


  > First, I think the word `expect` is too general. Perhaps, this should be 
called
  >  `expectsize()` or `expectlen()`.
  
  I can make it `expectsize()`.
  
  > It's also unclear what's the difference between `size` and `min`/`max`.
  >  Instead of these parameters, maybe we can add a `size` parameter that takes
  >  a number or a range `min:max`. See also the following patch.
  > 
  > 
https://www.mercurial-scm.org/pipermail/mercurial-devel/2019-February/127916.html
  
  Unfortunately, I can't see this in `hg-stable` which I was working.
  
  >> +if len(rev) != n:
  >>  +raise error.Abort(_('revset is not of expected size'))
  > 
  > Better to raise RepoLookupError so the error can be caught by 
`present(...)`.
  
  For sure. I could do that.
  
  >> +return rev
  > 
  > You need to filter rev by subset. Since we'll probably want to get an 
ordered
  >  result from `expect(set)`, we'll have to conditionalize the filtering 
direction:
  > 
  >   if order == followorder:
  >   return subset & rev
  >   else:
  >   return rev & subset
  > 
  > 
  > You can try out some combinations of `expect(5:0) & 1:10` and
  >  `10:1 & expect(0:5)`.
  
  I got into many errors while using this. I might be not understanding this 
correctly. Could you please elaborate?

REPOSITORY
  rHG Mercurial

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

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


D5849: merge: don't unnecessarily calculate absolute path

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I think this also makes the code clearer (and prepares for the next
  patch).

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1499,13 +1499,14 @@
 # If a file or directory exists with the same name, back that
 # up.  Otherwise, look to see if there is a file that conflicts
 # with a directory this file is in, and if so, back that up.
-absf = repo.wjoin(f)
+conflicting = f
 if not repo.wvfs.lexists(f):
 for p in util.finddirs(f):
 if repo.wvfs.isfileorlink(p):
-absf = repo.wjoin(p)
+conflicting = p
 break
-if repo.wvfs.lexists(absf):
+if repo.wvfs.lexists(conflicting):
+absf = repo.wjoin(conflicting)
 orig = scmutil.origpath(ui, repo, absf)
 util.rename(absf, orig)
 wctx[f].clearunknown()



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


D5848: merge: don't unnecessarily calculate backup path

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/merge.py

CHANGE DETAILS

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1505,8 +1505,8 @@
 if repo.wvfs.isfileorlink(p):
 absf = repo.wjoin(p)
 break
-orig = scmutil.origpath(ui, repo, absf)
 if repo.wvfs.lexists(absf):
+orig = scmutil.origpath(ui, repo, absf)
 util.rename(absf, orig)
 wctx[f].clearunknown()
 atomictemp = ui.configbool("experimental", "update.atomic-file")



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


D5635: branchmap: make branchcache responsible for reading

2019-02-05 Thread mjpieters (Martijn Pieters)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGbf7fb97aecf1: branchmap: make branchcache responsible for 
reading (authored by mjpieters, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5635?vs=13542&id=13806

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

AFFECTED FILES
  contrib/perf.py
  mercurial/branchmap.py

CHANGE DETAILS

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -30,63 +30,6 @@
 pack_into = struct.pack_into
 unpack_from = struct.unpack_from
 
-def _filename(repo):
-"""name of a branchcache file for a given repo or repoview"""
-filename = "branch2"
-if repo.filtername:
-filename = '%s-%s' % (filename, repo.filtername)
-return filename
-
-def read(repo):
-f = None
-try:
-f = repo.cachevfs(_filename(repo))
-lineiter = iter(f)
-cachekey = next(lineiter).rstrip('\n').split(" ", 2)
-last, lrev = cachekey[:2]
-last, lrev = bin(last), int(lrev)
-filteredhash = None
-if len(cachekey) > 2:
-filteredhash = bin(cachekey[2])
-bcache = branchcache(tipnode=last, tiprev=lrev,
-  filteredhash=filteredhash)
-if not bcache.validfor(repo):
-# invalidate the cache
-raise ValueError(r'tip differs')
-cl = repo.changelog
-for l in lineiter:
-l = l.rstrip('\n')
-if not l:
-continue
-node, state, label = l.split(" ", 2)
-if state not in 'oc':
-raise ValueError(r'invalid branch state')
-label = encoding.tolocal(label.strip())
-node = bin(node)
-if not cl.hasnode(node):
-raise ValueError(
-r'node %s does not exist' % pycompat.sysstr(hex(node)))
-bcache.setdefault(label, []).append(node)
-if state == 'c':
-bcache._closednodes.add(node)
-
-except (IOError, OSError):
-return None
-
-except Exception as inst:
-if repo.ui.debugflag:
-msg = 'invalid branchheads cache'
-if repo.filtername is not None:
-msg += ' (%s)' % repo.filtername
-msg += ': %s\n'
-repo.ui.debug(msg % pycompat.bytestr(inst))
-bcache = None
-
-finally:
-if f:
-f.close()
-
-return bcache
 
 ### Nearest subset relation
 # Nearest subset of filter X is a filter Y so that:
@@ -107,7 +50,7 @@
 
 revs = []
 if bcache is None or not bcache.validfor(repo):
-bcache = read(repo)
+bcache = branchcache.fromfile(repo)
 if bcache is None:
 subsetname = subsettable.get(filtername)
 if subsetname is None:
@@ -181,6 +124,64 @@
 This field can be used to avoid changelog reads when determining if a
 branch head closes a branch or not.
 """
+@classmethod
+def fromfile(cls, repo):
+f = None
+try:
+f = repo.cachevfs(cls._filename(repo))
+lineiter = iter(f)
+cachekey = next(lineiter).rstrip('\n').split(" ", 2)
+last, lrev = cachekey[:2]
+last, lrev = bin(last), int(lrev)
+filteredhash = None
+if len(cachekey) > 2:
+filteredhash = bin(cachekey[2])
+bcache = cls(tipnode=last, tiprev=lrev, filteredhash=filteredhash)
+if not bcache.validfor(repo):
+# invalidate the cache
+raise ValueError(r'tip differs')
+cl = repo.changelog
+for line in lineiter:
+line = line.rstrip('\n')
+if not line:
+continue
+node, state, label = line.split(" ", 2)
+if state not in 'oc':
+raise ValueError(r'invalid branch state')
+label = encoding.tolocal(label.strip())
+node = bin(node)
+if not cl.hasnode(node):
+raise ValueError(
+r'node %s does not exist' % pycompat.sysstr(hex(node)))
+bcache.setdefault(label, []).append(node)
+if state == 'c':
+bcache._closednodes.add(node)
+
+except (IOError, OSError):
+return None
+
+except Exception as inst:
+if repo.ui.debugflag:
+msg = 'invalid branchheads cache'
+if repo.filtername is not None:
+msg += ' (%s)' % repo.filtername
+msg += ': %s\n'
+repo.ui.debug(msg % pycompat.bytestr(inst))
+bcache = None
+
+finally:
+if f:
+f.close()
+
+return bcache
+
+@staticmethod
+def _filename(repo):
+"""

D5637: branchmap: add some clarifications and clean up flow

2019-02-05 Thread mjpieters (Martijn Pieters)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGc795c462b1d6: branchmap: add some clarifications and clean 
up flow (authored by mjpieters, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5637?vs=13332&id=13808

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

AFFECTED FILES
  mercurial/branchmap.py

CHANGE DETAILS

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -44,22 +44,33 @@
'immutable': 'base'}
 
 def updatecache(repo):
+"""Update the cache for the given filtered view on a repository"""
+# This can trigger updates for the caches for subsets of the filtered
+# view, e.g. when there is no cache for this filtered view or the cache
+# is stale.
+
 cl = repo.changelog
 filtername = repo.filtername
 bcache = repo._branchcaches.get(filtername)
+if bcache is None or not bcache.validfor(repo):
+# cache object missing or cache object stale? Read from disk
+bcache = branchcache.fromfile(repo)
 
 revs = []
-if bcache is None or not bcache.validfor(repo):
-bcache = branchcache.fromfile(repo)
-if bcache is None:
-subsetname = subsettable.get(filtername)
-if subsetname is None:
-bcache = branchcache()
-else:
-subset = repo.filtered(subsetname)
-bcache = subset.branchmap().copy()
-extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
-revs.extend(r for  r in extrarevs if r <= bcache.tiprev)
+if bcache is None:
+# no (fresh) cache available anymore, perhaps we can re-use
+# the cache for a subset, then extend that to add info on missing
+# revisions.
+subsetname = subsettable.get(filtername)
+if subsetname is not None:
+subset = repo.filtered(subsetname)
+bcache = subset.branchmap().copy()
+extrarevs = subset.changelog.filteredrevs - cl.filteredrevs
+revs.extend(r for r in extrarevs if r <= bcache.tiprev)
+else:
+# nothing to fall back on, start empty.
+bcache = branchcache()
+
 revs.extend(cl.revs(start=bcache.tiprev + 1))
 if revs:
 bcache.update(repo, revs)



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


D5636: branchmap: updating triggers a write

2019-02-05 Thread mjpieters (Martijn Pieters)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGeb7ce452e0fb: branchmap: updating triggers a write 
(authored by mjpieters, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5636?vs=13331&id=13807

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

AFFECTED FILES
  mercurial/branchmap.py
  mercurial/discovery.py

CHANGE DETAILS

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -238,7 +238,7 @@
 
 # D. Update newmap with outgoing changes.
 # This will possibly add new heads and remove existing ones.
-newmap = branchmap.branchcache((branch, heads[1])
+newmap = branchmap.remotebranchcache((branch, heads[1])
  for branch, heads in headssum.iteritems()
  if heads[0] is not None)
 newmap.update(repo, (ctx.rev() for ctx in missingctx))
diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -63,7 +63,6 @@
 revs.extend(cl.revs(start=bcache.tiprev + 1))
 if revs:
 bcache.update(repo, revs)
-bcache.write(repo)
 
 assert bcache.validfor(repo), filtername
 repo._branchcaches[repo.filtername] = bcache
@@ -242,8 +241,9 @@
 
 def copy(self):
 """return an deep copy of the branchcache object"""
-return branchcache(self, self.tipnode, self.tiprev, self.filteredhash,
-   self._closednodes)
+return type(self)(
+self, self.tipnode, self.tiprev, self.filteredhash,
+self._closednodes)
 
 def write(self, repo):
 try:
@@ -332,6 +332,15 @@
 repo.ui.log('branchcache', 'updated %s branch cache in %.4f seconds\n',
 repo.filtername, duration)
 
+self.write(repo)
+
+
+class remotebranchcache(branchcache):
+"""Branchmap info for a remote connection, should not write locally"""
+def write(self, repo):
+pass
+
+
 # Revision branch info cache
 
 _rbcversion = '-v1'



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


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread martinvonz (Martin von Zweigbergk)
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D5800#85624, @yuja wrote:
  
  > >   So do we prefer `legacyrelativevalue` then? Or `legacywasrelative`? Or 
`legacyrelative`? (I think the last one is least clear.)
  >
  > `legacyrelativevalue` sounds good to me.
  
  
  Okay, I will update the patch with that name.

REPOSITORY
  rHG Mercurial

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

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


Re: Google Summer of Code 2019.

2019-02-05 Thread Sangeet Kumar Mishra
Hey Pulkit,
Thanks for the detailed write-up.
I can help with mentoring if required.

On Tue, Feb 5, 2019 at 9:23 PM Pulkit Goyal <7895pul...@gmail.com> wrote:

> Hey everyone,
>
> I hope you're doing well.
>
> We missed the initial deadline for application to PSF for Google Summer of
> Code. Don't be scared, things are fine. Once google announces the list of
> organizations, PSF can accept more sub-orgs. Google will announce list of
> orgs on 26th Feb.
>
> So let's get ourselves prepared till then. I am happy to manage things for
> us this year too. But if someone else wants to take up, I am happy to share
> the load.
>
> That said, we need project ideas and mentors.
>
> The coding period is of roughly three months. Hence project should not be
> very small. Projects can be big and we can put initial part of that in
> summer of code and if student wants to continue contributing, they can
> maybe complete that.
> In past years, we had project ideas like python3-porting, releasenotes
> extension, improvement to largefiles, improving grep etc.
> If you have any such project idea, please reply to this email. Good
> project ideas will help us get more applications.
>
> We also need people to mentor. Quoting from summer of code webiste:
>
> Mentors are people from the community who volunteer to work with a
> student. Mentors provide guidance such as pointers to useful documentation,
> code reviews, etc. In addition to providing students with feedback and
> pointers, a mentor acts as an ambassador to help student contributors
> integrate into their project’s community.
>
> If you are willing to mentor, please reply to this email.
>
> Thanks and regards
> Pulkit
>
> ___
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>


-- 
Sangeet Kumar Mishra

Undergraduate,
Indian Institute of Technology, Kharagpur
GitHub  : LinkedIn
 : Facebook

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


Google Summer of Code 2019.

2019-02-05 Thread Pulkit Goyal
Hey everyone,

I hope you're doing well.

We missed the initial deadline for application to PSF for Google Summer of
Code. Don't be scared, things are fine. Once google announces the list of
organizations, PSF can accept more sub-orgs. Google will announce list of
orgs on 26th Feb.

So let's get ourselves prepared till then. I am happy to manage things for
us this year too. But if someone else wants to take up, I am happy to share
the load.

That said, we need project ideas and mentors.

The coding period is of roughly three months. Hence project should not be
very small. Projects can be big and we can put initial part of that in
summer of code and if student wants to continue contributing, they can
maybe complete that.
In past years, we had project ideas like python3-porting, releasenotes
extension, improvement to largefiles, improving grep etc.
If you have any such project idea, please reply to this email. Good project
ideas will help us get more applications.

We also need people to mentor. Quoting from summer of code webiste:

Mentors are people from the community who volunteer to work with a student.
Mentors provide guidance such as pointers to useful documentation, code
reviews, etc. In addition to providing students with feedback and pointers,
a mentor acts as an ambassador to help student contributors integrate into
their project’s community.

If you are willing to mentor, please reply to this email.

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


D5817: attr: make some docstrings raw strings

2019-02-05 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa5493a251ad3: attr: make some docstrings raw strings 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5817?vs=13744&id=13805

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

AFFECTED FILES
  mercurial/thirdparty/attr/_make.py
  mercurial/thirdparty/attr/filters.py

CHANGE DETAILS

diff --git a/mercurial/thirdparty/attr/filters.py 
b/mercurial/thirdparty/attr/filters.py
--- a/mercurial/thirdparty/attr/filters.py
+++ b/mercurial/thirdparty/attr/filters.py
@@ -19,7 +19,7 @@
 
 
 def include(*what):
-"""
+r"""
 Whitelist *what*.
 
 :param what: What to whitelist.
@@ -36,7 +36,7 @@
 
 
 def exclude(*what):
-"""
+r"""
 Blacklist *what*.
 
 :param what: What to blacklist.
diff --git a/mercurial/thirdparty/attr/_make.py 
b/mercurial/thirdparty/attr/_make.py
--- a/mercurial/thirdparty/attr/_make.py
+++ b/mercurial/thirdparty/attr/_make.py
@@ -56,7 +56,7 @@
 def attr(default=NOTHING, validator=None,
  repr=True, cmp=True, hash=None, init=True,
  convert=None, metadata={}):
-"""
+r"""
 Create a new attribute on a class.
 
 ..  warning::



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


D5417: rust: translated random test of missingancestors

2019-02-05 Thread gracinet (Georges Racinet)
gracinet added a comment.


  @yuja we don't need a seed to reproduce: failed examples contain all the 
information (that's a difference with the Python version)

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 3 of 3 V3] revset: leverage getintrange() helper in relation-subscript operation (API)

2019-02-05 Thread Augie Fackler
queued, thanks

> On Feb 1, 2019, at 08:35, Yuya Nishihara  wrote:
> 
> # HG changeset patch
> # User Yuya Nishihara 
> # Date 1548563857 -32400
> #  Sun Jan 27 13:37:37 2019 +0900
> # Node ID 84a273ff0d5254604d1f9d05d2dbdcebaadb5006
> # Parent  28b6a15f5bb2fcfa809532e27cf9008aa4f93d0d
> revset: leverage getintrange() helper in relation-subscript operation (API)
> 
> Now a range expression is parsed by a relation function itself since the
> upper layer have no knowledge about the default first/last bounds.
> 
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -43,7 +43,6 @@ getstring = revsetlang.getstring
> getinteger = revsetlang.getinteger
> getboolean = revsetlang.getboolean
> getlist = revsetlang.getlist
> -getrange = revsetlang.getrange
> getintrange = revsetlang.getintrange
> getargs = revsetlang.getargs
> getargsdict = revsetlang.getargsdict
> @@ -256,14 +255,14 @@ def _splitrange(a, b):
> descdepths = (max(a, 0), b + 1)
> return ancdepths, descdepths
> 
> -def generationsrel(repo, subset, x, rel, a, b, order):
> +def generationsrel(repo, subset, x, rel, z, order):
> # TODO: rewrite tests, and drop startdepth argument from ancestors() and
> # descendants() predicates
> -if a is None:
> -a = -(dagop.maxlogdepth - 1)
> -if b is None:
> -b = +(dagop.maxlogdepth - 1)
> -
> +a, b = getintrange(z,
> +   _('relation subscript must be an integer or a range'),
> +   _('relation subscript bounds must be integers'),
> +   deffirst=-(dagop.maxlogdepth - 1),
> +   deflast=+(dagop.maxlogdepth - 1))
> (ancstart, ancstop), (descstart, descstop) = _splitrange(a, b)
> 
> if ancstart is None and descstart is None:
> @@ -288,21 +287,8 @@ def relsubscriptset(repo, subset, x, y, 
> # experimental so undocumented. see the wiki for further ideas.
> # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
> rel = getsymbol(y)
> -try:
> -a, b = getrange(z, '')
> -except error.ParseError:
> -a = getinteger(z, _("relation subscript must be an integer"))
> -b = a
> -else:
> -def getbound(i):
> -if i is None:
> -return None
> -msg = _("relation subscript bounds must be integers")
> -return getinteger(i, msg)
> -a, b = [getbound(i) for i in (a, b)]
> -
> if rel in subscriptrelations:
> -return subscriptrelations[rel](repo, subset, x, rel, a, b, order)
> +return subscriptrelations[rel](repo, subset, x, rel, z, order)
> 
> relnames = [r for r in subscriptrelations.keys() if len(r) > 1]
> raise error.UnknownIdentifier(rel, relnames)
> diff --git a/tests/test-revset.t b/tests/test-revset.t
> --- a/tests/test-revset.t
> +++ b/tests/test-revset.t
> @@ -643,10 +643,10 @@ parse errors of relation, subscript and 
>   [255]
> 
>   $ hg debugrevspec '.#generations[a]'
> -  hg: parse error: relation subscript must be an integer
> +  hg: parse error: relation subscript must be an integer or a range
>   [255]
>   $ hg debugrevspec '.#generations[1-2]'
> -  hg: parse error: relation subscript must be an integer
> +  hg: parse error: relation subscript must be an integer or a range
>   [255]
>   $ hg debugrevspec '.#generations[foo:bar]'
>   hg: parse error: relation subscript bounds must be integers
> ___
> 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


D5417: rust: translated random test of missingancestors

2019-02-05 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   This test is useful for me, because it's the only one that really tests 
the corectness of MissingAncestor, and it's not a bench either.
  >   I agree it feels out of place in  with the unit tests, so my proposal is 
to make an integration test out of it.
  
  or examples/ to build a dev-only standalone executable?
  
  I don't know which is better, but I think we'll need a way to get around
  the randomness (e.g. pass in a static random seed to reproduce a failed
  example.)

REPOSITORY
  rHG Mercurial

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

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


Re: D5417: rust: translated random test of missingancestors

2019-02-05 Thread Yuya Nishihara
>   This test is useful for me, because it's the only one that really tests the 
> corectness of MissingAncestor, and it's not a bench either.
>   I agree it feels out of place in  with the unit tests, so my proposal is to 
> make an integration test out of it.

or examples/ to build a dev-only standalone executable?

I don't know which is better, but I think we'll need a way to get around
the randomness (e.g. pass in a static random seed to reproduce a failed
example.)
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@41556: 24 new changesets

2019-02-05 Thread Mercurial Commits
24 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/0f64091cc851
changeset:   41533:0f64091cc851
user:Gregory Szorc 
date:Mon Feb 04 09:07:00 2019 -0800
summary: global: make some docstrings raw strings

https://www.mercurial-scm.org/repo/hg/rev/47c92f8ed128
changeset:   41534:47c92f8ed128
user:Gregory Szorc 
date:Mon Feb 04 08:59:11 2019 -0800
summary: patch: properly escape \ in string literals

https://www.mercurial-scm.org/repo/hg/rev/7a90ff8cd14c
changeset:   41535:7a90ff8cd14c
user:Gregory Szorc 
date:Mon Feb 04 09:00:52 2019 -0800
summary: crecord: use raw string for regular expression

https://www.mercurial-scm.org/repo/hg/rev/fb9e11fdcbba
changeset:   41536:fb9e11fdcbba
user:Gregory Szorc 
date:Mon Feb 04 09:01:49 2019 -0800
summary: graphmod: use raw string

https://www.mercurial-scm.org/repo/hg/rev/fc09aafd3c36
changeset:   41537:fc09aafd3c36
user:Gregory Szorc 
date:Mon Feb 04 09:03:10 2019 -0800
summary: convert: use raw string for regular expressions

https://www.mercurial-scm.org/repo/hg/rev/b5642239fb32
changeset:   41538:b5642239fb32
user:Gregory Szorc 
date:Mon Feb 04 09:13:05 2019 -0800
summary: configitems: use raw strings for hidden-{command,topic} items

https://www.mercurial-scm.org/repo/hg/rev/45a4789d3ff2
changeset:   41539:45a4789d3ff2
user:Gregory Szorc 
date:Mon Feb 04 09:31:19 2019 -0800
summary: check-commit: use raw string for regular expression

https://www.mercurial-scm.org/repo/hg/rev/17a6e063c886
changeset:   41540:17a6e063c886
user:Gregory Szorc 
date:Mon Feb 04 09:32:30 2019 -0800
summary: run-tests: use raw strings for regular expressions

https://www.mercurial-scm.org/repo/hg/rev/595a67a301ee
changeset:   41541:595a67a301ee
user:Gregory Szorc 
date:Mon Feb 04 09:34:11 2019 -0800
summary: check-config: use raw strings for regular expressions

https://www.mercurial-scm.org/repo/hg/rev/8d4ee2d9ffb8
changeset:   41542:8d4ee2d9ffb8
user:Gregory Szorc 
date:Mon Feb 04 09:35:55 2019 -0800
summary: drawdag: use raw strings for docstrings

https://www.mercurial-scm.org/repo/hg/rev/dddf53473315
changeset:   41543:dddf53473315
user:Gregory Szorc 
date:Mon Feb 04 09:37:09 2019 -0800
summary: tests: use raw strings for regular expressions with escapes

https://www.mercurial-scm.org/repo/hg/rev/7d1798ec92a3
changeset:   41544:7d1798ec92a3
user:Gregory Szorc 
date:Mon Feb 04 09:38:33 2019 -0800
summary: check-code: use raw string

https://www.mercurial-scm.org/repo/hg/rev/fbb43514f342
changeset:   41545:fbb43514f342
user:Gregory Szorc 
date:Mon Feb 04 09:41:10 2019 -0800
summary: revetbenchmarks: use raw string for regular expression with escapes

https://www.mercurial-scm.org/repo/hg/rev/20e62312e016
changeset:   41546:20e62312e016
user:Gregory Szorc 
date:Mon Feb 04 09:47:13 2019 -0800
summary: run-tests: set attributes in sorted order

https://www.mercurial-scm.org/repo/hg/rev/f16c03c7a3d7
changeset:   41547:f16c03c7a3d7
user:Gregory Szorc 
date:Mon Feb 04 14:00:57 2019 -0800
summary: tests: use raw string in test-check-code.t

https://www.mercurial-scm.org/repo/hg/rev/6dae1f31c6c9
changeset:   41548:6dae1f31c6c9
user:Gregory Szorc 
date:Mon Feb 04 14:03:15 2019 -0800
summary: showstack: use raw docstring

https://www.mercurial-scm.org/repo/hg/rev/1ea1bba1c5be
changeset:   41549:1ea1bba1c5be
user:Gregory Szorc 
date:Mon Feb 04 14:05:26 2019 -0800
summary: tests: use raw strings in test-cbor.py

https://www.mercurial-scm.org/repo/hg/rev/7295279b9ea5
changeset:   41550:7295279b9ea5
user:Gregory Szorc 
date:Mon Feb 04 14:10:10 2019 -0800
summary: tests: escape backslash in makepatch.py inline file

https://www.mercurial-scm.org/repo/hg/rev/033a0f4b4a5f
changeset:   41551:033a0f4b4a5f
user:Gregory Szorc 
date:Mon Feb 04 14:14:25 2019 -0800
summary: tests: use raw strings in test-help.t

https://www.mercurial-scm.org/repo/hg/rev/99b4c6d73a72
changeset:   41552:99b4c6d73a72
user:Gregory Szorc 
date:Mon Feb 04 14:16:52 2019 -0800
summary: testparseutil: escape backslash in docstring

https://www.mercurial-scm.org/repo/hg/rev/eb14ab7db33e
changeset:   41553:eb14ab7db33e
user:Gregory Szorc 
date:Mon Feb 04 14:22:50 2019 -0800
summary: doc: escape backslash

https://www.mercurial-scm.org/repo/hg/rev/01417ca7f2e2
changeset:   41554:01417ca7f2e2
user:Gregory Szorc 
date:Mon Feb 04 14:25:00 2019 -0800
summary: check-py3-compat: provide filename to ast.parse()

https://www.mercurial-scm.org/repo/hg/rev/ba7eaff26474
changeset:   41555:ba7eaff26474
user:Gregory Szorc 
date:Mon Feb 04 14:38:23 2019 -0800
summary: check-py3

D5834: commit/revert: if interactive, look elsewhere for whitespace settings (BC)

2019-02-05 Thread spectral (Kyle Lippincott)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG66399f2e92aa: commit: if interactive, look elsewhere for 
whitespace settings (BC) (authored by spectral, committed by ).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D5834?vs=13761&id=13804#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5834?vs=13761&id=13804

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/configitems.py
  tests/test-commit-interactive.t
  tests/test-split.t

CHANGE DETAILS

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -26,6 +26,8 @@
   > [diff]
   > git=1
   > unified=0
+  > [commands]
+  > commit.interactive.unified=0
   > [alias]
   > glog=log -G -T '{rev}:{node|short} {desc} {bookmarks}\n'
   > EOF
@@ -105,10 +107,10 @@
 
 This function splits a bit strangely primarily to avoid changing the behavior 
of
 the test after a bug was fixed with how split/commit --interactive handled
-`diff.unified=0`: when there were no context lines, it kept only the last diff
-hunk. When running split, this meant that runsplit was always recording three 
commits,
-one for each diff hunk, in reverse order (the base commit was the last diff 
hunk
-in the file).
+`commands.commit.interactive.unified=0`: when there were no context lines,
+it kept only the last diff hunk. When running split, this meant that runsplit
+was always recording three commits, one for each diff hunk, in reverse order
+(the base commit was the last diff hunk in the file).
   $ runsplit() {
   > cat > $TESTTMP/messages < split 1
diff --git a/tests/test-commit-interactive.t b/tests/test-commit-interactive.t
--- a/tests/test-commit-interactive.t
+++ b/tests/test-commit-interactive.t
@@ -1808,7 +1808,7 @@
   $ hg status -A subdir/f1
   M subdir/f1
 
-Test diff.unified=0
+Test commands.commit.interactive.unified=0
 
   $ hg init $TESTTMP/b
   $ cd $TESTTMP/b
@@ -1829,7 +1829,7 @@
   > 4
   > 5
   > EOF
-  $ printf 'y\ny\ny\n' | hg ci -im initial --config diff.unified=0
+  $ printf 'y\ny\ny\n' | hg ci -im initial --config 
commands.commit.interactive.unified=0
   diff --git a/foo b/foo
   2 hunks, 2 lines changed
   examine changes to 'foo'? [Ynesfdaq?] y
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -201,6 +201,7 @@
 coreconfigitem('color', 'pagermode',
 default=dynamicdefault,
 )
+_registerdiffopts(section='commands', configprefix='commit.interactive.')
 coreconfigitem('commands', 'grep.all-files',
 default=False,
 )
@@ -213,6 +214,7 @@
 coreconfigitem('commands', 'resolve.mark-check',
 default='none',
 )
+_registerdiffopts(section='commands', configprefix='revert.interactive.')
 coreconfigitem('commands', 'show.aliasprefix',
 default=list,
 )
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -282,7 +282,9 @@
 status = repo.status(match=match)
 if not force:
 repo.checkcommitpatterns(wctx, vdirs, match, status, fail)
-diffopts = patch.difffeatureopts(ui, opts=opts)
+diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True,
+ section='commands',
+ configprefix='commit.interactive.')
 diffopts.nodates = True
 diffopts.git = True
 diffopts.showfunc = True
@@ -3126,7 +3128,9 @@
 # Prompt the user for changes to revert
 torevert = [f for f in actions['revert'][0] if f not in excluded_files]
 m = scmutil.matchfiles(repo, torevert)
-diffopts = patch.difffeatureopts(repo.ui)
+diffopts = patch.difffeatureopts(repo.ui, whitespace=True,
+ section='commands',
+ configprefix='revert.interactive.')
 diffopts.nodates = True
 diffopts.git = True
 operation = 'discard'



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


D5832: config: extract diff-related coreconfigitem()s to a helper method

2019-02-05 Thread spectral (Kyle Lippincott)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG901ebc81ffb3: config: extract diff-related 
coreconfigitem()s to a helper method (authored by spectral, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5832?vs=13759&id=13802

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

AFFECTED FILES
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -113,46 +113,49 @@
 
 coreconfigitem = getitemregister(coreitems)
 
+def _registerdiffopts(section, configprefix=''):
+coreconfigitem(section, configprefix + 'nodates',
+default=False,
+)
+coreconfigitem(section, configprefix + 'showfunc',
+default=False,
+)
+coreconfigitem(section, configprefix + 'unified',
+default=None,
+)
+coreconfigitem(section, configprefix + 'git',
+default=False,
+)
+coreconfigitem(section, configprefix + 'ignorews',
+default=False,
+)
+coreconfigitem(section, configprefix + 'ignorewsamount',
+default=False,
+)
+coreconfigitem(section, configprefix + 'ignoreblanklines',
+default=False,
+)
+coreconfigitem(section, configprefix + 'ignorewseol',
+default=False,
+)
+coreconfigitem(section, configprefix + 'nobinary',
+default=False,
+)
+coreconfigitem(section, configprefix + 'noprefix',
+default=False,
+)
+coreconfigitem(section, configprefix + 'word-diff',
+default=False,
+)
+
 coreconfigitem('alias', '.*',
 default=dynamicdefault,
 generic=True,
 )
-coreconfigitem('annotate', 'nodates',
-default=False,
-)
-coreconfigitem('annotate', 'showfunc',
-default=False,
-)
-coreconfigitem('annotate', 'unified',
-default=None,
-)
-coreconfigitem('annotate', 'git',
-default=False,
-)
-coreconfigitem('annotate', 'ignorews',
-default=False,
-)
-coreconfigitem('annotate', 'ignorewsamount',
-default=False,
-)
-coreconfigitem('annotate', 'ignoreblanklines',
-default=False,
-)
-coreconfigitem('annotate', 'ignorewseol',
-default=False,
-)
-coreconfigitem('annotate', 'nobinary',
-default=False,
-)
-coreconfigitem('annotate', 'noprefix',
-default=False,
-)
-coreconfigitem('annotate', 'word-diff',
-default=False,
-)
 coreconfigitem('auth', 'cookiefile',
 default=None,
 )
+_registerdiffopts(section='annotate')
 # bookmarks.pushing: internal hack for discovery
 coreconfigitem('bookmarks', 'pushing',
 default=list,
@@ -404,39 +407,7 @@
 coreconfigitem('devel', 'debug.peer-request',
 default=False,
 )
-coreconfigitem('diff', 'nodates',
-default=False,
-)
-coreconfigitem('diff', 'showfunc',
-default=False,
-)
-coreconfigitem('diff', 'unified',
-default=None,
-)
-coreconfigitem('diff', 'git',
-default=False,
-)
-coreconfigitem('diff', 'ignorews',
-default=False,
-)
-coreconfigitem('diff', 'ignorewsamount',
-default=False,
-)
-coreconfigitem('diff', 'ignoreblanklines',
-default=False,
-)
-coreconfigitem('diff', 'ignorewseol',
-default=False,
-)
-coreconfigitem('diff', 'nobinary',
-default=False,
-)
-coreconfigitem('diff', 'noprefix',
-default=False,
-)
-coreconfigitem('diff', 'word-diff',
-default=False,
-)
+_registerdiffopts(section='diff')
 coreconfigitem('email', 'bcc',
 default=None,
 )



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


D5833: diff: when looking for diff configs, support a configurable prefix

2019-02-05 Thread spectral (Kyle Lippincott)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG78b270a55dc6: diff: when looking for diff configs, support 
a configurable prefix (authored by spectral, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5833?vs=13760&id=13803

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

AFFECTED FILES
  mercurial/diffutil.py

CHANGE DETAILS

diff --git a/mercurial/diffutil.py b/mercurial/diffutil.py
--- a/mercurial/diffutil.py
+++ b/mercurial/diffutil.py
@@ -16,13 +16,15 @@
 pycompat,
 )
 
-def diffallopts(ui, opts=None, untrusted=False, section='diff'):
+def diffallopts(ui, opts=None, untrusted=False, section='diff',
+configprefix=''):
 '''return diffopts with all features supported and parsed'''
 return difffeatureopts(ui, opts=opts, untrusted=untrusted, section=section,
-   git=True, whitespace=True, formatchanging=True)
+   git=True, whitespace=True, formatchanging=True,
+   configprefix=configprefix)
 
 def difffeatureopts(ui, opts=None, untrusted=False, section='diff', git=False,
-whitespace=False, formatchanging=False):
+whitespace=False, formatchanging=False, configprefix=''):
 '''return diffopts with only opted-in features parsed
 
 Features:
@@ -45,7 +47,8 @@
 return v
 if forceplain is not None and ui.plain():
 return forceplain
-return getter(section, name or key, untrusted=untrusted)
+return getter(section, configprefix + (name or key),
+  untrusted=untrusted)
 
 # core options, expected to be understood by every diff parser
 buildopts = {



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


D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   So do we prefer `legacyrelativevalue` then? Or `legacywasrelative`? Or 
`legacyrelative`? (I think the last one is least clear.)
  
  `legacyrelativevalue` sounds good to me.

REPOSITORY
  rHG Mercurial

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

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


Re: D5800: config: introduce a new value for ui.relative-paths getting old behavior

2019-02-05 Thread Yuya Nishihara
>   So do we prefer `legacyrelativevalue` then? Or `legacywasrelative`? Or 
> `legacyrelative`? (I think the last one is least clear.)

`legacyrelativevalue` sounds good to me.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5834: commit/revert: if interactive, look elsewhere for whitespace settings (BC)

2019-02-05 Thread yuja (Yuya Nishihara)
yuja added a comment.


  Updated the tests added at 
https://phab.mercurial-scm.org/rHGd1d3094b54f96ae806303d98b69cf7fa32fa2486 and 
queued, thanks.

REPOSITORY
  rHG Mercurial

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

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


Re: D5834: commit/revert: if interactive, look elsewhere for whitespace settings (BC)

2019-02-05 Thread Yuya Nishihara
Updated the tests added at d1d3094b54f9 and queued, thanks.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D5744: commit: ignore diff whitespace settings when doing `commit -i` (issue5839)

2019-02-05 Thread yuja (Yuya Nishihara)
yuja added a comment.


  >   > I agree with that we would never set the 
`commands.commit.interactive.{...}`
  >   >  in hgrc, but the feature itself is useful if you have to work on 
unclean
  >   >  codebase unlike in Google. For example, I sometimes need to commit 
changes
  >   >  ignoring unrelated whitespace cleanups made by editor or code 
formatter,
  >   >  because I can't control the development workflow.
  >   >
  >   > That's why I thought there would be users relying on the current 
behavior.
  >   
  >   I think I understand what you're saying.  I was under the impression that 
what we cared about was that `hg record -b` should continue working. Since 
there are no diffopts available on `hg commit -i`, you're thinking that this 
could be written as `hg commit -i --config 
commands.commit.interactive.ignorews=1`.
  >   
  >   While I'm sympathetic to that argument, it is so long and unwieldy that I 
think I'd recommend that users just do `hg --config extensions.record= record 
-b` (or, more likely, set `[extensions] record=` in their hgrc).
  
  Yeah. If we didn't have the same issue for revert, I would agree with that and
  dropping `--config diff.*` support from `hg commit -i`.
  
  >   I'll send the other patch series, we can discuss this on the relevant 
patches instead of keeping most of the discussion in a (somewhat unrelated) 
patch.  I've sent https://phab.mercurial-scm.org/D5832-D5834 with the config 
option approach, and still have D5877-D5878 as the "only respect commandline 
args" approach.
  
  I've queued https://phab.mercurial-scm.org/D5832-D5834 as it can provide 
escape hatch for a potential BC.
  Many thanks!

REPOSITORY
  rHG Mercurial

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

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


Re: D5744: commit: ignore diff whitespace settings when doing `commit -i` (issue5839)

2019-02-05 Thread Yuya Nishihara
>   > I agree with that we would never set the 
> `commands.commit.interactive.{...}`
>   >  in hgrc, but the feature itself is useful if you have to work on unclean
>   >  codebase unlike in Google. For example, I sometimes need to commit 
> changes
>   >  ignoring unrelated whitespace cleanups made by editor or code formatter,
>   >  because I can't control the development workflow.
>   >
>   > That's why I thought there would be users relying on the current behavior.
>   
>   I think I understand what you're saying.  I was under the impression that 
> what we cared about was that `hg record -b` should continue working. Since 
> there are no diffopts available on `hg commit -i`, you're thinking that this 
> could be written as `hg commit -i --config 
> commands.commit.interactive.ignorews=1`.
>   
>   While I'm sympathetic to that argument, it is so long and unwieldy that I 
> think I'd recommend that users just do `hg --config extensions.record= record 
> -b` (or, more likely, set `[extensions] record=` in their hgrc).

Yeah. If we didn't have the same issue for revert, I would agree with that and
dropping `--config diff.*` support from `hg commit -i`.

>   I'll send the other patch series, we can discuss this on the relevant 
> patches instead of keeping most of the discussion in a (somewhat unrelated) 
> patch.  I've sent https://phab.mercurial-scm.org/D5832-D5834 with the config 
> option approach, and still have D5877-D5878 as the "only respect commandline 
> args" approach.

I've queued D5832-D5834 as it can provide escape hatch for a potential BC.
Many thanks!
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


mercurial@41532: 3 new changesets

2019-02-05 Thread Mercurial Commits
3 new changesets in mercurial:

https://www.mercurial-scm.org/repo/hg/rev/4dd07bf84608
changeset:   41530:4dd07bf84608
user:Augie Fackler 
date:Mon Feb 04 17:06:22 2019 -0500
summary: tests: fix test-match.py on Python3

https://www.mercurial-scm.org/repo/hg/rev/14983ac4a764
changeset:   41531:14983ac4a764
user:Gregory Szorc 
date:Mon Feb 04 09:29:25 2019 -0800
summary: tests: add optional Python 2.7 deprecation output

https://www.mercurial-scm.org/repo/hg/rev/bd3f03d8cc9f
changeset:   41532:bd3f03d8cc9f
bookmark:@
tag: tip
user:Gregory Szorc 
date:Mon Feb 04 08:54:30 2019 -0800
summary: global: use raw strings for regular expressions with escapes

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


D5816: global: make some docstrings raw strings

2019-02-05 Thread pulkit (Pulkit Goyal)
pulkit added a comment.


  Should we add `# skip-blame` to this and rest of the series as they are just 
adding of r'' prefixes?

REPOSITORY
  rHG Mercurial

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

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