depth: basic debugdepth implementation and test
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 22 Nov 2017 16:57:07 +0100
changeset 3236 7c78b0c482a1
parent 3235 8a772f0c54d9
child 3237 9a2cc4687cb9
depth: basic debugdepth implementation and test This will come very handy to validate more advanced implementation later.
hgext3rd/evolve/depthcache.py
hgext3rd/evolve/stablerange.py
tests/test-stablerange.t
tests/test-stablesort-criss-cross.t
tests/test-stablesort.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hgext3rd/evolve/depthcache.py	Wed Nov 22 16:57:07 2017 +0100
@@ -0,0 +1,31 @@
+from __future__ import absolute_import
+
+from mercurial import (
+    scmutil,
+)
+
+from . import (
+    exthelper,
+)
+
+from mercurial.i18n import _
+
+eh = exthelper.exthelper()
+
+def simpledepth(repo, rev):
+    """simple but obviously right implementation of depth"""
+    return len(repo.revs('::%d', rev))
+
+@eh.command(
+    'debugdepth',
+    [
+        ('r', 'rev', [], 'revs to print depth for'),
+    ],
+    _('REVS'))
+def debugdepth(ui, repo, **opts):
+    """display depth of REVS
+    """
+    revs = scmutil.revrange(repo, opts['rev'])
+    for r in revs:
+        ctx = repo[r]
+        ui.write('%s %d\n' % (ctx, simpledepth(repo, r)))
--- a/hgext3rd/evolve/stablerange.py	Sat Dec 09 06:13:28 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py	Wed Nov 22 16:57:07 2017 +0100
@@ -29,10 +29,12 @@
 from mercurial.i18n import _
 
 from . import (
+    depthcache,
     exthelper,
 )
 
 eh = exthelper.exthelper()
+eh.merge(depthcache.eh)
 
 # prior to hg-4.2 there are not util.timer
 if util.safehasattr(util, 'timer'):
--- a/tests/test-stablerange.t	Sat Dec 09 06:13:28 2017 +0100
+++ b/tests/test-stablerange.t	Wed Nov 22 16:57:07 2017 +0100
@@ -16,6 +16,14 @@
   $ hg init repo_linear
   $ cd repo_linear
   $ hg debugbuilddag '.+6'
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  01241442b3c2 3
+  2dc09a01254d 4
+  bebd167eb94d 5
+  c8d03c1b5e94 6
+  f69452c5b1af 7
   $ hg debugstablerange --verify --verbose --subranges --rev 1
   66f7d451a68b-0 (1, 2, 2) [complete] - 1ea73414a91b-0 (0, 1, 1), 66f7d451a68b-1 (1, 2, 1)
   1ea73414a91b-0 (0, 1, 1) [leaf] - 
@@ -156,6 +164,17 @@
   |/
   o  0 1ea73414a91b r0 base
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  01241442b3c2 3
+  2dc09a01254d 4
+  e7bd5218ca15 2
+  3a367db1fabc 3
+  a2f58e9c1e56 4
+  5f18015f9110 8
+  71b32fcf3f71 9
+  0338daf18215 10
 
 Each of the linear branch reuse range internally
 
@@ -327,6 +346,20 @@
   |/
   o  0 1ea73414a91b r0 base
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  01241442b3c2 3
+  2dc09a01254d 4
+  bebd167eb94d 5
+  de561312eff4 2
+  b9bc20507e0b 3
+  42b07e8da27d 4
+  857477a9aebb 5
+  f4b7da68b467 6
+  8aca7f8c9bd2 11
+  485383494a89 12
+  e6b8d5b46647 13
 
 Each of the linear branch reuse range internally
 
@@ -605,6 +638,23 @@
   |/
   o  0 1ea73414a91b r0
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  fa942426a6fd 2
+  2b6d669947cd 4
+  4c748ffd1a46 3
+  f0f3ef9a6cd5 4
+  2702dd0c91e7 5
+  e7d9710d9fc6 5
+  d62d843c9a01 6
+  dcbb326fdec2 7
+  ff43616e5d0f 7
+  bab5d5bf48bd 5
+  e46a4836065c 6
+  b4594d867745 6
+  43227190fef8 5
+  1d8d22637c2d 8
   $ hg debugstablerange --verify --verbose --subranges --rev 'head()'
   1d8d22637c2d-0 (15, 8, 8) [complete] - 2b6d669947cd-0 (3, 4, 4), 1d8d22637c2d-4 (15, 8, 4)
   dcbb326fdec2-0 (9, 7, 7) [complete] - 2b6d669947cd-0 (3, 4, 4), dcbb326fdec2-4 (9, 7, 3)
@@ -664,6 +714,12 @@
   |/
   o  0 1ea73414a91b r0
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  fa942426a6fd 2
+  36315563e2fa 3
+  f37e476fba9a 5
   $ hg debugstablerange --verify --verbose --subranges --rev 'head()'
   f37e476fba9a-0 (4, 5, 5) [complete] - 66f7d451a68b-0 (1, 2, 2), 36315563e2fa-0 (3, 3, 3), f37e476fba9a-4 (4, 5, 1)
   36315563e2fa-0 (3, 3, 3) [complete] - fa942426a6fd-0 (2, 2, 2), 36315563e2fa-2 (3, 3, 1)
--- a/tests/test-stablesort-criss-cross.t	Sat Dec 09 06:13:28 2017 +0100
+++ b/tests/test-stablesort-criss-cross.t	Wed Nov 22 16:57:07 2017 +0100
@@ -293,6 +293,102 @@
   |
   o  0 1ea73414a91b r0
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  01241442b3c2 3
+  2dc09a01254d 4
+  bebd167eb94d 5
+  c8d03c1b5e94 6
+  0c1445abb33d 4
+  65eb34ffc3a8 5
+  c81423bf5a24 9
+  07c648efceeb 9
+  5ba9a53052ed 11
+  3e2da24aee59 12
+  26f59ee8b1d7 13
+  f7c6e7bfbcd0 13
+  39bab1cb1cbe 15
+  55bf3fdb634f 15
+  3e1560705803 17
+  4f5078f7da8a 18
+  9729470d9329 18
+  884936b34999 19
+  b115c694654e 18
+  17b6e6bac221 18
+  5ce588c2b7c5 19
+  f2bdd828a3aa 20
+  a457569c5306 21
+  ad46a4a0fc10 22
+  de05b9c29ec7 18
+  2bd677d0f13a 21
+  3bdb00d5c818 22
+  b9c3aa92fba5 23
+  f3441cd3e664 24
+  0c3f2ba59eb7 25
+  2ea3fbf151b5 26
+  47c836a1f13e 27
+  722d1b8b8942 28
+  1f4a19f83a29 20
+  01e29e20ea3f 24
+  32b41ca704e1 25
+  e3e6738c56ce 20
+  88714f4125cb 21
+  d928b4e8a515 22
+  88eace5ce682 23
+  43fc0b77ff07 21
+  4b39f229a0ce 25
+  d94da36be176 26
+  40553f55397e 21
+  bfcfd9a61e84 20
+  d6c9e2d27f14 21
+  8ecb28746ec4 21
+  673f5499c8c2 24
+  900dd066a072 25
+  97ac964e34b7 26
+  0d153e3ad632 27
+  c37e7cd9f2bd 28
+  9a67238ad1c4 29
+  76151e8066e1 20
+  c7c1497fc270 21
+  e7135b665740 22
+  29141354a762 24
+  0484d39906c8 25
+  5eec91b12a58 26
+  c84da74cf586 27
+  3871506da61e 28
+  bf6593f7e073 24
+  b33fd5ad4c0c 24
+  c713eae2d31f 20
+  d99e0f7dad5b 21
+  e4cfd6264623 22
+  fac9e582edd1 23
+  d917f77a6439 20
+  c3c7fa726f88 21
+  4f3b41956174 24
+  eed373b0090d 36
+  31d7b43cc321 24
+  698970a2480b 31
+  790cdfecd168 24
+  37ad3ab0cddf 29
+  97d19fc5236f 25
+  89a0fe204177 36
+  82238c0bc950 25
+  cd345198cf12 27
+  0bab31f71a21 31
+  1da228afcf06 31
+  b3cf98c3d587 49
+  dbde319d43a3 31
+  28be96b80dc1 36
+  469c700e9ed8 37
+  c7d3029bf731 38
+  2472d042ec95 43
+  041e1188f5f1 55
+  8b79544bb56d 48
+  8ae32c3ed670 48
+  721ba7c5f4ff 77
+  84d6ec6a8e21 65
+  01f771406cab 95
 
 Basic check
 -----------
--- a/tests/test-stablesort.t	Sat Dec 09 06:13:28 2017 +0100
+++ b/tests/test-stablesort.t	Wed Nov 22 16:57:07 2017 +0100
@@ -90,6 +90,23 @@
   |/
   o  0 1ea73414a91b r0
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  fa942426a6fd 2
+  2b6d669947cd 4
+  4c748ffd1a46 3
+  f0f3ef9a6cd5 4
+  2702dd0c91e7 5
+  e7d9710d9fc6 5
+  d62d843c9a01 6
+  dcbb326fdec2 7
+  ff43616e5d0f 7
+  bab5d5bf48bd 5
+  e46a4836065c 6
+  b4594d867745 6
+  43227190fef8 5
+  1d8d22637c2d 8
   $ hg showsort --rev 'all()' --traceback
   1ea73414a91b
   66f7d451a68b
@@ -208,6 +225,23 @@
   |/
   o  0 1ea73414a91b r0
   
+  $ hg -R repo_B debugdepth -r 'all()'
+  1ea73414a91b 1
+  fa942426a6fd 2
+  4c748ffd1a46 3
+  f0f3ef9a6cd5 4
+  66f7d451a68b 2
+  2b6d669947cd 4
+  bab5d5bf48bd 5
+  b4594d867745 6
+  43227190fef8 5
+  2702dd0c91e7 5
+  e7d9710d9fc6 5
+  d62d843c9a01 6
+  dcbb326fdec2 7
+  ff43616e5d0f 7
+  e46a4836065c 6
+  1d8d22637c2d 8
   $ hg -R repo_B log -G > B.log
 
   $ hg clone repo_A repo_C --rev 10
@@ -553,6 +587,28 @@
   |/
   o  0 1ea73414a91b r0 base
   
+  $ hg debugdepth -r 'all()'
+  1ea73414a91b 1
+  66f7d451a68b 2
+  01241442b3c2 3
+  2dc09a01254d 4
+  e7bd5218ca15 2
+  3a367db1fabc 3
+  a2f58e9c1e56 4
+  5f18015f9110 8
+  abf57d94268b 5
+  529dfc5bb875 6
+  6ee532b68cfa 3
+  001194dd78d5 9
+  a66b68853635 10
+  013b27f11536 11
+  4bbfc6078919 12
+  9fff0871d230 9
+  4dbf739dd63f 10
+  d64d500024d1 11
+  0496f0a6a143 16
+  1c645e73dbc6 17
+  160a7a0adbf4 18
   $ hg showsort --rev 'all()'
   1ea73414a91b
   66f7d451a68b
@@ -682,6 +738,12 @@
   |/
   o  0 d20a80d4def3 base
   
+  $ hg debugdepth -r 'all()'
+  d20a80d4def3 1
+  47da0f2c25e2 2
+  0dedbcd995b6 3
+  ed776db7ed63 4
+  7f2454f6b04f 5
   $ hg showsort --rev '.'
   d20a80d4def3
   47da0f2c25e2