Mercurial > hg
annotate tests/test-merge-default.t @ 20742:3681de20b0a7
parsers: fail fast if Python has wrong minor version (issue4110)
This change causes an informative ImportError to be raised when importing
the parsers extension module if the minor version of the currently-running
Python interpreter doesn't match that of the Python used when compiling
the extension module.
This change also exposes a parsers.versionerrortext constant in the
C implementation of the module. Its presence can be used to determine
whether this behavior is present in a version of the module. The value
of the constant is the leading text of the ImportError raised and is set
to "Python minor version mismatch".
Here is an example of what the new error looks like:
Traceback (most recent call last):
File "test.py", line 1, in <module>
import mercurial.parsers
ImportError: Python minor version mismatch: The Mercurial extension
modules were compiled with Python 2.7.6, but Mercurial is currently using
Python with sys.hexversion=33883888: Python 2.5.6
(r256:88840, Nov 18 2012, 05:37:10)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))]
at: /opt/local/Library/Frameworks/Python.framework/Versions/2.5/Resources/
Python.app/Contents/MacOS/Python
The reason for raising an error in this scenario is that Python's C API
is known not to be compatible from minor version to minor version, even
if sys.api_version is the same. See for example this Python bug report
about incompatibilities between 2.5 and 2.6+:
http://bugs.python.org/issue8118
These incompatibilities can cause Mercurial to break in mysterious,
unforeseen ways. For example, when Mercurial compiled with Python 2.7 was
run with 2.5, the following crash occurred when running "hg status":
http://bz.selenic.com/show_bug.cgi?id=4110
After this crash was fixed, running with Python 2.5 no longer crashes, but
the following puzzling behavior still occurs:
$ hg status
...
File ".../mercurial/changelog.py", line 123, in __init__
revlog.revlog.__init__(self, opener, "00changelog.i")
File ".../mercurial/revlog.py", line 251, in __init__
d = self._io.parseindex(i, self._inline)
File ".../mercurial/revlog.py", line 158, in parseindex
index, cache = parsers.parse_index2(data, inline)
TypeError: data is not a string
which can be reproduced more simply with:
import mercurial.parsers as parsers
parsers.parse_index2("", True)
Both the crash and the TypeError occurred because the Python C API's
PyString_Check() returns the wrong value when the C header files from
Python 2.7 are run with Python 2.5. This is an example of an
incompatibility of the sort mentioned in the Python bug report above.
Failing fast with an informative error message results in a better user
experience in cases like the above. The information in the ImportError
also simplifies troubleshooting for those on Mercurial mailing lists, the
bug tracker, etc.
This patch only adds the version check to parsers.c, which is sufficient
to affect command-line commands like "hg status" and "hg summary".
An idea for a future improvement is to move the version-checking C code
to a more central location, and have it run when importing all
Mercurial extension modules and not just parsers.c.
author | Chris Jerdonek <chris.jerdonek@gmail.com> |
---|---|
date | Wed, 04 Dec 2013 20:38:27 -0800 |
parents | fc8c7a5ccc4a |
children | 94f77624dbb5 |
rev | line source |
---|---|
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
1 $ hg init |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
2 $ echo a > a |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
3 $ hg commit -A -ma |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
4 adding a |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
5 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
6 $ echo b >> a |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
7 $ hg commit -mb |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
8 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
9 $ echo c >> a |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
10 $ hg commit -mc |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
11 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
12 $ hg up 1 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
13 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
14 $ echo d >> a |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
15 $ hg commit -md |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
16 created new head |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
17 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
18 $ hg up 1 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
19 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
20 $ echo e >> a |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
21 $ hg commit -me |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
22 created new head |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
23 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
24 $ hg up 1 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
25 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
26 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
27 Should fail because not at a head: |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
28 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
29 $ hg merge |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
30 abort: branch 'default' has 3 heads - please merge with an explicit rev |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
31 (run 'hg heads .' to see heads) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12255
diff
changeset
|
32 [255] |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
33 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
34 $ hg up |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
35 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
36 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
37 Should fail because > 2 heads: |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
38 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
39 $ HGMERGE=internal:other; export HGMERGE |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
40 $ hg merge |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
41 abort: branch 'default' has 3 heads - please merge with an explicit rev |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
42 (run 'hg heads .' to see heads) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12255
diff
changeset
|
43 [255] |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
44 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
45 Should succeed: |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
46 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
47 $ hg merge 2 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
48 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
49 (branch merge, don't forget to commit) |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
50 $ hg commit -mm1 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
51 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
52 Should succeed - 2 heads: |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
53 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
54 $ hg merge -P |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
55 changeset: 3:ea9ff125ff88 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
56 parent: 1:1846eede8b68 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
57 user: test |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
58 date: Thu Jan 01 00:00:00 1970 +0000 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
59 summary: d |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
60 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
61 $ hg merge |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
62 0 files updated, 1 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
63 (branch merge, don't forget to commit) |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
64 $ hg commit -mm2 |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
65 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
66 Should fail because at tip: |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
67 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
68 $ hg merge |
15619
6c8573dd1b6b
merge: make 'nothing to merge' aborts consistent
Kevin Bullock <kbullock@ringworld.org>
parents:
12316
diff
changeset
|
69 abort: nothing to merge |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12255
diff
changeset
|
70 [255] |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
71 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
72 $ hg up 0 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
73 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
5242
9cd6578750b9
improve error message for 'hg merge' when repo already at branchtip
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
2915
diff
changeset
|
74 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
75 Should fail because there is only one head: |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
76 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
77 $ hg merge |
15619
6c8573dd1b6b
merge: make 'nothing to merge' aborts consistent
Kevin Bullock <kbullock@ringworld.org>
parents:
12316
diff
changeset
|
78 abort: nothing to merge |
6c8573dd1b6b
merge: make 'nothing to merge' aborts consistent
Kevin Bullock <kbullock@ringworld.org>
parents:
12316
diff
changeset
|
79 (use 'hg update' instead) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12255
diff
changeset
|
80 [255] |
2915
013921c753bd
merge with other head by default, not tip.
Vadim Gelfer <vadim.gelfer@gmail.com>
parents:
diff
changeset
|
81 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
82 $ hg up 3 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
84 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
85 $ echo f >> a |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
86 $ hg branch foobranch |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
87 marked working directory as branch foobranch |
15615 | 88 (branches are permanent and global, did you want a bookmark?) |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
89 $ hg commit -mf |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
90 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
91 Should fail because merge with other branch: |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
92 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
93 $ hg merge |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
94 abort: branch 'foobranch' has one head - please merge with an explicit rev |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
95 (run 'hg heads' to see all heads) |
12316
4134686b83e1
tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents:
12255
diff
changeset
|
96 [255] |
10355
a5576908b589
merge: add hints about the use of 'hg heads' to find the rev to merge
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8834
diff
changeset
|
97 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
98 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
99 Test for issue2043: ensure that 'merge -P' shows ancestors of 6 that |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
100 are not ancestors of 7, regardless of where their least common |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
101 ancestor is. |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
102 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
103 Merge preview not affected by common ancestor: |
10505
b3311e26f94f
merge: fix --preview to show all nodes that will be merged (issue2043).
Greg Ward <greg-hg@gerg.ca>
parents:
10504
diff
changeset
|
104 |
12255
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
105 $ hg up -q 7 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
106 $ hg merge -q -P 6 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
107 2:2d95304fed5d |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
108 4:f25cbe84d8b3 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
109 5:a431fabd6039 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
110 6:e88e33f3bf62 |
9b3c02c36d92
tests: unify test-merge-default
Adrian Buehlmann <adrian@cadifra.com>
parents:
10658
diff
changeset
|
111 |