changeset 1588:e2d38f6b8afe

tests: make output comaptible with hash changes in hg-4.8 46da52f4b820 in core mercurial added logic to try hard to reuse manifest if we can. In the tests of hgsubversion, there are lot of cases we create an empty commit with just branch name changed. In hg < 4.8, hgsubversion used to create a new manifest entry for that commit but after that patch, empty commit started using the manifest of the parent leading to hash change.
author Pulkit Goyal <pulkit@yandex-team.ru>
date Wed, 31 Oct 2018 17:04:57 +0300
parents 4889843a704e
children bd61c929f9bb
files tests/test_fetch_command.py tests/test_fetch_mappings.py tests/test_tags.py tests/test_utility_commands.py
diffstat 4 files changed, 54 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test_fetch_command.py
+++ b/tests/test_fetch_command.py
@@ -41,8 +41,9 @@ class TestBasicRepoLayout(test_util.Test
         repo = self._load_fixture_and_fetch('simple_branch.svndump')
         self.assertEqual(node.hex(repo[0].node()),
                          'a1ff9f5d90852ce7f8e607fa144066b0a06bdc57')
-        self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
-                         '545e36ed13615e39c5c8fb0c325109d8cb8e00c3')
+        self.assertTrue(node.hex(revsymbol(repo, 'tip').node()) in
+                         ('545e36ed13615e39c5c8fb0c325109d8cb8e00c3',
+                          '04043a3f29a7070b1ea56d6ef832591956a41381'))
         self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
         self.assertEqual(revsymbol(repo, 'tip').parents()[0], revsymbol(repo, 'default'))
         self.assertEqual(revsymbol(repo, 'tip').extra()['convert_revision'],
@@ -57,10 +58,14 @@ class TestBasicRepoLayout(test_util.Test
                          '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
         self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
                          '1083037b18d85cd84fa211c5adbaeff0fea2cd9f')
-        self.assertEqual(node.hex(revsymbol(repo, 'the_branch').node()),
-                         '4e256962fc5df545e2e0a51d0d1dc61c469127e6')
-        self.assertEqual(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()),
-                         'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
+        # two hashes to be compat with hg < 4.8 because from 4.8 we try hard to
+        # reuse the manifest
+        self.assertTrue(node.hex(revsymbol(repo, 'the_branch').node()) in
+                        ('4e256962fc5df545e2e0a51d0d1dc61c469127e6',
+                         '13c5dc1514ad8619c589a8929bfe0ece5c00f18e'))
+        self.assertTrue(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()) in
+                        ('f1ff5b860f5dbb9a59ad0921a79da77f10f25109',
+                         '62f4e5fb583a405df3dae62c156461a0f44219f2'))
         self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
         self.assertEqual(revsymbol(repo, 'tip'), revsymbol(repo, 'default'))
         self.assertEqual(len(repo.heads()), 2)
@@ -73,12 +78,15 @@ class TestBasicRepoLayout(test_util.Test
         # two possible hashes for bw compat to hg < 1.5, since hg 1.5
         # sorts entries in extra()
         self.assertTrue(node.hex(revsymbol(repo, 'tip').node()) in
-                         ('e92012d8c170a0236c84166167f149c2e28548c6',
-                         'b7bdc73041b1852563deb1ef3f4153c2fe4484f2'))
-        self.assertEqual(node.hex(revsymbol(repo, 'the_branch').node()),
-                         '4e256962fc5df545e2e0a51d0d1dc61c469127e6')
-        self.assertEqual(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()),
-                         'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
+                        ('e92012d8c170a0236c84166167f149c2e28548c6',
+                        'b7bdc73041b1852563deb1ef3f4153c2fe4484f2'))
+        # two possible hashes for backward compatibility with hg < 4.8
+        self.assertTrue(node.hex(revsymbol(repo, 'the_branch').node()) in
+                        ('4e256962fc5df545e2e0a51d0d1dc61c469127e6',
+                         '13c5dc1514ad8619c589a8929bfe0ece5c00f18e'))
+        self.assertTrue(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()) in
+                        ('f1ff5b860f5dbb9a59ad0921a79da77f10f25109',
+                         '62f4e5fb583a405df3dae62c156461a0f44219f2'))
         self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
         self.assertEqual(revsymbol(repo, 'tip'), revsymbol(repo, 'default'))
         self.assertEqual(len(repo.heads()), 2)
@@ -119,8 +127,11 @@ class TestBasicRepoLayout(test_util.Test
                          '926671740dec045077ab20f110c1595f935334fa')
         self.assertEqual(revsymbol(repo, 'tip').parents()[0].parents()[0],
                          revsymbol(repo, 'oldest'))
-        self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
-                         '1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
+        # two hashes for backward compatibility with hg < 4.8 because from 4.8,
+        # we try hard to reuse the manifest
+        self.assertTrue(node.hex(revsymbol(repo, 'tip').node()) in
+                         ('1a6c3f30911d57abb67c257ec0df3e7bc44786f7',
+                          'fa799f2781255dba874645e849d75af837472518'))
 
     def test_propedit_with_nothing_else(self):
         repo = self._load_fixture_and_fetch('branch_prop_edit.svndump')
@@ -185,12 +196,15 @@ class TestStupidPull(test_util.TestBase)
                          '434ed487136c1b47c1e8f952edb4dc5a8e6328df')
         self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
                          '1083037b18d85cd84fa211c5adbaeff0fea2cd9f')
-        self.assertEqual(node.hex(revsymbol(repo, 'the_branch').node()),
-                         '4e256962fc5df545e2e0a51d0d1dc61c469127e6')
+        # two hashes to be compat with hg < 4.8
+        self.assertTrue(node.hex(revsymbol(repo, 'the_branch').node()) in
+                         ('4e256962fc5df545e2e0a51d0d1dc61c469127e6',
+                          '13c5dc1514ad8619c589a8929bfe0ece5c00f18e'))
         self.assertEqual(revsymbol(repo, 'the_branch').extra()['convert_revision'],
                          'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/branches/the_branch@5')
-        self.assertEqual(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()),
-                         'f1ff5b860f5dbb9a59ad0921a79da77f10f25109')
+        self.assertTrue(node.hex(revsymbol(repo, 'the_branch').parents()[0].node()) in
+                        ('f1ff5b860f5dbb9a59ad0921a79da77f10f25109',
+                         '62f4e5fb583a405df3dae62c156461a0f44219f2'))
         self.assertEqual(len(revsymbol(repo, 'tip').parents()), 1)
         self.assertEqual(revsymbol(repo, 'default').extra()['convert_revision'],
                          'svn:df2126f7-00ab-4d49-b42c-7e981dde0bcf/trunk@6')
@@ -204,8 +218,10 @@ class TestStupidPull(test_util.TestBase)
                          '926671740dec045077ab20f110c1595f935334fa')
         self.assertEqual(revsymbol(repo, 'tip').parents()[0].parents()[0],
                          revsymbol(repo, 'oldest'))
-        self.assertEqual(node.hex(revsymbol(repo, 'tip').node()),
-                         '1a6c3f30911d57abb67c257ec0df3e7bc44786f7')
+        # two hashes to be compat with hg < 4.8
+        self.assertTrue(node.hex(revsymbol(repo, 'tip').node()) in
+                         ('1a6c3f30911d57abb67c257ec0df3e7bc44786f7',
+                          'fa799f2781255dba874645e849d75af837472518'))
 
     def test_empty_repo(self):
         # This used to crash HgEditor because it could be closed without
--- a/tests/test_fetch_mappings.py
+++ b/tests/test_fetch_mappings.py
@@ -147,14 +147,18 @@ class MapTests(test_util.TestBase):
         repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
             "include alpha\n")
         self.assertEqual(node.hex(repo[0].node()), '88e2c7492d83e4bf30fbb2dcbf6aa24d60ac688d')
-        self.assertEqual(node.hex(revsymbol(repo, 'default').node()), 'e524296152246b3837fe9503c83b727075835155')
+        self.assertTrue(node.hex(revsymbol(repo, 'default').node()) in
+                        ('e524296152246b3837fe9503c83b727075835155',
+                         'ecf9b521a1799ebb0e01c1d1e86305ea8b542d2e'))
 
     @test_util.requiresreplay
     def test_file_map_exclude(self):
         repo = self._loadwithfilemap('replace_trunk_with_branch.svndump',
             "exclude alpha\n")
         self.assertEqual(node.hex(repo[0].node()), '2c48f3525926ab6c8b8424bcf5eb34b149b61841')
-        self.assertEqual(node.hex(revsymbol(repo, 'default').node()), 'b37a3c0297b71f989064d9b545b5a478bbed7cc1')
+        self.assertTrue(node.hex(revsymbol(repo, 'default').node()) in
+                        ('b37a3c0297b71f989064d9b545b5a478bbed7cc1',
+                         'e494691507b55deeb85c9c362d47b427f5c644ad'))
 
     @test_util.requiresreplay
     def test_file_map_rule_order(self):
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -72,10 +72,14 @@ rename a tag
         repo = self._load_fixture_and_fetch('tag_deletion_tag_branch.svndump')
         branches = set(repo[h].extra()['branch'] for h in repo.heads())
         self.assertEqual(branches, set(['default', 'from_2', ]))
-        self.assertEqual(
-            repo.tags(),
-            {'tip': 'g\xdd\xcd\x93\x03g\x1e\x7f\xa6-[V%\x99\x07\xd3\x9d>(\x94',
-             'new_tag': '=\xb8^\xb5\x18\xa9M\xdb\xf9\xb62Z\xa0\xb5R6+\xfe6.'})
+        # two hash values because from hg > 4.8, we try hard to reuse a manifest
+        # which leads to hash change of empty changesets
+        self.assertTrue(
+            repo.tags() in
+            ({'tip': 'g\xdd\xcd\x93\x03g\x1e\x7f\xa6-[V%\x99\x07\xd3\x9d>(\x94',
+             'new_tag': '=\xb8^\xb5\x18\xa9M\xdb\xf9\xb62Z\xa0\xb5R6+\xfe6.'},
+             {'new_tag': '\x1d+\xb8v:6@9D\x9f\xb9\xf4o\xd4n\x8e\x93\xd7\x07\xe3',
+              'tip': 'F/\xb8V\xd9\x00\xdb\xca\x9b\xd7\x90+O\x02\xbe\xe5\xd6\xc6\x7f\x99'}))
 
     def test_tags_in_unusual_location(self):
         repo = self._load_fixture_and_fetch('unusual_tags.svndump')
--- a/tests/test_utility_commands.py
+++ b/tests/test_utility_commands.py
@@ -184,7 +184,8 @@ class UtilityTests(test_util.TestBase):
         hg.update(self.repo, new)
         wrappers.parents(lambda x, y: None, u, self.repo, svn=True)
         actual = u.popbuffer()
-        self.assertEqual(actual, '3:4e256962fc5d\n')
+        # two hashes becaure in hg > 4.8 we try hard to reuse the manifest
+        self.assertTrue(actual in ('3:4e256962fc5d\n', '3:13c5dc1514ad\n'))
 
         hg.update(self.repo, revsymbol(self.repo, 'default'))
 
@@ -232,7 +233,8 @@ class UtilityTests(test_util.TestBase):
         commands.outgoing(u, self.repo, repourl(repo_path))
         actual = u.popbuffer()
         self.assertTrue(node.hex(revsymbol(self.repo, 'localbranch').node())[:8] in actual)
-        self.assertEqual(actual.strip(), '5:6de15430fa20')
+        # two hashes for compat with hg < 4.8
+        self.assertTrue(actual.strip() in ('5:6de15430fa20', '5:76670ad282fd'))
         hg.update(self.repo, revsymbol(self.repo, 'default'))
         u.pushbuffer()
         commands.outgoing(u, self.repo, repourl(repo_path))