annotate tests/test_pull.py @ 1551:22137e94411f

wrappers: cope with removal of text= kwarg on vfs Fixes #472.
author Augie Fackler <raf@durin42.com>
date Sat, 24 Mar 2018 15:16:11 -0400
parents 4f1461428334
children cff81f35b31e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
1 import test_util
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
2
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
3 import os.path
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
4 import subprocess
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 812
diff changeset
5 from mercurial import node
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
6 from mercurial import ui
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 283
diff changeset
7 from mercurial import util as hgutil
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 283
diff changeset
8 from mercurial import commands
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
9 from hgsubversion import verify
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
10
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
11 class TestPull(test_util.TestBase):
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
12 def setUp(self):
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
13 super(TestPull, self).setUp()
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
14
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
15 def _loadupdate(self, fixture_name, *args, **kwargs):
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
16 kwargs = kwargs.copy()
1068
cd35f6739669 test_pull: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 1044
diff changeset
17 kwargs.update(noupdate=False)
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
18 repo, repo_path = self.load_and_fetch(fixture_name, *args, **kwargs)
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
19 return repo, repo_path
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
20
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
21 def test_nochanges(self):
865
04729f3a3d17 test_util: merge load_fixture_and_fetch() into TestBase method
Patrick Mezard <patrick@mezard.eu>
parents: 821
diff changeset
22 self._loadupdate('single_rev.svndump')
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
23 state = self.repo[None].parents()
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 283
diff changeset
24 commands.pull(self.repo.ui, self.repo)
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
25 self.assertEqual(state, self.repo[None].parents())
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
26
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
27 def test_onerevision_noupdate(self):
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
28 repo, repo_path = self._loadupdate('single_rev.svndump')
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
29 state = repo[None].parents()
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
30 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 283
diff changeset
31 commands.pull(self.repo.ui, repo)
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
32 self.assertEqual(state, repo[None].parents())
1339
74e82a7da393 tests: check '.' for tags instead of None
Durham Goode <durham@fb.com>
parents: 1170
diff changeset
33 self.assertTrue('tip' not in repo['.'].tags())
808
b64173a27ce8 test_pull: clean up whitespace
Augie Fackler <durin42@gmail.com>
parents: 689
diff changeset
34
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
35 def test_onerevision_doupdate(self):
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
36 repo, repo_path = self._loadupdate('single_rev.svndump')
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
37 state = repo[None].parents()
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
38 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
331
75f082b5897e Switch to using url scheme wrappers instead of duplicating each command we wrap.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 283
diff changeset
39 commands.pull(self.repo.ui, repo, update=True)
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
40 self.failIfEqual(state, repo[None].parents())
1339
74e82a7da393 tests: check '.' for tags instead of None
Durham Goode <durham@fb.com>
parents: 1170
diff changeset
41 self.assertTrue('tip' in repo['.'].tags())
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
42
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
43 def test_onerevision_divergent(self):
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
44 repo, repo_path = self._loadupdate('single_rev.svndump')
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
45 self.commitchanges((('alpha', 'alpha', 'Changed another way'),))
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
46 state = repo[None].parents()
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
47 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed one way'})
812
8c7447b4b004 test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents: 808
diff changeset
48 try:
8c7447b4b004 test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents: 808
diff changeset
49 commands.pull(self.repo.ui, repo, update=True)
8c7447b4b004 test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents: 808
diff changeset
50 except hgutil.Abort:
8c7447b4b004 test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents: 808
diff changeset
51 # hg < 1.9 raised when crossing branches
8c7447b4b004 test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents: 808
diff changeset
52 pass
1417
4f1461428334 test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents: 1339
diff changeset
53 self.assertEqual(state, repo[None].parents())
1339
74e82a7da393 tests: check '.' for tags instead of None
Durham Goode <durham@fb.com>
parents: 1170
diff changeset
54 self.assertTrue('tip' not in repo['.'].tags())
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
55 self.assertEqual(len(repo.heads()), 2)
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
56
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 812
diff changeset
57 def test_tag_repull_doesnt_happen(self):
868
cc1c870f1758 test_util: pass repo_path to _add_svn_rev() explicitely
Patrick Mezard <patrick@mezard.eu>
parents: 865
diff changeset
58 repo = self._loadupdate('branchtagcollision.svndump')[0]
821
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 812
diff changeset
59 oldheads = map(node.hex, repo.heads())
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 812
diff changeset
60 commands.pull(repo.ui, repo)
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 812
diff changeset
61 self.assertEqual(oldheads, map(node.hex, repo.heads()))
f28e0f54a6ef svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents: 812
diff changeset
62
1170
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
63 def test_pull_with_secret_default(self):
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
64 repo = self._loadupdate('branchtagcollision.svndump',
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
65 config={'phases.new-commit': 'secret'})[0]
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
66 oldheads = map(node.hex, repo.heads())
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
67 commands.pull(repo.ui, repo)
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
68 self.assertEqual(oldheads, map(node.hex, repo.heads()))
61d4fb78370b pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents: 1068
diff changeset
69
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
70 def test_skip_basic(self):
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
71 repo, repo_path = self._loadupdate('single_rev.svndump')
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
72 self.add_svn_rev(repo_path, {'trunk/alpha': 'Changed'})
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
73 self.add_svn_rev(repo_path, {'trunk/beta': 'More changed'})
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
74 self.add_svn_rev(repo_path, {'trunk/gamma': 'Even more changeder'})
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
75 repo.ui.setconfig('hgsubversion', 'unsafeskip', '3 4')
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
76 commands.pull(repo.ui, repo)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
77 tip = repo['tip'].rev()
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
78 self.assertEqual(tip, 1)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
79 self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 1)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
80
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
81 def test_skip_delete_restore(self):
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
82 repo, repo_path = self._loadupdate('delete_restore_trunk.svndump',
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
83 rev=2)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
84 repo.ui.setconfig('hgsubversion', 'unsafeskip', '3 4')
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
85 commands.pull(repo.ui, repo)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
86 tip = repo['tip'].rev()
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
87 self.assertEqual(tip, 1)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
88 self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 0)