Patchwork match: stabilize _rootsdirsandparents doctest

login
register
mail settings
Submitter Pierre-Yves David
Date May 24, 2019, 10:41 a.m.
Message ID <96fc696a9cb2052561af.1558694474@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40223/
State Accepted
Headers show

Comments

Pierre-Yves David - May 24, 2019, 10:41 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1558694026 -7200
#      Fri May 24 12:33:46 2019 +0200
# Node ID 96fc696a9cb2052561afd8918676b05720ee5244
# Parent  21e77ede77abbbb299c7bab2a73dd144225a0ff9
# EXP-Topic fix-build
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 96fc696a9cb2
match: stabilize _rootsdirsandparents doctest

Changeset c4b8f8637d7a tried to stabilize some matcher test by using a set. This
did not work because the set order is not stable. To fix it, we post process the
result to display a sorted version of the set.
Pulkit Goyal - May 24, 2019, 12:19 p.m.
On Fri, May 24, 2019 at 1:49 PM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1558694026 -7200
> #      Fri May 24 12:33:46 2019 +0200
> # Node ID 96fc696a9cb2052561afd8918676b05720ee5244
> # Parent  21e77ede77abbbb299c7bab2a73dd144225a0ff9
> # EXP-Topic fix-build
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> 96fc696a9cb2
> match: stabilize _rootsdirsandparents doctest
>
> Changeset c4b8f8637d7a tried to stabilize some matcher test by using a
> set. This
> did not work because the set order is not stable. To fix it, we post
> process the
> result to display a sorted version of the set.
>

Queued, many thanks for the fix.

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -1380,21 +1380,25 @@  def _rootsdirsandparents(kindpats):
 
     Returns a tuple of (roots, dirs, parents).
 
-    >>> _rootsdirsandparents(
+    >>> r = _rootsdirsandparents(
     ...     [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
     ...      (b'glob', b'g*', b'')])
-    (['g/h', 'g/h', ''], [], set(['', 'g']))
-    >>> _rootsdirsandparents(
+    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
+    (['g/h', 'g/h', ''], []) ['', 'g']
+    >>> r = _rootsdirsandparents(
     ...     [(b'rootfilesin', b'g/h', b''), (b'rootfilesin', b'', b'')])
-    ([], ['g/h', ''], set(['', 'g']))
-    >>> _rootsdirsandparents(
+    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
+    ([], ['g/h', '']) ['', 'g']
+    >>> r = _rootsdirsandparents(
     ...     [(b'relpath', b'r', b''), (b'path', b'p/p', b''),
     ...      (b'path', b'', b'')])
-    (['r', 'p/p', ''], [], set(['', 'p']))
-    >>> _rootsdirsandparents(
+    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
+    (['r', 'p/p', ''], []) ['', 'p']
+    >>> r = _rootsdirsandparents(
     ...     [(b'relglob', b'rg*', b''), (b're', b're/', b''),
     ...      (b'relre', b'rr', b'')])
-    (['', '', ''], [], set(['']))
+    >>> print(r[0:2], sorted(r[2])) # the set has an unstable output
+    (['', '', ''], []) ['']
     '''
     r, d = _patternrootsanddirs(kindpats)