Mercurial > hgsubversion
comparison tests/comprehensive/test_rebuildmeta.py @ 1255:139a44a63090 stable 1.7
Merge default into stable for a release.
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Wed, 05 Nov 2014 12:48:59 -0500 |
| parents | 11c8de73b48a |
| children | c6b01fd34694 |
comparison
equal
deleted
inserted
replaced
| 1230:807c443928d4 | 1255:139a44a63090 |
|---|---|
| 1 import os | 1 import os |
| 2 import pickle | |
| 3 import unittest | 2 import unittest |
| 4 import sys | 3 import sys |
| 5 | 4 |
| 6 # wrapped in a try/except because of weirdness in how | 5 # wrapped in a try/except because of weirdness in how |
| 7 # run.py works as compared to nose. | 6 # run.py works as compared to nose. |
| 12 import test_util | 11 import test_util |
| 13 | 12 |
| 14 from mercurial import context | 13 from mercurial import context |
| 15 from mercurial import extensions | 14 from mercurial import extensions |
| 16 from mercurial import hg | 15 from mercurial import hg |
| 16 from mercurial import localrepo | |
| 17 from mercurial import ui | 17 from mercurial import ui |
| 18 from mercurial import util as hgutil | |
| 18 | 19 |
| 19 from hgsubversion import compathacks | 20 from hgsubversion import compathacks |
| 20 from hgsubversion import svncommands | 21 from hgsubversion import svncommands |
| 21 from hgsubversion import svnmeta | 22 from hgsubversion import svnmeta |
| 23 from hgsubversion import util | |
| 22 | 24 |
| 23 # These test repositories have harmless skew in rebuildmeta for the | 25 # These test repositories have harmless skew in rebuildmeta for the |
| 24 # last-pulled-rev because the last rev in svn causes absolutely no | 26 # last-pulled-rev because the last rev in svn causes absolutely no |
| 25 # changes in hg. | 27 # changes in hg. |
| 26 expect_youngest_skew = [('file_mixed_with_branches.svndump', False, False), | 28 expect_youngest_skew = [('file_mixed_with_branches.svndump', False, False), |
| 83 subdir), ]) | 85 subdir), ]) |
| 84 finally: | 86 finally: |
| 85 # remove the wrapper | 87 # remove the wrapper |
| 86 context.changectx.children = origchildren | 88 context.changectx.children = origchildren |
| 87 | 89 |
| 88 dest.pull(src) | 90 if hgutil.safehasattr(localrepo.localrepository, 'pull'): |
| 91 dest.pull(src) | |
| 92 else: | |
| 93 # Mercurial >= 3.2 | |
| 94 from mercurial import exchange | |
| 95 exchange.pull(dest, src) | |
| 89 | 96 |
| 90 # insert a wrapper that prevents calling changectx.children() | 97 # insert a wrapper that prevents calling changectx.children() |
| 91 extensions.wrapfunction(context.changectx, 'children', failfn) | 98 extensions.wrapfunction(context.changectx, 'children', failfn) |
| 92 try: | 99 try: |
| 93 svncommands.updatemeta(u, dest, | 100 svncommands.updatemeta(u, dest, |
| 108 'no .hg/svn directory in the destination!') | 115 'no .hg/svn directory in the destination!') |
| 109 dest = hg.repository(u, os.path.dirname(dest.path)) | 116 dest = hg.repository(u, os.path.dirname(dest.path)) |
| 110 for tf in ('lastpulled', 'rev_map', 'uuid', 'tagmap', 'layout', 'subdir',): | 117 for tf in ('lastpulled', 'rev_map', 'uuid', 'tagmap', 'layout', 'subdir',): |
| 111 | 118 |
| 112 stf = os.path.join(src.path, 'svn', tf) | 119 stf = os.path.join(src.path, 'svn', tf) |
| 113 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf) | 120 # the generation of tagmap is lazy so it doesn't strictly need to exist |
| 121 # if it's not being used | |
| 122 if not stf.endswith('tagmap'): | |
| 123 self.assertTrue(os.path.isfile(stf), '%r is missing!' % stf) | |
| 114 dtf = os.path.join(dest.path, 'svn', tf) | 124 dtf = os.path.join(dest.path, 'svn', tf) |
| 115 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf) | 125 old, new = None, None |
| 116 old, new = open(stf).read(), open(dtf).read() | 126 if not dtf.endswith('tagmap'): |
| 127 self.assertTrue(os.path.isfile(dtf), '%r is missing!' % tf) | |
| 128 if os.path.isfile(stf) and os.path.isfile(dtf): | |
| 129 old, new = util.load(stf, resave=False), util.load(dtf, resave=False) | |
| 117 if tf == 'lastpulled' and (name, | 130 if tf == 'lastpulled' and (name, |
| 118 self.stupid, single) in expect_youngest_skew: | 131 self.stupid, single) in expect_youngest_skew: |
| 119 self.assertNotEqual(old, new, | 132 self.assertNotEqual(old, new, |
| 120 'rebuildmeta unexpected match on youngest rev!') | 133 'rebuildmeta unexpected match on youngest rev!') |
| 121 continue | 134 continue |
| 122 self.assertMultiLineEqual(old, new, tf + ' differs') | 135 self.assertEqual(old, new, tf + ' differs') |
| 123 try: | 136 try: |
| 124 self.assertEqual(src.branchmap(), dest.branchmap()) | 137 self.assertEqual(src.branchmap(), dest.branchmap()) |
| 125 except AttributeError: | 138 except AttributeError: |
| 126 # hg 2.8 and earlier | 139 # hg 2.8 and earlier |
| 127 self.assertEqual(src.branchtags(), dest.branchtags()) | 140 self.assertEqual(src.branchtags(), dest.branchtags()) |
| 128 srcbi = pickle.load(open(os.path.join(src.path, 'svn', 'branch_info'))) | 141 srcbi = util.load(os.path.join(src.path, 'svn', 'branch_info')) |
| 129 destbi = pickle.load(open(os.path.join(dest.path, 'svn', 'branch_info'))) | 142 destbi = util.load(os.path.join(dest.path, 'svn', 'branch_info')) |
| 130 self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys())) | 143 self.assertEqual(sorted(srcbi.keys()), sorted(destbi.keys())) |
| 131 revkeys = svnmeta.SVNMeta(dest).revmap.keys() | 144 revkeys = svnmeta.SVNMeta(dest).revmap.keys() |
| 132 for branch in destbi: | 145 for branch in destbi: |
| 133 srcinfo = srcbi[branch] | 146 srcinfo = srcbi[branch] |
| 134 destinfo = destbi[branch] | 147 destinfo = destbi[branch] |
