Show More
@@ -1,133 +1,132 b'' | |||
|
1 | 1 | # reproduce issue2264, issue2516 |
|
2 | 2 | |
|
3 | 3 | create test repo |
|
4 | 4 | $ cat <<EOF >> $HGRCPATH |
|
5 | 5 | > [extensions] |
|
6 | 6 | > transplant = |
|
7 | 7 | > EOF |
|
8 | 8 | $ hg init repo |
|
9 | 9 | $ cd repo |
|
10 | 10 | $ template="{rev} {desc|firstline} [{branch}]\n" |
|
11 | 11 | |
|
12 | 12 | # we need to start out with two changesets on the default branch |
|
13 | 13 | # in order to avoid the cute little optimization where transplant |
|
14 | 14 | # pulls rather than transplants |
|
15 | 15 | add initial changesets |
|
16 | 16 | $ echo feature1 > file1 |
|
17 | 17 | $ hg ci -Am"feature 1" |
|
18 | 18 | adding file1 |
|
19 | 19 | $ echo feature2 >> file2 |
|
20 | 20 | $ hg ci -Am"feature 2" |
|
21 | 21 | adding file2 |
|
22 | 22 | |
|
23 | 23 | # The changes to 'bugfix' are enough to show the bug: in fact, with only |
|
24 | 24 | # those changes, it's a very noisy crash ("RuntimeError: nothing |
|
25 | 25 | # committed after transplant"). But if we modify a second file in the |
|
26 | 26 | # transplanted changesets, the bug is much more subtle: transplant |
|
27 | 27 | # silently drops the second change to 'bugfix' on the floor, and we only |
|
28 | 28 | # see it when we run 'hg status' after transplanting. Subtle data loss |
|
29 | 29 | # bugs are worse than crashes, so reproduce the subtle case here. |
|
30 | 30 | commit bug fixes on bug fix branch |
|
31 | 31 | $ hg branch fixes |
|
32 | 32 | marked working directory as branch fixes |
|
33 | 33 | (branches are permanent and global, did you want a bookmark?) |
|
34 | 34 | $ echo fix1 > bugfix |
|
35 | 35 | $ echo fix1 >> file1 |
|
36 | 36 | $ hg ci -Am"fix 1" |
|
37 | 37 | adding bugfix |
|
38 | 38 | $ echo fix2 > bugfix |
|
39 | 39 | $ echo fix2 >> file1 |
|
40 | 40 | $ hg ci -Am"fix 2" |
|
41 | 41 | $ hg log -G --template="$template" |
|
42 | 42 | @ 3 fix 2 [fixes] |
|
43 | 43 | | |
|
44 | 44 | o 2 fix 1 [fixes] |
|
45 | 45 | | |
|
46 | 46 | o 1 feature 2 [default] |
|
47 | 47 | | |
|
48 | 48 | o 0 feature 1 [default] |
|
49 | 49 | |
|
50 | 50 | transplant bug fixes onto release branch |
|
51 | 51 | $ hg update 0 |
|
52 | 52 | 1 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
53 | 53 | $ hg branch release |
|
54 | 54 | marked working directory as branch release |
|
55 | 55 | $ hg transplant 2 3 |
|
56 | 56 | applying [0-9a-f]{12} (re) |
|
57 | 57 | [0-9a-f]{12} transplanted to [0-9a-f]{12} (re) |
|
58 | 58 | applying [0-9a-f]{12} (re) |
|
59 | 59 | [0-9a-f]{12} transplanted to [0-9a-f]{12} (re) |
|
60 | 60 | $ hg log -G --template="$template" |
|
61 | 61 | @ 5 fix 2 [release] |
|
62 | 62 | | |
|
63 | 63 | o 4 fix 1 [release] |
|
64 | 64 | | |
|
65 | 65 | | o 3 fix 2 [fixes] |
|
66 | 66 | | | |
|
67 | 67 | | o 2 fix 1 [fixes] |
|
68 | 68 | | | |
|
69 | 69 | | o 1 feature 2 [default] |
|
70 | 70 | |/ |
|
71 | 71 | o 0 feature 1 [default] |
|
72 | 72 | |
|
73 | 73 | $ hg status |
|
74 | 74 | $ hg status --rev 0:4 |
|
75 | 75 | M file1 |
|
76 | 76 | A bugfix |
|
77 | 77 | $ hg status --rev 4:5 |
|
78 | 78 | M bugfix |
|
79 | 79 | M file1 |
|
80 | 80 | |
|
81 | 81 | now test that we fixed the bug for all scripts/extensions |
|
82 | 82 | $ cat > $TESTTMP/committwice.py <<__EOF__ |
|
83 | 83 | > import time |
|
84 | 84 | > from mercurial import hg, match, node, ui as uimod |
|
85 | 85 | > |
|
86 | 86 | > def replacebyte(fn, b): |
|
87 | 87 | > f = open(fn, "rb+") |
|
88 | 88 | > f.seek(0, 0) |
|
89 | 89 | > f.write(b) |
|
90 | 90 | > f.close() |
|
91 | 91 | > |
|
92 | 92 | > def printfiles(repo, rev): |
|
93 | 93 | > repo.ui.status(b"revision %d files: [%s]\n" |
|
94 | 94 | > % (rev, b', '.join(b"'%s'" % f |
|
95 | 95 | > for f in repo[rev].files()))) |
|
96 | 96 | > |
|
97 | 97 | > repo = hg.repository(uimod.ui.load(), b'.') |
|
98 | > assert len(repo) == 6, \ | |
|
99 | > "initial: len(repo): %d, expected: 6" % len(repo) | |
|
98 | > assert len(repo) == 6, "initial: len(repo): %d, expected: 6" % len(repo) | |
|
100 | 99 | > |
|
101 | 100 | > replacebyte(b"bugfix", b"u") |
|
102 | 101 | > time.sleep(2) |
|
103 | 102 | > try: |
|
104 | 103 | > repo.ui.status(b"PRE: len(repo): %d\n" % len(repo)) |
|
105 | 104 | > wlock = repo.wlock() |
|
106 | 105 | > lock = repo.lock() |
|
107 | 106 | > replacebyte(b"file1", b"x") |
|
108 | 107 | > repo.commit(text=b"x", user=b"test", date=(0, 0)) |
|
109 | 108 | > replacebyte(b"file1", b"y") |
|
110 | 109 | > repo.commit(text=b"y", user=b"test", date=(0, 0)) |
|
111 | 110 | > repo.ui.status(b"POST: len(repo): %d\n" % len(repo)) |
|
112 | 111 | > finally: |
|
113 | 112 | > lock.release() |
|
114 | 113 | > wlock.release() |
|
115 | 114 | > printfiles(repo, 6) |
|
116 | 115 | > printfiles(repo, 7) |
|
117 | 116 | > __EOF__ |
|
118 | 117 | $ "$PYTHON" $TESTTMP/committwice.py |
|
119 | 118 | PRE: len(repo): 6 |
|
120 | 119 | POST: len(repo): 8 |
|
121 | 120 | revision 6 files: ['bugfix', 'file1'] |
|
122 | 121 | revision 7 files: ['file1'] |
|
123 | 122 | |
|
124 | 123 | Do a size-preserving modification outside of that process |
|
125 | 124 | $ echo abcd > bugfix |
|
126 | 125 | $ hg status |
|
127 | 126 | M bugfix |
|
128 | 127 | $ hg log --template "{rev} {desc} {files}\n" -r5: |
|
129 | 128 | 5 fix 2 bugfix file1 |
|
130 | 129 | 6 x bugfix file1 |
|
131 | 130 | 7 y file1 |
|
132 | 131 | |
|
133 | 132 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now