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