annotate tests/test_pull.py @ 1157:c2b72618645a

svnmeta: turn revmap into lazy property This has no effect currently but will be used in a future patch to make it possible to create a SVNMeta object without having to load the revmap (for use in rebuilding metadata).
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 17 Feb 2014 16:29:54 -0600
parents cd35f6739669
children 61d4fb78370b
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')
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
23 state = self.repo.parents()
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)
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
25 self.assertEqual(state, self.repo.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')
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
29 state = repo.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)
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
32 self.assertEqual(state, repo.parents())
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
33 self.assertTrue('tip' not in repo[None].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')
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
37 state = repo.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)
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
40 self.failIfEqual(state, repo.parents())
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
41 self.assertTrue('tip' in repo[None].tags())
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'),))
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
46 state = repo.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
283
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
53 self.assertEqual(state, repo.parents())
521d9c1bb11d Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff changeset
54 self.assertTrue('tip' not in repo[None].tags())
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
908
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
74 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
75 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
76 rev=2)
c4ee11a5d04c pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents: 868
diff changeset
77 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
78 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
79 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
80 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
81 self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 0)