Mercurial > hgsubversion
annotate tests/test_single_dir_clone.py @ 1236:f367a4462191
push: update to branch tip instead of tip
We previously updated to the repository tip after pushing a revision,
presumably on the assumption that tip would be the last revision we
just pushed. This assumption is flawed for high traffic repositories.
In particular, you previsouly would sometimes end up on a completley
unrelated commit if someone else commits to a different branch in
between the time we push a revision and pull it back from the server.
This changes to instead update to the branch tip of the branch we were
on at the beginning of the push. This should be either the revision
we just pushed or a linear descendent of the revision we just pushed,
with a fair degree of reliability.
author | David Schleimer <dschleimer@fb.com> |
---|---|
date | Sat, 30 Aug 2014 09:23:31 -0700 |
parents | 6e1dbf6cbc92 |
children | a36e87ae2380 |
rev | line source |
---|---|
643
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
1 import test_util |
d2ef7220a079
tests: import test_util as the first module in all relevant tests
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
577
diff
changeset
|
2 |
531
cf4fe45bf8fd
Change all instantiations of IOError to set both errno and strerror.
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
502
diff
changeset
|
3 import errno |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
4 import shutil |
577
930bb6df19a0
tests: make sure single dir clone tests get run by non-nose users
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
531
diff
changeset
|
5 import unittest |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
6 |
500
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
7 from mercurial import commands |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
8 from mercurial import context |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
9 from mercurial import hg |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
10 from mercurial import node |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
11 from mercurial import ui |
5ddc212dbc56
push: fix for single directory repository layouts
Daniel Tang <dytang@cs.purdue.edu>
parents:
499
diff
changeset
|
12 |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
13 from hgsubversion import compathacks |
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
14 |
1047
3092b3c109a8
tests: split single directory tests that push & clone in two modules
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1044
diff
changeset
|
15 class TestSingleDirClone(test_util.TestBase): |
1074
2668785264d7
test_single_dir_clone: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1047
diff
changeset
|
16 stupid_mode_tests = True |
2668785264d7
test_single_dir_clone: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1047
diff
changeset
|
17 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
18 def test_clone_single_dir_simple(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
19 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
20 layout='single', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
21 subdir='') |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
22 self.assertEqual(compathacks.branchset(repo), |
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
23 set(['default'])) |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
24 self.assertEqual(repo['tip'].manifest().keys(), |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
25 ['trunk/beta', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
26 'tags/copied_tag/alpha', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
27 'trunk/alpha', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
28 'tags/copied_tag/beta', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
29 'branches/branch_from_tag/alpha', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
30 'tags/tag_r3/alpha', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
31 'tags/tag_r3/beta', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
32 'branches/branch_from_tag/beta']) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
33 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
34 def test_auto_detect_single(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
35 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
36 layout='auto') |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
37 self.assertEqual(compathacks.branchset(repo), |
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
38 set(['default', 'branch_from_tag'])) |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
39 oldmanifest = test_util.filtermanifest(repo['default'].manifest().keys()) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
40 # remove standard layout |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
41 shutil.rmtree(self.wc_path) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
42 # try again with subdir to get single dir clone |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
43 repo = self._load_fixture_and_fetch('branch_from_tag.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
44 layout='auto', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
45 subdir='trunk') |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
46 self.assertEqual(compathacks.branchset(repo), set(['default', ])) |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
47 self.assertEqual(repo['default'].manifest().keys(), oldmanifest) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
48 |
1074
2668785264d7
test_single_dir_clone: use stupid mode metaclass
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents:
1047
diff
changeset
|
49 def test_clone_subdir_is_file_prefix(self): |
888
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
871
diff
changeset
|
50 FIXTURE = 'subdir_is_file_prefix.svndump' |
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
871
diff
changeset
|
51 repo = self._load_fixture_and_fetch(FIXTURE, |
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
871
diff
changeset
|
52 layout='single', |
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
871
diff
changeset
|
53 subdir=test_util.subdir[FIXTURE]) |
1103
6e1dbf6cbc92
compathacks: new module to collect hacks to work around hg internals changing
Augie Fackler <raf@durin42.com>
parents:
1074
diff
changeset
|
54 self.assertEqual(compathacks.branchset(repo), set(['default'])) |
888
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
871
diff
changeset
|
55 self.assertEqual(repo['tip'].manifest().keys(), ['flaf.txt']) |
c6388ed0ec0a
svnmeta: only remove directory components in normalize()
Dan Villiom Podlaski Christiansen <dan@cabo.dk>
parents:
871
diff
changeset
|
56 |
499
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
57 def test_externals_single(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
58 repo = self._load_fixture_and_fetch('externals.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
59 layout='single') |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
60 for rev in repo: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
61 assert '.hgsvnexternals' not in repo[rev].manifest() |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
62 return # TODO enable test when externals in single are fixed |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
63 expect = """[.] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
64 -r2 ^/externals/project2@2 deps/project2 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
65 [subdir] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
66 ^/externals/project1 deps/project1 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
67 [subdir2] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
68 ^/externals/project1 deps/project1 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
69 """ |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
70 test = 2 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
71 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
72 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
73 def test_externals_single_whole_repo(self): |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
74 # This is the test which demonstrates the brokenness of externals |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
75 return # TODO enable test when externals in single are fixed |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
76 repo = self._load_fixture_and_fetch('externals.svndump', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
77 layout='single', |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
78 subdir='') |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
79 for rev in repo: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
80 rc = repo[rev] |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
81 if '.hgsvnexternals' in rc: |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
82 extdata = rc['.hgsvnexternals'].data() |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
83 assert '[.]' not in extdata |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
84 print extdata |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
85 expect = '' # Not honestly sure what this should be... |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
86 test = 4 |
1fd3cfa47c5e
Support for single-directory clones.
Augie Fackler <durin42@gmail.com>
parents:
diff
changeset
|
87 self.assertEqual(self.repo[test]['.hgsvnexternals'].data(), expect) |