D1755: logexchange: introduce helper function to get remote path name

2018-01-11 Thread pulkit (Pulkit Goyal)
pulkit updated this revision to Diff 4794.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1755?vs=4605&id=4794

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

AFFECTED FILES
  mercurial/logexchange.py
  tests/test-logexchange.t

CHANGE DETAILS

diff --git a/tests/test-logexchange.t b/tests/test-logexchange.t
--- a/tests/test-logexchange.t
+++ b/tests/test-logexchange.t
@@ -57,14 +57,14 @@
   $ cat .hg/logexchange/bookmarks
   0
   
-  87d6d66763085b629e6d7ed56778c79827273022\x00file:$TESTTMP/server\x00bar (esc)
-  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00file:$TESTTMP/server\x00foo (esc)
+  87d6d66763085b629e6d7ed56778c79827273022\x00$TESTTMP/server\x00bar (esc)
+  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00$TESTTMP/server\x00foo (esc)
 
   $ cat .hg/logexchange/branches
   0
   
-  ec2426147f0e39dbc9cef599b066be6035ce691d\x00file:$TESTTMP/server\x00default 
(esc)
-  3e1487808078543b0af6d10dadf5d46943578db0\x00file:$TESTTMP/server\x00wat (esc)
+  ec2426147f0e39dbc9cef599b066be6035ce691d\x00$TESTTMP/server\x00default (esc)
+  3e1487808078543b0af6d10dadf5d46943578db0\x00$TESTTMP/server\x00wat (esc)
 
 Making a new server
 ---
@@ -94,15 +94,15 @@
   $ cat .hg/logexchange/bookmarks
   0
   
-  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00file:$TESTTMP/server\x00foo (esc)
-  87d6d66763085b629e6d7ed56778c79827273022\x00file:$TESTTMP/server\x00bar (esc)
-  87d6d66763085b629e6d7ed56778c79827273022\x00file:$TESTTMP/server2\x00bar 
(esc)
-  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00file:$TESTTMP/server2\x00foo 
(esc)
+  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00$TESTTMP/server\x00foo (esc)
+  87d6d66763085b629e6d7ed56778c79827273022\x00$TESTTMP/server\x00bar (esc)
+  87d6d66763085b629e6d7ed56778c79827273022\x00$TESTTMP/server2\x00bar (esc)
+  62615734edd52f06b6fb9c2beb429e4fe30d57b8\x00$TESTTMP/server2\x00foo (esc)
 
   $ cat .hg/logexchange/branches
   0
   
-  3e1487808078543b0af6d10dadf5d46943578db0\x00file:$TESTTMP/server\x00wat (esc)
-  ec2426147f0e39dbc9cef599b066be6035ce691d\x00file:$TESTTMP/server\x00default 
(esc)
-  ec2426147f0e39dbc9cef599b066be6035ce691d\x00file:$TESTTMP/server2\x00default 
(esc)
-  3e1487808078543b0af6d10dadf5d46943578db0\x00file:$TESTTMP/server2\x00wat 
(esc)
+  3e1487808078543b0af6d10dadf5d46943578db0\x00$TESTTMP/server\x00wat (esc)
+  ec2426147f0e39dbc9cef599b066be6035ce691d\x00$TESTTMP/server\x00default (esc)
+  ec2426147f0e39dbc9cef599b066be6035ce691d\x00$TESTTMP/server2\x00default (esc)
+  3e1487808078543b0af6d10dadf5d46943578db0\x00$TESTTMP/server2\x00wat (esc)
diff --git a/mercurial/logexchange.py b/mercurial/logexchange.py
--- a/mercurial/logexchange.py
+++ b/mercurial/logexchange.py
@@ -94,14 +94,35 @@
 finally:
 wlock.release()
 
+def activepath(remote):
+"""returns remote path"""
+local = None
+try:
+local = remote.local()
+except AttributeError:
+pass
+
+# determine the remote path from the repo, if possible; else just
+# use the string given to us
+rpath = remote
+if local:
+rpath = remote._repo.root
+elif not isinstance(remote, str):
+try:
+rpath = remote._url
+except AttributeError:
+rpath = remote.url
+
+return rpath
+
 def pullremotenames(localrepo, remoterepo):
 """
 pulls bookmarks and branches information of the remote repo during a
 pull or clone operation.
 localrepo is our local repository
 remoterepo is the peer instance
 """
-remotepath = remoterepo.url()
+remotepath = activepath(remoterepo)
 bookmarks = remoterepo.listkeys('bookmarks')
 # on a push, we don't want to keep obsolete heads since
 # they won't show up as heads on the next pull, so we



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


D1581: rust: implementation of `hg`

2018-01-11 Thread kevincox (Kevin Cox)
kevincox added a comment.


  Overall it looks great. I added a bunch of nitpicks. The most common 
suggestion was to add some contextual information to error messages. Other then 
that mostly minor style improvements. Feel free to push back on anything you 
don't agree with :)

INLINE COMMENTS

