test-touch.t 5.57 KB
Newer Older
Pierre-Yves David's avatar
Pierre-Yves David committed
1
2
3
4

  $ cat >> $HGRCPATH <<EOF
  > [ui]
  > logtemplate={rev}:{node|short} {desc}\n
5
6
  > [alias]
  > glog = log -GT "{rev}: {desc}"
Pierre-Yves David's avatar
Pierre-Yves David committed
7
  > [extensions]
8
  > rebase =
Pierre-Yves David's avatar
Pierre-Yves David committed
9
  > EOF
10
  $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
Pierre-Yves David's avatar
Pierre-Yves David committed
11
12
13
14
15
16
17
18
19
20

  $ hg init repo
  $ cd repo
  $ echo A > a
  $ hg add a
  $ hg commit -m a

Basic usage

  $ hg log -G
21
  @  0:[0-9a-f]{12} a (re)
Pierre-Yves David's avatar
Pierre-Yves David committed
22
23
24
25
26
27
28
29
30
31
32
33
34
  
  $ hg touch .
  $ hg log -G
  @  1:[0-9a-f]{12} a (re)
  


Revive usage

  $ echo A > b
  $ hg add b
  $ hg commit -m ab --amend
  $ hg up --hidden 1
Boris Feld's avatar
Boris Feld committed
35
36
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  updated to hidden changeset * (glob)
37
  (hidden revision '*' was rewritten as: *) (glob)
38
39
  working directory parent is obsolete! (*) (glob)
  (use 'hg evolve' to update to its successor: *) (glob)
Pierre-Yves David's avatar
Pierre-Yves David committed
40
  $ hg log -G
41
  o  2:[0-9a-f]{12} ab (re)
Pierre-Yves David's avatar
Pierre-Yves David committed
42
43
44
45
  
  @  1:[0-9a-f]{12} a (re)
  
  $ hg touch .
46
47
48
  [1] a
  reviving this changeset will create divergence unless you make a duplicate.
  (a)llow divergence or (d)uplicate the changeset?  a
49
  2 new content-divergent changesets
Pierre-Yves David's avatar
Pierre-Yves David committed
50
  $ hg log -G
51
  @  3:[0-9a-f]{12} a (re)
Pierre-Yves David's avatar
Pierre-Yves David committed
52
  
53
  \*  2:[0-9a-f]{12} ab (re)
Pierre-Yves David's avatar
Pierre-Yves David committed
54
  
55
  $ hg prune 3
56
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
57
  working directory is now at 000000000000
Pierre-Yves David's avatar
Pierre-Yves David committed
58
  1 changesets pruned
59
60
61
62
63

Duplicate

  $ hg touch --duplicate .
  $ hg log -G
64
  @  4:[0-9a-f]{12} (re)
65
  
66
  o  2:[0-9a-f]{12} ab (re)
67
  
68
69
70
71
72
73
74
75
76
77

Multiple touch

  $ echo C > c
  $ hg add c
  $ hg commit -m c
  $ echo D > d
  $ hg add d
  $ hg commit -m d
  $ hg log -G
78
  @  6:[0-9a-f]{12} d (re)
79
  |
80
  o  5:[0-9a-f]{12} c (re)
81
  |
82
  o  4:[0-9a-f]{12} (re)
83
  
84
  o  2:[0-9a-f]{12} ab (re)
85
  
86
  $ hg touch .^:.
87
  $ hg log -G
88
  @  8:[0-9a-f]{12} d (re)
89
  |
90
  o  7:[0-9a-f]{12} c (re)
91
  |
92
  o  4:[0-9a-f]{12} (re)
93
  
94
  o  2:[0-9a-f]{12} ab (re)
95
96
  

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
check move data kept after rebase on touch:

  $ touch gna1
  $ hg commit -Am gna1
  adding gna1
  $ hg mv gna1 gna2
  $ hg commit -m move
  $ hg st -C --change=tip
  A gna2
    gna1
  R gna1
  $ hg up .^
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved

  $ hg touch
