Patchwork [1,of,2,STABLE] revset: get revision number of each nodes gotten from target namespaces

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 3, 2015, 1:04 p.m.
Message ID <147878ac1d02298847d5.1422968683@juju>
Download mbox | patch
Permalink /patch/7627/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Feb. 3, 2015, 1:04 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1422968189 -32400
#      Tue Feb 03 21:56:29 2015 +0900
# Branch stable
# Node ID 147878ac1d02298847d5b2a0d2e06063b2fefe91
# Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
revset: get revision number of each nodes gotten from target namespaces

Before this patch, revset predicate "named()" uses each nodes gotten
from target namespaces directly.

This causes problems below:

  - combination of other predicates doesn't work correctly, because
    they assume that revisions are listed up in number

  - "hg log" doesn't show any revisions for "named()" result, because:

    - "changeset_printer" stores formatted output for each revisions
      into dict with revision number (= ctx.rev()) as a key of them

    - "changeset_printer.flush(rev)" writes stored output for
      the specified revision, but

    - "commands.log" invokes it with the node, gotten from "named()"

  - "hg debugrevspec" shows nodes (= may be binary) directly

Difference between revset predicate "tag()" and "named('tags')" in
tests is fixed in subsequent patch.
Pierre-Yves David - Feb. 3, 2015, 3:53 p.m.
On 02/03/2015 01:04 PM, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1422968189 -32400
> #      Tue Feb 03 21:56:29 2015 +0900
> # Branch stable
> # Node ID 147878ac1d02298847d5b2a0d2e06063b2fefe91
> # Parent  3667bc21b8773715d9472a3b4e034b77e62c6451
> revset: get revision number of each nodes gotten from target namespaces
>
> Before this patch, revset predicate "named()" uses each nodes gotten
> from target namespaces directly.
>
> This causes problems below:
>
>    - combination of other predicates doesn't work correctly, because
>      they assume that revisions are listed up in number
>
>    - "hg log" doesn't show any revisions for "named()" result, because:
>
>      - "changeset_printer" stores formatted output for each revisions
>        into dict with revision number (= ctx.rev()) as a key of them
>
>      - "changeset_printer.flush(rev)" writes stored output for
>        the specified revision, but
>
>      - "commands.log" invokes it with the node, gotten from "named()"
>
>    - "hg debugrevspec" shows nodes (= may be binary) directly
>
> Difference between revset predicate "tag()" and "named('tags')" in
> tests is fixed in subsequent patch.

Surprise, the old changesets had no tests and ended up being an absolute 
non-sense. Queuing for stable.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1277,7 +1277,7 @@  def named(repo, subset, x):
     names = set()
     for ns in namespaces:
         for name in ns.listnames(repo):
-            names.update(ns.nodes(repo, name))
+            names.update(repo[n].rev() for n in ns.nodes(repo, name))
 
     names -= set([node.nullrev])
     return subset & names
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -787,6 +787,12 @@  we can use patterns when searching for t
   $ log 'present(named("unknown"))'
   $ log 'present(named("re:unknown"))'
 
+  $ log 'tag()'
+  6
+  $ log 'named("tags")'
+  6
+  9
+
 issue2437
 
   $ log '3 and p1(5)'