> cramertj wrote in build.rs:88
> Nit: not sure what version you're targeting, but `'static` is automatic for 
> `const` vars, so you could write `[&str; 2]`

I would also recommend using a slice if you don't intend the size of the array 
to be part of the type signature.

  const REQUIRED_CONFIG_FLAGS: &[&str] = &["Py_USING_UNICODE", "WITH_THREAD"];

> build.rs:33
> +);
> +}
> +

assert!(
  Path::new(&python).exists(),
  "Python interpreter {} does not exist; this should never happen",
  python);

I would also recommend `{:?}` as the quotes highlight the injected variable 
nicely and it will make some hard-to-notice things more visible due to escaping.

> build.rs:110
> +if !result {
> +panic!("Detected Python requires feature {}", key);
> +}

Use `assert!`.

> build.rs:116
> +if !have_shared(&config) {
> +panic!("Detected Python lacks a shared library, which is required");
> +}

Use `assert!`

> build.rs:127
> +panic!("Detected Python doesn't support UCS-4 code points");
> +}
> +}

#[cfg(not(target_os = "windows"))]
  assert_eq!(
  config.config.get("Py_UNICODE_SIZE"), Some("4"),
   "Detected Python doesn't support UCS-4 code points");

> main.rs:37
> +fn get_environment() -> Environment {
> +let exe = env::current_exe().unwrap();
> +

Use expect for a better error message. `.expect("Error getting executable 
path")`

> main.rs:91
> +.unwrap()
> +.into_raw();
> +unsafe {

This method allows paths that aren't valid UTF-8 by avoiding ever becoming a 
`str`.

  CString::new(env.python_home.as_ref().as_bytes())

I would also change the unwrap to `.expect("Error setting python home")`.

> main.rs:99
> +// Call sys.setdefaultencoding("undefined") if HGUNICODEPEDANTRY is set.
> +let pedantry = env::var("HGUNICODEPEDANTRY").is_ok();
> +

It appears that HG accepts `HGUNICODEPEDANTRY=` as not enabling unicode 
pedantry. Maybe the behavior should be the same here. Untested code below 
should work.

  let pedantry = !env::var("HGUNICODEPEDANTRY").unwrap_or("").is_empty();

> main.rs:111
> +fn update_modules_path(env: &Environment, py: Python, sys_mod: &PyModule) {
> +let sys_path = sys_mod.get(py, "path").unwrap();
> +sys_path

`.expect("Error accessing sys.path")`

> main.rs:133
> +// not desirable.
> +let program_name = CString::new(env.python_exe.to_str().unwrap())
> +.unwrap()

`CString::new(env.python_exe.as_ref().as_bytes())`

> main.rs:134
> +let program_name = CString::new(env.python_exe.to_str().unwrap())
> +.unwrap()
> +.as_ptr();

`.expect("Error setting program name")`

> main.rs:200
> +fn run_py(env: &Environment, py: Python) -> PyResult<()> {
> +let sys_mod = py.import("sys").unwrap();
> +

Since this method returns a Result why not handle the error?

  let sys_mod = py.import("sys")?;

REPOSITORY
  rHG Mercurial

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

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


[PATCH] hgweb: drop support of browsers that don't understand (BC)

2018-01-11 Thread Anton Shestakov
# HG changeset patch
# User Anton Shestakov 
# Date 1515666008 -28800
#  Thu Jan 11 18:20:08 2018 +0800
# Node ID b9e397c45c99292bb3a285fa118360726b3aebf3
# Parent  98b87b8307e07ad3d93d3854508c362435d80c38
hgweb: drop support of browsers that don't understand  (BC)

Internet Explorer 8 and below need excanvas aka ExplorerCanvas to support
canvas tag at all. We used to vendor the library in Mercurial, but IE8 was
discontinued and all support for it ceased in January 2016. We should do the
same and remove excanvas library.

Apart from just cleaning up code, this will also make downstream Debian
packages stop depending on libjs-excanvas, for example.

diff --git a/contrib/wix/templates.wxs b/contrib/wix/templates.wxs
--- a/contrib/wix/templates.wxs
+++ b/contrib/wix/templates.wxs
@@ -230,7 +230,6 @@
 
 
 
-
 
 
 
diff --git a/mercurial/templates/gitweb/graph.tmpl 
b/mercurial/templates/gitweb/graph.tmpl
--- a/mercurial/templates/gitweb/graph.tmpl
+++ b/mercurial/templates/gitweb/graph.tmpl
@@ -4,7 +4,6 @@
href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}"/>
 
-
 
 
 
diff --git a/mercurial/templates/monoblue/graph.tmpl 
b/mercurial/templates/monoblue/graph.tmpl
--- a/mercurial/templates/monoblue/graph.tmpl
+++ b/mercurial/templates/monoblue/graph.tmpl
@@ -2,7 +2,6 @@
 {repo|escape}: graph
 
 
-
 
 
 
diff --git a/mercurial/templates/paper/graph.tmpl 
b/mercurial/templates/paper/graph.tmpl
--- a/mercurial/templates/paper/graph.tmpl
+++ b/mercurial/templates/paper/graph.tmpl
@@ -4,7 +4,6 @@
href="{url|urlescape}atom-log" title="Atom feed for {repo|escape}: log" />
 
-
 
 
 
diff --git a/mercurial/templates/spartan/graph.tmpl 
b/mercurial/templates/spartan/graph.tmpl
--- a/mercurial/templates/spartan/graph.tmpl
+++ b/mercurial/templates/spartan/graph.tmpl
@@ -4,7 +4,6 @@
href="{url|urlescape}atom-tags" title="Atom feed for {repo|escape}: tags">
 
-
 
 
 
diff --git a/mercurial/templates/static/excanvas.js 
b/mercurial/templates/static/excanvas.js
deleted file mode 100644
--- a/mercurial/templates/static/excanvas.js
+++ /dev/null
@@ -1,924 +0,0 @@
-// Copyright 2006 Google Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-
-// Known Issues:
-//
-// * Patterns are not implemented.
-// * Radial gradient are not implemented. The VML version of these look very
-//   different from the canvas one.
-// * Clipping paths are not implemented.
-// * Coordsize. The width and height attribute have higher priority than the
-//   width and height style values which isn't correct.
-// * Painting mode isn't implemented.
-// * Canvas width/height should is using content-box by default. IE in
-//   Quirks mode will draw the canvas using border-box. Either change your
-//   doctype to HTML5
-//   (http://www.whatwg.org/specs/web-apps/current-work/#the-doctype)
-//   or use Box Sizing Behavior from WebFX
-//   (http://webfx.eae.net/dhtml/boxsizing/boxsizing.html)
-// * Non uniform scaling does not correctly scale strokes.
-// * Optimize. There is always room for speed improvements.
-
-// Only add this code if we do not already have a canvas implementation
-if (!document.createElement('canvas').getContext) {
-
-(function() {
-
-  // alias some functions to make (compiled) code shorter
-  var m = Math;
-  var mr = m.round;
-  var ms = m.sin;
-  var mc = m.cos;
-  var abs = m.abs;
-  var sqrt = m.sqrt;
-
-  // this is used for sub pixel precision
-  var Z = 10;
-  var Z2 = Z / 2;
-
-  /**
-   * This funtion is assigned to the  elements as element.getContext().
-   * @this {HTMLElement}
-   * @return {CanvasRenderingContext2D_}
-   */
-  function getContext() {
-return this.context_ ||
-(this.context_ = new CanvasRenderingContext2D_(this));
-  }
-
-  var slice = Array.prototype.slice;
-
-  /**
-   * Binds a function to an object. The returned function will always use the
-   * passed in {@code obj} as {@code this}.
-   *
-   * Example:
-   *
-   *   g = bind(f, obj, a, b)
-   *   g(c, d) // will do f.call(obj, a, b, c, d)
-   *
-   * @param {Function} f The function to bind the object to
-   * @param {Object} obj The object that should act as this when the function
-   * is called
-   * @param {*} var_args Rest arguments that will be used as the initial
-   * arguments when the function is called
-   * @return {Function} A new function that has bound this
-   */
-  functi

[PATCH] pull: hold wlock for the full operation when --update is used

2018-01-11 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1515671879 0
#  Thu Jan 11 11:57:59 2018 +
# Node ID ba6760b14c221377e11f5a841b6794e7b1f858ad
# Parent  58fda95a0202fc6327d1f5d9df26f7ff16538d57
# EXP-Topic update-wlock
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
ba6760b14c22
pull: hold wlock for the full operation when --update is used

With now, the wlock is not held between the pull and the update. This can lead
to race condition and make logic checking to post pull results more complicated
(eg: with _afterlock).

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4022,36 +4022,40 @@ def pull(ui, repo, source="default", **o
 "so a rev cannot be specified.")
 raise error.Abort(err)
 
-pullopargs.update(opts.get('opargs', {}))
-modheads = exchange.pull(repo, other, heads=revs,
- force=opts.get('force'),
- bookmarks=opts.get('bookmark', ()),
- opargs=pullopargs).cgresult
-
-# brev is a name, which might be a bookmark to be activated at
-# the end of the update. In other words, it is an explicit
-# destination of the update
-brev = None
-
-if checkout:
-checkout = str(repo.changelog.rev(checkout))
-
-# order below depends on implementation of
-# hg.addbranchrevs(). opts['bookmark'] is ignored,
-# because 'checkout' is determined without it.
-if opts.get('rev'):
-brev = opts['rev'][0]
-elif opts.get('branch'):
-brev = opts['branch'][0]
-else:
-brev = branches[0]
-repo._subtoppath = source
-try:
-ret = postincoming(ui, repo, modheads, opts.get('update'),
-   checkout, brev)
-
-finally:
-del repo._subtoppath
+wlock = util.nullcontextmanager()
+if opts.get('update'):
+wlock = repo.wlock()
+with wlock:
+pullopargs.update(opts.get('opargs', {}))
+modheads = exchange.pull(repo, other, heads=revs,
+ force=opts.get('force'),
+ bookmarks=opts.get('bookmark', ()),
+ opargs=pullopargs).cgresult
+
+# brev is a name, which might be a bookmark to be activated at
+# the end of the update. In other words, it is an explicit
+# destination of the update
+brev = None
+
+if checkout:
+checkout = str(repo.changelog.rev(checkout))
+
+# order below depends on implementation of
+# hg.addbranchrevs(). opts['bookmark'] is ignored,
+# because 'checkout' is determined without it.
+if opts.get('rev'):
+brev = opts['rev'][0]
+elif opts.get('branch'):
+brev = opts['branch'][0]
+else:
+brev = branches[0]
+repo._subtoppath = source
+try:
+ret = postincoming(ui, repo, modheads, opts.get('update'),
+   checkout, brev)
+
+finally:
+del repo._subtoppath
 
 finally:
 other.close()
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -262,6 +262,7 @@ Pull from bundle and trigger notify
   adding file changes
   added 2 changesets with 3 changes to 3 files
   new changesets a2392c293916:ef63ca68695b
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
   MIME-Version: 1.0
   Content-Type: text/plain; charset="us-ascii"
   Content-Transfer-Encoding: 7bit
@@ -314,7 +315,6 @@ Pull from bundle and trigger notify
   +++ b/b  Thu Jan 01 00:00:00 1970 +
   @@ -0,0 +1,1 @@
   +ignore $Id$
-  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
   $ cp $HGRCPATH.nohooks $HGRCPATH
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1581: rust: implementation of `hg`

2018-01-11 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> kevincox wrote in main.rs:133
> `CString::new(env.python_exe.as_ref().as_bytes())`

That's more correct on Unix, but wouldn't work on Windows since 
native string is UTF-16 variant (Rust) or ANSI (Python 2.7).

REPOSITORY
  rHG Mercurial

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

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


D1813: bookmarks: add bookmarks to hidden revs if directaccess config is set

2018-01-11 Thread yuja (Yuya Nishihara)
yuja requested changes to this revision.
yuja added inline comments.
This revision now requires changes to proceed.

INLINE COMMENTS

> bookmarks.py:859
> +if ctx.hidden():
> +repo.ui.warn(_("accessing hidden changeset %s\n") % ctx)
> +tgt = ctx.node()

Perhaps we can say "bookmarking" or "reviving" instead of "accessing"? I don't 
know which is better, though.

Another minor problem I found is this warning will be repeated if
you pass more than one bookmark names.

REPOSITORY
  rHG Mercurial

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

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


D1846: rust: avoid redundant 'static lifetime

2018-01-11 Thread yuja (Yuya Nishihara)
yuja added a comment.


  I think it's new feature. Which Rust version should we support?
  
  
https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1170-2017-04-27

REPOSITORY
  rHG Mercurial

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

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


D1581: rust: implementation of `hg`

2018-01-11 Thread kevincox (Kevin Cox)
kevincox added inline comments.

INLINE COMMENTS

> yuja wrote in main.rs:133
> That's more correct on Unix, but wouldn't work on Windows since 
> native string is UTF-16 variant (Rust) or ANSI (Python 2.7).

Oops, for some reason I thought this was in a unix block. `as_bytes()` isn't 
actually available otherise. I think that this is fine then. non-UTF-8 paths 
shouldn't be a major issue..

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH] pull: hold wlock for the full operation when --update is used

2018-01-11 Thread Yuya Nishihara
On Thu, 11 Jan 2018 12:11:36 +, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld 
> # Date 1515671879 0
> #  Thu Jan 11 11:57:59 2018 +
> # Node ID ba6760b14c221377e11f5a841b6794e7b1f858ad
> # Parent  58fda95a0202fc6327d1f5d9df26f7ff16538d57
> # EXP-Topic update-wlock
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
> ba6760b14c22
> pull: hold wlock for the full operation when --update is used
> 
> With now, the wlock is not held between the pull and the update. This can lead
> to race condition and make logic checking to post pull results more 
> complicated
> (eg: with _afterlock).

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


Re: [PATCH] hgweb: drop support of browsers that don't understand (BC)

2018-01-11 Thread Yuya Nishihara
On Thu, 11 Jan 2018 19:20:59 +0800, Anton Shestakov wrote:
> # HG changeset patch
> # User Anton Shestakov 
> # Date 1515666008 -28800
> #  Thu Jan 11 18:20:08 2018 +0800
> # Node ID b9e397c45c99292bb3a285fa118360726b3aebf3
> # Parent  98b87b8307e07ad3d93d3854508c362435d80c38
> hgweb: drop support of browsers that don't understand  (BC)
> 
> Internet Explorer 8 and below need excanvas aka ExplorerCanvas to support
> canvas tag at all. We used to vendor the library in Mercurial, but IE8 was
> discontinued and all support for it ceased in January 2016. We should do the
> same and remove excanvas library.
> 
> Apart from just cleaning up code, this will also make downstream Debian
> packages stop depending on libjs-excanvas, for example.

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


D1848: perf: do not import util.queue

2018-01-11 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG998b585f156c: perf: do not import util.queue (authored by 
quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1848?vs=4792&id=4795

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

AFFECTED FILES
  contrib/perf.py

CHANGE DETAILS

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -27,7 +27,6 @@
 import sys
 import threading
 import time
-import util.queue
 from mercurial import (
 changegroup,
 cmdutil,



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


D1847: rust: add TODO about lifetime of program_name variable

2018-01-11 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG74bec9e74831: rust: add TODO about lifetime of program_name 
variable (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1847?vs=4791&id=4797

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

AFFECTED FILES
  rust/hgcli/src/main.rs

CHANGE DETAILS

diff --git a/rust/hgcli/src/main.rs b/rust/hgcli/src/main.rs
--- a/rust/hgcli/src/main.rs
+++ b/rust/hgcli/src/main.rs
@@ -125,6 +125,9 @@
 // Set program name. The backing memory needs to live for the duration of 
the
 // interpreter.
 //
+// TODO consider storing this in a static or associating with lifetime of
+// the Python interpreter.
+//
 // Yes, we use the path to the Python interpreter not argv[0] here. The
 // reason is because Python uses the given path to find the location of
 // Python files. Apparently we could define our own ``Py_GetPath()``



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


D1845: rust: move import of PathBuf

2018-01-11 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG11c86ab69e67: rust: move import of PathBuf (authored by 
indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1845?vs=4789&id=4796

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

AFFECTED FILES
  rust/hgcli/build.rs

CHANGE DETAILS

diff --git a/rust/hgcli/build.rs b/rust/hgcli/build.rs
--- a/rust/hgcli/build.rs
+++ b/rust/hgcli/build.rs
@@ -8,9 +8,6 @@
 use std::collections::HashMap;
 use std::env;
 use std::path::Path;
-#[cfg(target_os = "windows")]
-use std::path::PathBuf;
-
 use std::process::Command;
 
 struct PythonConfig {
@@ -77,6 +74,8 @@
 
 #[cfg(target_os = "windows")]
 fn have_shared(config: &PythonConfig) -> bool {
+use std::path::PathBuf;
+
 // python27.dll should exist next to python2.7.exe.
 let mut dll = PathBuf::from(&config.python);
 dll.pop();



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


[PATCH 1 of 5] log: make opt2revset table a module constant

2018-01-11 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1514879917 -32400
#  Tue Jan 02 16:58:37 2018 +0900
# Node ID da12c978eafe1b414122213c75ce149a5e8d8b5b
# Parent  4b68ca118d8d316cff1fbfe260e8fdb0dae3e26a
log: make opt2revset table a module constant

Just makes it clear that the table isn't updated in _makelogrevset().

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2338,6 +2338,24 @@ def _makenofollowlogfilematcher(repo, pa
 '''hook for extensions to override the filematcher for non-follow cases'''
 return None
 
+_opt2logrevset = {
+'no_merges':('not merge()', None),
+'only_merges':  ('merge()', None),
+'_ancestors':   ('ancestors(%(val)s)', None),
+'_fancestors':  ('_firstancestors(%(val)s)', None),
+'_descendants': ('descendants(%(val)s)', None),
+'_fdescendants':('_firstdescendants(%(val)s)', None),
+'_matchfiles':  ('_matchfiles(%(val)s)', None),
+'date': ('date(%(val)r)', None),
+'branch':   ('branch(%(val)r)', ' or '),
+'_patslog': ('filelog(%(val)r)', ' or '),
+'_patsfollow':  ('follow(%(val)r)', ' or '),
+'_patsfollowfirst': ('_followfirst(%(val)r)', ' or '),
+'keyword':  ('keyword(%(val)r)', ' or '),
+'prune':('not (%(val)r or ancestors(%(val)r))', ' and '),
+'user': ('user(%(val)r)', ' or '),
+}
+
 def _makelogrevset(repo, pats, opts, revs):
 """Return (expr, filematcher) where expr is a revset string built
 from log options and file patterns or None. If --stat or --patch
@@ -2345,24 +2363,6 @@ def _makelogrevset(repo, pats, opts, rev
 taking a revision number and returning a match objects filtering
 the files to be detailed when displaying the revision.
 """
-opt2revset = {
-'no_merges':('not merge()', None),
-'only_merges':  ('merge()', None),
-'_ancestors':   ('ancestors(%(val)s)', None),
-'_fancestors':  ('_firstancestors(%(val)s)', None),
-'_descendants': ('descendants(%(val)s)', None),
-'_fdescendants':('_firstdescendants(%(val)s)', None),
-'_matchfiles':  ('_matchfiles(%(val)s)', None),
-'date': ('date(%(val)r)', None),
-'branch':   ('branch(%(val)r)', ' or '),
-'_patslog': ('filelog(%(val)r)', ' or '),
-'_patsfollow':  ('follow(%(val)r)', ' or '),
-'_patsfollowfirst': ('_followfirst(%(val)r)', ' or '),
-'keyword':  ('keyword(%(val)r)', ' or '),
-'prune':('not (%(val)r or ancestors(%(val)r))', ' and '),
-'user': ('user(%(val)r)', ' or '),
-}
-
 opts = dict(opts)
 # follow or not follow?
 follow = opts.get('follow') or opts.get('follow_first')
@@ -2471,9 +2471,9 @@ def _makelogrevset(repo, pats, opts, rev
 for op, val in sorted(opts.iteritems()):
 if not val:
 continue
-if op not in opt2revset:
+if op not in _opt2logrevset:
 continue
-revop, andor = opt2revset[op]
+revop, andor = _opt2logrevset[op]
 if '%(val)' not in revop:
 expr.append(revop)
 else:
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 4 of 5] log: use revsetlang.formatspec() thoroughly

2018-01-11 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1514882221 -32400
#  Tue Jan 02 17:37:01 2018 +0900
# Node ID 438dde28f8693b822898903325d2567c5e618c4b
# Parent  bab0b8954f8430710ddacf1db852a4420121f677
log: use revsetlang.formatspec() thoroughly

This patch replaces %(val)s and %(val)r with %r (expression) and %s (string)
respectively. _matchfiles() is the exception as it takes a list of string
parameters.

"--prune REV" could take a revset expression if it were "ancestors(%(val)s)",
but this patch doesn't change the existing behavior.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2342,19 +2342,19 @@ def _makenofollowlogfilematcher(repo, pa
 _opt2logrevset = {
 'no_merges':('not merge()', None),
 'only_merges':  ('merge()', None),
-'_ancestors':   ('ancestors(%(val)s)', None),
-'_fancestors':  ('_firstancestors(%(val)s)', None),
-'_descendants': ('descendants(%(val)s)', None),
-'_fdescendants':('_firstdescendants(%(val)s)', None),
-'_matchfiles':  ('_matchfiles(%(val)s)', None),
-'date': ('date(%(val)r)', None),
-'branch':   ('branch(%(val)r)', '%lr'),
-'_patslog': ('filelog(%(val)r)', '%lr'),
-'_patsfollow':  ('follow(%(val)r)', '%lr'),
-'_patsfollowfirst': ('_followfirst(%(val)r)', '%lr'),
-'keyword':  ('keyword(%(val)r)', '%lr'),
-'prune':('ancestors(%(val)r)', 'not %lr'),
-'user': ('user(%(val)r)', '%lr'),
+'_ancestors':   ('ancestors(%r)', None),
+'_fancestors':  ('_firstancestors(%r)', None),
+'_descendants': ('descendants(%r)', None),
+'_fdescendants':('_firstdescendants(%r)', None),
+'_matchfiles':  (None, '_matchfiles(%ps)'),
+'date': ('date(%s)', None),
+'branch':   ('branch(%s)', '%lr'),
+'_patslog': ('filelog(%s)', '%lr'),
+'_patsfollow':  ('follow(%s)', '%lr'),
+'_patsfollowfirst': ('_followfirst(%s)', '%lr'),
+'keyword':  ('keyword(%s)', '%lr'),
+'prune':('ancestors(%s)', 'not %lr'),
+'user': ('user(%s)', '%lr'),
 }
 
 def _makelogrevset(repo, pats, opts, revs):
@@ -2437,7 +2437,6 @@ def _makelogrevset(repo, pats, opts, rev
 matchargs.append('i:' + p)
 for p in opts.get('exclude', []):
 matchargs.append('x:' + p)
-matchargs = ','.join(('%r' % p) for p in matchargs)
 opts['_matchfiles'] = matchargs
 if follow:
 opts[fnopats[0][followfirst]] = '.'
@@ -2475,15 +2474,14 @@ def _makelogrevset(repo, pats, opts, rev
 if op not in _opt2logrevset:
 continue
 revop, listop = _opt2logrevset[op]
-if '%(val)' not in revop:
+if revop and '%' not in revop:
 expr.append(revop)
+elif not listop:
+expr.append(revsetlang.formatspec(revop, val))
 else:
-if not listop:
-e = revop % {'val': val}
-else:
-e = [revop % {'val': v} for v in val]
-e = revsetlang.formatspec(listop, e)
-expr.append(e)
+if revop:
+val = [revsetlang.formatspec(revop, v) for v in val]
+expr.append(revsetlang.formatspec(listop, val))
 
 if expr:
 expr = '(' + ' and '.join(expr) + ')'
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 2 of 5] log: simplify 'x or ancestors(x)' expression

2018-01-11 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1514880048 -32400
#  Tue Jan 02 17:00:48 2018 +0900
# Node ID c0c7ecef4093eae82fcff7589e534f96c9e8e8c5
# Parent  da12c978eafe1b414122213c75ce149a5e8d8b5b
log: simplify 'x or ancestors(x)' expression

'ancestors(x)' includes 'x'.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2352,7 +2352,7 @@ def _makenofollowlogfilematcher(repo, pa
 '_patsfollow':  ('follow(%(val)r)', ' or '),
 '_patsfollowfirst': ('_followfirst(%(val)r)', ' or '),
 'keyword':  ('keyword(%(val)r)', ' or '),
-'prune':('not (%(val)r or ancestors(%(val)r))', ' and '),
+'prune':('not ancestors(%(val)r)', ' and '),
 'user': ('user(%(val)r)', ' or '),
 }
 
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1573,34 +1573,24 @@ glog always reorders nodes which explain
   []
   (and
 (not
-  (or
-(list
-  (string '31')
-  (func
-(symbol 'ancestors')
-(string '31')
+  (func
+(symbol 'ancestors')
+(string '31')))
 (not
-  (or
-(list
-  (string '32')
-  (func
-(symbol 'ancestors')
-(string '32'))
+  (func
+(symbol 'ancestors')
+(string '32'
   ,
   ,
-  ,
-,
-,
 ,
-  
+  >>>,
+,
+>>>
 
 Dedicated repo for --follow and paths filtering. The g is crafted to
 have 2 filelog topological heads in a linear changeset graph.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 3 of 5] log: use revsetlang.formatspec() to concatenate list expression

2018-01-11 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1514880798 -32400
#  Tue Jan 02 17:13:18 2018 +0900
# Node ID bab0b8954f8430710ddacf1db852a4420121f677
# Parent  c0c7ecef4093eae82fcff7589e534f96c9e8e8c5
log: use revsetlang.formatspec() to concatenate list expression

This rewrites 'not ancestors(x) and not ...' as 'not (ancestors(x) or ...)'
so we can use '%lr'. 'isinstance(val, list)' is replaced with 'listop' to
make sure 'listop' is applied.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -41,6 +41,7 @@ from . import (
 registrar,
 revlog,
 revset,
+revsetlang,
 scmutil,
 smartset,
 templatekw,
@@ -2347,13 +2348,13 @@ def _makenofollowlogfilematcher(repo, pa
 '_fdescendants':('_firstdescendants(%(val)s)', None),
 '_matchfiles':  ('_matchfiles(%(val)s)', None),
 'date': ('date(%(val)r)', None),
-'branch':   ('branch(%(val)r)', ' or '),
-'_patslog': ('filelog(%(val)r)', ' or '),
-'_patsfollow':  ('follow(%(val)r)', ' or '),
-'_patsfollowfirst': ('_followfirst(%(val)r)', ' or '),
-'keyword':  ('keyword(%(val)r)', ' or '),
-'prune':('not ancestors(%(val)r)', ' and '),
-'user': ('user(%(val)r)', ' or '),
+'branch':   ('branch(%(val)r)', '%lr'),
+'_patslog': ('filelog(%(val)r)', '%lr'),
+'_patsfollow':  ('follow(%(val)r)', '%lr'),
+'_patsfollowfirst': ('_followfirst(%(val)r)', '%lr'),
+'keyword':  ('keyword(%(val)r)', '%lr'),
+'prune':('ancestors(%(val)r)', 'not %lr'),
+'user': ('user(%(val)r)', '%lr'),
 }
 
 def _makelogrevset(repo, pats, opts, revs):
@@ -2473,14 +2474,15 @@ def _makelogrevset(repo, pats, opts, rev
 continue
 if op not in _opt2logrevset:
 continue
-revop, andor = _opt2logrevset[op]
+revop, listop = _opt2logrevset[op]
 if '%(val)' not in revop:
 expr.append(revop)
 else:
-if not isinstance(val, list):
+if not listop:
 e = revop % {'val': val}
 else:
-e = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
+e = [revop % {'val': v} for v in val]
+e = revsetlang.formatspec(listop, e)
 expr.append(e)
 
 if expr:
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1500,12 +1500,14 @@ glog always reorders nodes which explain
   (func
 (symbol 'branch')
 (string 'default'))
-  (func
-(symbol 'branch')
-(string 'branch'))
-  (func
-(symbol 'branch')
-(string 'branch'
+  (or
+(list
+  (func
+(symbol 'branch')
+(string 'branch'))
+  (func
+(symbol 'branch')
+(string 'branch'))
   ,
 ,
-  ,
+,
-  >>>,
-,
->>>
+  >,
+,
+  
 
 Dedicated repo for --follow and paths filtering. The g is crafted to
 have 2 filelog topological heads in a linear changeset graph.
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


[PATCH 5 of 5] log: rewrite --follow-first -rREV like --follow for consistency (BC)

2018-01-11 Thread Yuya Nishihara
# HG changeset patch
# User Yuya Nishihara 
# Date 1512897933 -32400
#  Sun Dec 10 18:25:33 2017 +0900
# Node ID 7c2c82f67697a0957afaa9b4f450d7b03eaa9536
# Parent  438dde28f8693b822898903325d2567c5e618c4b
log: rewrite --follow-first -rREV like --follow for consistency (BC)

This helps fixing the "--follow -rREV PATH" issue.

.. bc::

   ``log --follow-first -rREV``, which is deprecated, now follows the first
   parent of merge revisions from the specified ``REV`` just like
   ``log --follow -rREV``.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3405,7 +3405,11 @@ def log(ui, repo, *pats, **opts):
 _('FILE arguments are not compatible with --line-range option')
 )
 
-if opts.get('follow') and opts.get('rev'):
+if opts.get('follow_first') and opts.get('rev'):
+opts['rev'] = [revsetlang.formatspec('reverse(_firstancestors(%lr))',
+ opts.get('rev'))]
+del opts['follow_first']
+elif opts.get('follow') and opts.get('rev'):
 opts['rev'] = [revsetlang.formatspec('reverse(::%lr)', 
opts.get('rev'))]
 del opts['follow']
 
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -2304,22 +2304,9 @@ changessincelatesttag with no prior tag
 Test --follow-first and forward --rev
 
   $ testlog --follow-first -r6 -r8 -r5 -r7 -r4
-  ['6', '8', '5', '7', '4']
-  (func
-(symbol '_firstdescendants')
-(func
-  (symbol 'rev')
-  (symbol '6')))
-  ,
->
-  --- log.nodes* (glob)
-  +++ glog.nodes   * (glob)
-  @@ -1,3 +1,3 @@
-  -nodetag 6
-   nodetag 8
-   nodetag 7
-  +nodetag 6
+  ['reverse(_firstancestors6) or (8)) or ((5) or ((7) or (4))']
+  []
+  
 
 Test --follow and backward --rev
 
@@ -2331,15 +2318,9 @@ Test --follow and backward --rev
 Test --follow-first and backward --rev
 
   $ testlog --follow-first -r6 -r5 -r7 -r8 -r4
-  ['6', '5', '7', '8', '4']
-  (func
-(symbol '_firstancestors')
-(func
-  (symbol 'rev')
-  (symbol '6')))
-  ,
->
+  ['reverse(_firstancestors6) or (5)) or ((7) or ((8) or (4))']
+  []
+  
 
 Test --follow with --rev of graphlog extension
 
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1591: visibility: improve the message when accessing filtered obsolete rev

2018-01-11 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> context.py:446
> +reason = obsutil._getfilteredreason(unfilteredrepo, ctx)
> +msg = _("hidden revision '%s' %s") % (changeid, reason)
> +else:

Not translatable.

Needs a table of

  {'pruned': _("hidden revision '%s' is pruned"),
   ...,
  }

Can you send a followup?

REPOSITORY
  rHG Mercurial

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

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


D1591: visibility: improve the message when accessing filtered obsolete rev

2018-01-11 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> obsutil.py:871
> +"""
> +successors = successorssets(unfilteredrepo, ctx.node())
> +fate = _getobsfate(successors)

Maybe it's okay to pass a "filtered" repo to this function as
`templatekw.showsuccessorssets()` does.

REPOSITORY
  rHG Mercurial

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

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


D1795: py3: use pycompat.bytestr() instead of str()

2018-01-11 Thread yuja (Yuya Nishihara)
yuja added a comment.


  `bytes()` or `"%d"` is preferred. Can you send a follow up?

REPOSITORY
  rHG Mercurial

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

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


D1797: py3: make sure we open the file to write in bytes mode

2018-01-11 Thread yuja (Yuya Nishihara)
yuja added inline comments.

INLINE COMMENTS

> subrepo.py:844
>  
> -fp = self._repo.vfs("hgrc", "w", text=True)
> +fp = self._repo.vfs("hgrc", "wb", text=True)
>  try:

No. Here we explicitly states that we want to open a file in "text" mode.

Needs something like 
https://phab.mercurial-scm.org/rHGac69675fff1caacf143ab7f0bda668e6e325670a.

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 2 of 2 V2] filterlang: add a small language to filter files

2018-01-11 Thread Yuya Nishihara
On Thu, 11 Jan 2018 00:17:39 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison 
> # Date 1515641014 18000
> #  Wed Jan 10 22:23:34 2018 -0500
> # Node ID 548e748cb3f4eea0aedb36a2b2e9fe3b77ffb263
> # Parent  962b2bdd70d094ce4bf9a8135495788166b04510
> filterlang: add a small language to filter files

> I also made the 'always' token a
> predicate for consistency, and introduced 'never' to improve readability.

Perhaps '**' or '.' could be an "always" symbol given patterns are relative
to the repository root in filterlang.

> Finally, I changed the extension operator from '.' to '*'.  This matches how 
> git
> tracks by extension, but might be slightly confusing here because '**' 
> recurses
> in Mercurial, but '*' usually doesn't.

I prefer '**' or 'relglob:*' for fileset compatibility.

> diff --git a/mercurial/filterlang.py b/mercurial/filterlang.py
> new file mode 100644
> --- /dev/null
> +++ b/mercurial/filterlang.py
> @@ -0,0 +1,73 @@
> +# filterlang.py - a simple language to select files

The module name seems too generic.
minifileset.py, ufileset.py, etc. or merge these functions into fileset.py?

> +from . import (
> +error,
> +fileset,
> +util,
> +)

Missing i18n._().

> +def _compile(tree):
> +op = tree[0]
> +if op in ('symbol', 'string'):
> +name = fileset.getstring(tree, 'invalid file pattern')
> +op = name[0]
> +if op == '*': # file extension test, ex. "*.tar.gz"
> +return lambda n, s: n.endswith(name[1:])

Better to make sure no metacharacters in name[1:].

> +elif op == '/': # directory or full path test
> +p = name[1:].rstrip('/') # prefix
> +pl = len(p)
> +f = lambda n, s: n.startswith(p) and (len(n) == pl or n[pl] == 
> '/')
> +return f

Perhaps this could be 'path:'.

> +else:
> +raise error.ParseError('invalid symbol: %s' % name)

_()

> +elif op in ['or', 'and']:
> +funcs = [_compile(t) for t in tree[1:]]
> +summary = {'or': any, 'and': all}[op]
> +return lambda n, s: summary(f(n, s) for f in funcs)

IIRC, ('or'/'and', x, y) isn't flattened in fileset.py, so the tree would have
exactly 2 operands.

> +elif op == 'not':
> +return lambda n, s: not _compile(tree[1])(n, s)
> +elif op == 'group':
> +return _compile(tree[1])
> +elif op == 'func':
> +name = tree[1][1]
> +symbols = {
> +'always': lambda n, s: True,
> +'never': lambda n, s: False,
> +'size': lambda n, s: fileset.sizematcher(tree[2])(s),
> +}
> +
> +if name in symbols:
> +return symbols[name]
> +
> +raise error.UnknownIdentifier(name, symbols.keys())
> +elif op in ('negate', 'minus'):
> +raise error.ParseError('unsupported operator: %s' % '-')
> +elif op in ('list'):

== 'list', in ('list',) or in {'list'}.

> +raise error.ParseError(_("can't use a list in this context"),
> +   hint=_('see hg help "filesets.x or y"'))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 2 of 2 V2] filterlang: add a small language to filter files

2018-01-11 Thread Matt Harbison

> On Jan 11, 2018, at 10:16 AM, Yuya Nishihara  wrote:
> 
>> On Thu, 11 Jan 2018 00:17:39 -0500, Matt Harbison wrote:
>> # HG changeset patch
>> # User Matt Harbison 
>> # Date 1515641014 18000
>> #  Wed Jan 10 22:23:34 2018 -0500
>> # Node ID 548e748cb3f4eea0aedb36a2b2e9fe3b77ffb263
>> # Parent  962b2bdd70d094ce4bf9a8135495788166b04510
>> filterlang: add a small language to filter files
> 
>> I also made the 'always' token a
>> predicate for consistency, and introduced 'never' to improve readability.
> 
> Perhaps '**' or '.' could be an "always" symbol given patterns are relative
> to the repository root in filterlang.

I’m thinking ahead to a tracked file that could be converted to this language, 
and trying to make it readable. This construct seems weird to me:

  **.c = !**

>> Finally, I changed the extension operator from '.' to '*'.  This matches how 
>> git
>> tracks by extension, but might be slightly confusing here because '**' 
>> recurses
>> in Mercurial, but '*' usually doesn't.
> 
> I prefer '**' or 'relglob:*' for fileset compatibility.

Good idea.

>> diff --git a/mercurial/filterlang.py b/mercurial/filterlang.py
>> new file mode 100644
>> --- /dev/null
>> +++ b/mercurial/filterlang.py
>> @@ -0,0 +1,73 @@
>> +# filterlang.py - a simple language to select files
> 
> The module name seems too generic.
> minifileset.py, ufileset.py, etc. or merge these functions into fileset.py?

minifileset.py I guess?  My concern with putting it in fileset.py is how to 
enforce the boundary clearly.

>> +from . import (
>> +error,
>> +fileset,
>> +util,
>> +)
> 
> Missing i18n._().
> 
>> +def _compile(tree):
>> +op = tree[0]
>> +if op in ('symbol', 'string'):
>> +name = fileset.getstring(tree, 'invalid file pattern')
>> +op = name[0]
>> +if op == '*': # file extension test, ex. "*.tar.gz"
>> +return lambda n, s: n.endswith(name[1:])
> 
> Better to make sure no metacharacters in name[1:].

Aren’t meta characters allowed in a string, so as to not block certain file 
names?  Does this mean symbol and string have to be handled separately?

>> +elif op == '/': # directory or full path test
>> +p = name[1:].rstrip('/') # prefix
>> +pl = len(p)
>> +f = lambda n, s: n.startswith(p) and (len(n) == pl or n[pl] == 
>> '/')
>> +return f
> 
> Perhaps this could be 'path:'.

Good idea.

>> +else:
>> +raise error.ParseError('invalid symbol: %s' % name)
> 
> _()

This was kind of a placeholder, because I couldn’t figure out how to put the 
position arg in here, or how to make it less cryptic.

>> +elif op in ['or', 'and']:
>> +funcs = [_compile(t) for t in tree[1:]]
>> +summary = {'or': any, 'and': all}[op]
>> +return lambda n, s: summary(f(n, s) for f in funcs)
> 
> IIRC, ('or'/'and', x, y) isn't flattened in fileset.py, so the tree would have
> exactly 2 operands.

fileset.andset() calls getset(), which checks the arg, but maybe that’s an 
artifact of other uses.

>> +elif op == 'not':
>> +return lambda n, s: not _compile(tree[1])(n, s)
>> +elif op == 'group':
>> +return _compile(tree[1])
>> +elif op == 'func':
>> +name = tree[1][1]
>> +symbols = {
>> +'always': lambda n, s: True,
>> +'never': lambda n, s: False,
>> +'size': lambda n, s: fileset.sizematcher(tree[2])(s),
>> +}
>> +
>> +if name in symbols:
>> +return symbols[name]
>> +
>> +raise error.UnknownIdentifier(name, symbols.keys())
>> +elif op in ('negate', 'minus'):
>> +raise error.ParseError('unsupported operator: %s' % '-')
>> +elif op in ('list'):
> 
> == 'list', in ('list',) or in {'list'}.
> 
>> +raise error.ParseError(_("can't use a list in this context"),
>> +   hint=_('see hg help "filesets.x or y"'))
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D1581: rust: implementation of `hg`

2018-01-11 Thread ruuda (Ruud van Asseldonk)
ruuda added a comment.


  Awesome! I have just a few things that could be written more briefly.

INLINE COMMENTS

> build.rs:39
> +let script = "import sysconfig; \
> +c = sysconfig.get_config_vars(); \
> +print('SEPARATOR STRING'.join('%s=%s' % i for i in c.items()))";

You can safely indent those, leading whitespace on the continuation line will 
be stripped from the string literal.

> build.rs:107
> +None => false,
> +};
> +

There is no need to match:

  let result = config.config.get(*key) == Some("1");

Or using assert as @kevincox recommends:

  assert_eq!(config.config.get(*key), Some("1"), "Detected ...");

> main.rs:187
> +Err(255)
> +}
> +Ok(()) => Ok(()),

There exists `Result::map_err` for this:

  result = run_py(&env, py).map_err(|err| {
  err.print(py);
  255
  });

REPOSITORY
  rHG Mercurial

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

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


D1846: rust: avoid redundant 'static lifetime

2018-01-11 Thread durin42 (Augie Fackler)
durin42 added a comment.


  In https://phab.mercurial-scm.org/D1846#31265, @yuja wrote:
  
  > I think it's new feature. Which Rust version should we support?
  >
  > 
https://github.com/rust-lang/rust/blob/master/RELEASES.md#version-1170-2017-04-27
  
  
  Hm, that's release notes from April of 2017, so about 9 months ago. To my 
understanding, as long as we're only using the stable channel, we should be 
fine for the binaries we're building being packageable even on slower-moving 
distros like Debian. Let's go with this for now, worst case we can re-add the 
annotation.

REPOSITORY
  rHG Mercurial

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

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


D1846: rust: avoid redundant 'static lifetime

2018-01-11 Thread indygreg (Gregory Szorc)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG24b5106e3e1e: rust: avoid redundant 'static lifetime 
(authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1846?vs=4790&id=4798

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

AFFECTED FILES
  rust/hgcli/build.rs

CHANGE DETAILS

diff --git a/rust/hgcli/build.rs b/rust/hgcli/build.rs
--- a/rust/hgcli/build.rs
+++ b/rust/hgcli/build.rs
@@ -84,7 +84,7 @@
 return dll.exists();
 }
 
-const REQUIRED_CONFIG_FLAGS: [&'static str; 2] = ["Py_USING_UNICODE", 
"WITH_THREAD"];
+const REQUIRED_CONFIG_FLAGS: [&str; 2] = ["Py_USING_UNICODE", "WITH_THREAD"];
 
 fn main() {
 let config = get_python_config();



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


D1846: rust: avoid redundant 'static lifetime

2018-01-11 Thread glandium (Mike Hommey)
glandium added a comment.


  >   To my understanding, as long as we're only using the stable channel, we 
should be fine for the binaries we're building being packageable even on 
slower-moving distros like Debian.
  
  Slow-moving distros like Debian don't update the rust compiler. Debian stable 
is stuck on rustc 1.14 until Debian buster (next year?).

REPOSITORY
  rHG Mercurial

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

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


D1846: rust: avoid redundant 'static lifetime

2018-01-11 Thread durin42 (Augie Fackler)
durin42 added a comment.


  In https://phab.mercurial-scm.org/D1846#31298, @glandium wrote:
  
  > >   To my understanding, as long as we're only using the stable channel, we 
should be fine for the binaries we're building being packageable even on 
slower-moving distros like Debian.
  >
  > Slow-moving distros like Debian don't update the rust compiler. Debian 
stable is stuck on rustc 1.14 until Debian buster (next year?).
  
  
  My understanding (correct me if you know more) was that that's the 
distributed compiler, but it's okay to depend on backports or rustup to /build/ 
packages, since there aren't runtime deps on anything from rustc.

REPOSITORY
  rHG Mercurial

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

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


D1846: rust: avoid redundant 'static lifetime

2018-01-11 Thread glandium (Mike Hommey)
glandium added a comment.


  > but it's okay to depend on backports or rustup to /build/ packages
  
  The only exception where it's okay is, essentially, Firefox. With a backport 
of the rust compiler landing in stable about once a year, and even then it 
won't replace the version in stable. See the gcc-mozilla package in Debian 
wheezy.

REPOSITORY
  rHG Mercurial

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

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


Re: [PATCH 2 of 2 V2] filterlang: add a small language to filter files

2018-01-11 Thread Matt Harbison
On Thu, 11 Jan 2018 11:13:57 -0500, Matt Harbison   
wrote:





On Jan 11, 2018, at 10:16 AM, Yuya Nishihara  wrote:


On Thu, 11 Jan 2018 00:17:39 -0500, Matt Harbison wrote:
# HG changeset patch
# User Matt Harbison 
# Date 1515641014 18000
#  Wed Jan 10 22:23:34 2018 -0500
# Node ID 548e748cb3f4eea0aedb36a2b2e9fe3b77ffb263
# Parent  962b2bdd70d094ce4bf9a8135495788166b04510
filterlang: add a small language to filter files


Finally, I changed the extension operator from '.' to '*'.  This  
matches how git
tracks by extension, but might be slightly confusing here because '**'  
recurses

in Mercurial, but '*' usually doesn't.


I prefer '**' or 'relglob:*' for fileset compatibility.


Good idea.


+elif op == '/': # directory or full path test
+p = name[1:].rstrip('/') # prefix
+pl = len(p)
+f = lambda n, s: n.startswith(p) and (len(n) == pl or  
n[pl] == '/')

+return f


Perhaps this could be 'path:'.


Good idea.


I ended up needing to add this to avoid a parse error.  The "*fileset*"  
tests run, but I'm not sure if this should be allowed for normal  
filesets.  The '/' operator works because it is in the globchars string.


diff --git a/mercurial/fileset.py b/mercurial/fileset.py
--- a/mercurial/fileset.py
+++ b/mercurial/fileset.py
@@ -72,13 +72,13 @@
 pos += 1
 else:
 raise error.ParseError(_("unterminated string"), s)
-elif c.isalnum() or c in globchars or ord(c) > 127:
+elif c.isalnum() or c in globchars or ord(c) > 127 or c == ':':
 # gather up a symbol/keyword
 s = pos
 pos += 1
 while pos < l: # find end of symbol
 d = program[pos]
-if not (d.isalnum() or d in globchars or ord(d) > 127):
+if not (d.isalnum() or d in globchars or ord(d) > 127 or  
d == ':'):

 break
 pos += 1
 sym = program[s:pos]
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Switching to a date-based version scheme?

2018-01-11 Thread Gregory Szorc
Mercurial's version numbers (currently 4.4, soon to be 4.5) mean little to
nothing. Mercurial's existing .. version scheme
doesn't honor semantic versioning in the traditional sense. API guarantees
are that each quarterly X.Y release generally maintains API compatibility
within the release but there are no guarantees between quarterly releases.
The  component of the version scheme is incremented when 
would hit 10 - not when there is a major API change. (This is an arbitrary
decision since it is technically possible to have version components with
an absolute value >=10.)

To the typical user who isn't intimately familiar with Mercurial's
versioning and release strategy, the existing versioning scheme means
little to nothing.

A typical user does care about something: whether their Mercurial is up to
date.

One way of determining if something is up to date is asking "how old is it?"

I'd like to propose changing Mercurial's versioning scheme so it is based
on release date. This versioning scheme would reinforce the reality of
Mercurial's time-based release cadence and help average users understand
how old their Mercurial release is. It would not sacrifice adherence to
semantic versioning compared to what we do currently.

There is certainly room to bikeshed time based versioning schemes. I'll
suggest a scheme that is similar to how we currently do things:
YY.[M]M.[N]N, where:

YY = 2000 - current calendar year (2018 = 18)
[M]M = month of major release (January = 1, December = 12)
[N]N = Point release (initial = 0, subsequent N+1)

So, the next release of Mercurial would be 18.2.0, corresponding to
February 2018. Point releases would be 18.2.1, 18.2.2, 18.2.3, etc. The
next quarterly release would be 18.5.0 (May 2018). Then 18.8.0 and 18.11.0.
A year from now, we'd release 19.2.0.

Random questions...

If we only release quarterly, why not use 1, 2, 3, 4 for the minor version
component? Using the month reinforces the date based nature of the release
mechanism. If we ever decide to move to a faster or slower major release
cadence, a minor version component reflecting the month doesn't need to
change semantic meaning.

Why use 1, 2, 3 as opposed to 01, 02, 03, etc? This should be an arbitrary
decision. Padding zeros would provide some defense against tools that do a
bytes-level string comparison. However, tools shouldn't be using string
compare for version sorting. PEP 440 says that leading 0s should be ignored
in integer version fields. Even the Linux kernel doesn't use zero padding.
We /could/ use 0 padding if people feel it is needed. But it shouldn't be
necessary.

Since major versions are quarterly, why not combine the year and month
components into the same version field? e.g. 201802.0 instead of 2018.2.0.
This is a reasonable bikeshed to have. If we want to have stronger semantic
versioning guarantees, combining the year and month components into a
single field to reflect the actual API guarantees does make sense. But API
guarantees are what we define them to be. Only purists care about whether
API compatibility is preserved between . or just .
Until we start providing libraries with strong backwards compatibility
guarantees, it doesn't really matter.

Thoughts?

If adopted, what would need changed?
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel