Mercurial > hgsubversion
annotate tests/test_pull.py @ 1587:4889843a704e
merge old hg fix
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 29 Oct 2018 17:08:38 -0400 |
parents | cff81f35b31e |
children |
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 |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1417
diff
changeset
|
5 from mercurial import error as hgerror |
821
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
812
diff
changeset
|
6 from mercurial import node |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
7 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
|
8 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
|
9 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
|
10 from hgsubversion import verify |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
11 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
12 class TestPull(test_util.TestBase): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
13 def setUp(self): |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
14 super(TestPull, self).setUp() |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
15 |
908
c4ee11a5d04c
pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents:
868
diff
changeset
|
16 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
|
17 kwargs = kwargs.copy() |
1068
cd35f6739669
test_pull: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
18 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
|
19 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
|
20 return repo, repo_path |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
21 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
22 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
|
23 self._loadupdate('single_rev.svndump') |
1417
4f1461428334
test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents:
1339
diff
changeset
|
24 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
|
25 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
|
26 self.assertEqual(state, self.repo[None].parents()) |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
27 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
28 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
|
29 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
|
30 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
|
31 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
|
32 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
|
33 self.assertEqual(state, repo[None].parents()) |
1339
74e82a7da393
tests: check '.' for tags instead of None
Durham Goode <durham@fb.com>
parents:
1170
diff
changeset
|
34 self.assertTrue('tip' not in repo['.'].tags()) |
808
b64173a27ce8
test_pull: clean up whitespace
Augie Fackler <durin42@gmail.com>
parents:
689
diff
changeset
|
35 |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 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
|
41 self.failIfEqual(state, repo[None].parents()) |
1339
74e82a7da393
tests: check '.' for tags instead of None
Durham Goode <durham@fb.com>
parents:
1170
diff
changeset
|
42 self.assertTrue('tip' in repo['.'].tags()) |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
43 |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
44 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
|
45 repo, repo_path = self._loadupdate('single_rev.svndump') |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
46 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
|
47 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
|
48 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
|
49 try: |
8c7447b4b004
test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents:
808
diff
changeset
|
50 commands.pull(self.repo.ui, repo, update=True) |
1555
cff81f35b31e
cleanup: reference Abort from mercurial.error instead of mercurial.util
Augie Fackler <raf@durin42.com>
parents:
1417
diff
changeset
|
51 except hgerror.Abort: |
812
8c7447b4b004
test_pull: commands.pull() no longer aborts when crossing branches
Patrick Mezard <pmezard@gmail.com>
parents:
808
diff
changeset
|
52 # 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
|
53 pass |
1417
4f1461428334
test_hooks: cope with localrepo.parents() going away
Augie Fackler <raf@durin42.com>
parents:
1339
diff
changeset
|
54 self.assertEqual(state, repo[None].parents()) |
1339
74e82a7da393
tests: check '.' for tags instead of None
Durham Goode <durham@fb.com>
parents:
1170
diff
changeset
|
55 self.assertTrue('tip' not in repo['.'].tags()) |
283
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
56 self.assertEqual(len(repo.heads()), 2) |
521d9c1bb11d
Implement -u/--update support when pulling.
Martijn Pieters <mj@zopatista.com>
parents:
diff
changeset
|
57 |
821
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
812
diff
changeset
|
58 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
|
59 repo = self._loadupdate('branchtagcollision.svndump')[0] |
821
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
812
diff
changeset
|
60 oldheads = map(node.hex, repo.heads()) |
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
812
diff
changeset
|
61 commands.pull(repo.ui, repo) |
f28e0f54a6ef
svnmeta: store youngest revision pulled from subversion
Augie Fackler <durin42@gmail.com>
parents:
812
diff
changeset
|
62 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
|
63 |
1170
61d4fb78370b
pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents:
1068
diff
changeset
|
64 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
|
65 repo = self._loadupdate('branchtagcollision.svndump', |
61d4fb78370b
pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents:
1068
diff
changeset
|
66 config={'phases.new-commit': 'secret'})[0] |
61d4fb78370b
pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents:
1068
diff
changeset
|
67 oldheads = map(node.hex, repo.heads()) |
61d4fb78370b
pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents:
1068
diff
changeset
|
68 commands.pull(repo.ui, repo) |
61d4fb78370b
pull: fix pull when phases.new-commit=secret
Augie Fackler <raf@durin42.com>
parents:
1068
diff
changeset
|
69 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
|
70 |
908
c4ee11a5d04c
pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents:
868
diff
changeset
|
71 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
|
72 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
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 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
|
81 |
c4ee11a5d04c
pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents:
868
diff
changeset
|
82 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
|
83 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
|
84 rev=2) |
c4ee11a5d04c
pull: add a hgsubversion.unsafeskip option to omit unwanted revs
Bryan O'Sullivan <bryano@fb.com>
parents:
868
diff
changeset
|
85 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
|
86 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
|
87 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
|
88 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
|
89 self.assertEquals(verify.verify(repo.ui, repo, rev=tip), 0) |