112
  1 new orphan changesets
113

114
  $ hg log -G --hidden
115
  @  11:[0-9a-f]{12} gna1 (re)
116
  |
117
  . \*  10:[0-9a-f]{12} move (re)
118
  | |
119
  . x  9:[0-9a-f]{12} gna1 (re)
120
  |/
121
  o  8:[0-9a-f]{12} d (re)
122
  |
123
  o  7:[0-9a-f]{12} c (re)
124
  |
125
  . x  6:[0-9a-f]{12} d (re)
126
  | |
127
  . x  5:[0-9a-f]{12} c (re)
128
  |/
129
  o  4:[0-9a-f]{12} (re)
130
  
131
  x  3:[0-9a-f]{12} a (re)
132
  
133
  o  2:[0-9a-f]{12} ab (re)
134
135
136
137
138
139
  
  x  1:[0-9a-f]{12} a (re)
  
  x  0:[0-9a-f]{12} a (re)
  

140
141
  $ hg rebase -s 10 -d 11
  rebasing 10:[0-9a-f]{12} "move" (re)
142
143
144
145
  $ hg st -C --change=tip
  A gna2
    gna1
  R gna1
146
147
148

check that the --duplicate option does not create divergence

149
150
  $ hg touch --duplicate 10 --hidden
  1 new orphan changesets
151
152
153

check that reviving a changeset with no successor does not show the prompt

154
  $ hg prune 13
155
  1 changesets pruned
156
  $ hg touch 13 --hidden --note "testing with no successor"
157
  1 new orphan changesets
158
159
160
161
162
163
164
165
166
167
168
  $ hg debugobsolete
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'touch', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'touch', 'user': 'test'} (glob)
  * 0 {0000000000000000000000000000000000000000} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'touch', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'touch', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'touch', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'rebase', 'user': 'test'} (glob)
  * 0 {*} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'test'} (glob)
  * * 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'note': 'testing with no successor', 'operation': 'touch', 'user': 'test'} (glob)
169
  $ hg obslog -r 13 --no-origin --hidden
170
  x  [0-9a-f]{12} (.*) move (re)
171
       pruned using prune by test (Thu Jan 01 00:00:00 1970 +0000)
172
       rewritten(.*) as [0-9a-f]{12} using touch by test (.*) (re)
173
         note: testing with no successor
174
  
175
176
177
178
179
180
181

Public phase

  $ hg phase --public -r 2
  $ hg touch 2
  abort: cannot touch public changesets: * (glob)
  (see 'hg help phases' for details)
182
  [10]
183
  $ hg touch --duplicate 2
184

185
186
187
188
189
190
191
192
Reviving merge commit

  $ hg up 12
  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg merge 15
  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m merge
193
194
195
  $ hg st --change .
  A a
  A b
196
197
198
199
200
  $ hg prune -r .
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  working directory is now at * (glob)
  1 changesets pruned
  $ hg touch 16 --hidden
201
202
203
204
205
206
207
208
  $ hg glog -r '12+15+17'
  o    17: merge
  |\
  | o  15: ab
  |
  @  12: move
  |
  ~
209
210
211
  $ hg st --change 17
  A a
  A b
212

213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
  $ cd ..

Make sure touch doesn't fail to warn about divergence (issue6107)

  $ hg init touchdiv
  $ cd touchdiv
  $ echo c > c
  $ hg add c
  $ hg ci -m "added c"

  $ hg amend -m "modified c"
  $ hg prune . -q

  $ hg touch -r "desc('added c')" --hidden
  $ hg touch -r "desc('modified c')" --hidden
228
229
230
  [1] modified c
  reviving this changeset will create divergence unless you make a duplicate.
  (a)llow divergence or (d)uplicate the changeset?  a
231
232
  2 new content-divergent changesets

233
234
235
236
237
But -A allows divergence

  $ hg touch -r "desc('modified c')" --hidden -A
  1 new content-divergent changesets

238
  $ cd ..