##// 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 1 # reproduce issue2264, issue2516
2 2
3 3 create test repo
4 4 $ cat <<EOF >> $HGRCPATH
5 5 > [extensions]
6 6 > transplant =
7 7 > graphlog =
8 8 > EOF
9 9 $ hg init repo
10 10 $ cd repo
11 11 $ template="{rev} {desc|firstline} [{branch}]\n"
12 12
13 13 # we need to start out with two changesets on the default branch
14 14 # in order to avoid the cute little optimization where transplant
15 15 # pulls rather than transplants
16 16 add initial changesets
17 17 $ echo feature1 > file1
18 18 $ hg ci -Am"feature 1"
19 19 adding file1
20 20 $ echo feature2 >> file2
21 21 $ hg ci -Am"feature 2"
22 22 adding file2
23 23
24 24 # The changes to 'bugfix' are enough to show the bug: in fact, with only
25 25 # those changes, it's a very noisy crash ("RuntimeError: nothing
26 26 # committed after transplant"). But if we modify a second file in the
27 27 # transplanted changesets, the bug is much more subtle: transplant
28 28 # silently drops the second change to 'bugfix' on the floor, and we only
29 29 # see it when we run 'hg status' after transplanting. Subtle data loss
30 30 # bugs are worse than crashes, so reproduce the subtle case here.
31 31 commit bug fixes on bug fix branch
32 32 $ hg branch fixes
33 33 marked working directory as branch fixes
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 glog --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 glog --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 > from mercurial import ui, hg, match, node
84 > from time import sleep
84 85 >
85 86 > def replacebyte(fn, b):
86 > f = open("file1", "rb+")
87 > f = open(fn, "rb+")
87 88 > f.seek(0, 0)
88 89 > f.write(b)
89 90 > f.close()
90 91 >
92 > def printfiles(repo, rev):
93 > print "revision %s files: %s" % (rev, repo[rev].files())
94 >
91 95 > repo = hg.repository(ui.ui(), '.')
92 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 101 > try:
102 > print "PRE: len(repo): %d" % len(repo)
95 103 > wlock = repo.wlock()
96 104 > lock = repo.lock()
97 > m = match.exact(repo.root, '', ['file1'])
98 105 > replacebyte("file1", "x")
99 > n = repo.commit(text="x", user="test", date=(0, 0), match=m)
100 > print "commit 1: len(repo) == %d" % len(repo)
106 > repo.commit(text="x", user="test", date=(0, 0))
101 107 > replacebyte("file1", "y")
102 > n = repo.commit(text="y", user="test", date=(0, 0), match=m)
103 > print "commit 2: len(repo) == %d" % len(repo)
108 > repo.commit(text="y", user="test", date=(0, 0))
109 > print "POST: len(repo): %d" % len(repo)
104 110 > finally:
105 111 > lock.release()
106 112 > wlock.release()
113 > printfiles(repo, 6)
114 > printfiles(repo, 7)
107 115 > __EOF__
108 116 $ $PYTHON $TESTTMP/committwice.py
109 commit 1: len(repo) == 7
110 commit 2: len(repo) == 8
117 PRE: len(repo): 6
118 POST: len(repo): 8
119 revision 6 files: ['bugfix', 'file1']
120 revision 7 files: ['file1']
111 121
112 122 Do a size-preserving modification outside of that process
113 123 $ echo abcd > bugfix
114 124 $ hg status
115 125 M bugfix
116 126 $ hg log --template "{rev} {desc} {files}\n" -r5:
117 127 5 fix 2 bugfix file1
118 6 x file1
128 6 x bugfix file1
119 129 7 y file1
General Comments 0
You need to be logged in to leave comments. Login now