File: test-bundle-phase-internal.t

package info (click to toggle)
mercurial 7.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 44,824 kB
  • sloc: python: 206,444; ansic: 56,415; tcl: 3,715; sh: 1,797; lisp: 1,483; cpp: 864; makefile: 752; javascript: 649; xml: 36
file content (288 lines) | stat: -rw-r--r-- 6,946 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
=====================================================
test behavior of the `internal` phase around bundling
=====================================================

Long story short, internal changeset are internal implementation details and
they should never leave the repository. Hence, they should never be in a
bundle.

Setup
=====

  $ cat << EOF >> $HGRCPATH
  > [ui]
  > logtemplate="{node|short} [{phase}] {desc|firstline}"
  > EOF


  $ hg init reference-repo --config format.use-internal-phase=yes
  $ cd reference-repo
  $ echo a > a
  $ hg add a
  $ hg commit -m "a"
  $ echo b > b
  $ hg add b
  $ hg commit -m "b"
  $ echo b > c
  $ hg add c
  $ hg commit -m "c"
  $ hg log -G
  @  07f0cc02c068 [draft] c
  |
  o  d2ae7f538514 [draft] b
  |
  o  cb9a9f314b8b [draft] a
  
  $ hg up ".^"
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved

do a shelve

  $ touch a_file.txt
  $ hg shelve -A
  adding a_file.txt
  shelved as default
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg log -G --hidden
  o  2ec3cf310d86 [internal] changes to: b
  |
  | o  07f0cc02c068 [draft] c
  |/
  @  d2ae7f538514 [draft] b
  |
  o  cb9a9f314b8b [draft] a
  
  $ shelved_node=`hg log --rev tip --hidden -T '{node|short}'`

add more changeset above it

  $ hg up 'desc(a)'
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ echo d > d
  $ hg add d
  $ hg commit -m "d"
  created new head
  $ echo d > e
  $ hg add e
  $ hg commit -m "e"
  $ hg up null
  0 files updated, 0 files merged, 3 files removed, 0 files unresolved
  $ hg log -G
  o  636bc07920e3 [draft] e
  |
  o  980f7dc84c29 [draft] d
  |
  | o  07f0cc02c068 [draft] c
  | |
  | o  d2ae7f538514 [draft] b
  |/
  o  cb9a9f314b8b [draft] a
  
  $ hg log -G --hidden
  o  636bc07920e3 [draft] e
  |
  o  980f7dc84c29 [draft] d
  |
  | o  2ec3cf310d86 [internal] changes to: b
  | |
  | | o  07f0cc02c068 [draft] c
  | |/
  | o  d2ae7f538514 [draft] b
  |/
  o  cb9a9f314b8b [draft] a
  
  $ cd ..

backup bundle from strip
========================

strip an ancestors of the internal changeset
--------------------------------------------

  $ cp -aR reference-repo strip-ancestor
  $ cd strip-ancestor

The internal change is stripped, yet it should be skipped from the backup bundle.

  $ hg log -G
  o  636bc07920e3 [draft] e
  |
  o  980f7dc84c29 [draft] d
  |
  | o  07f0cc02c068 [draft] c
  | |
  | o  d2ae7f538514 [draft] b
  |/
  o  cb9a9f314b8b [draft] a
  
  $ hg debugstrip 'desc(b)'
  saved backup bundle to $TESTTMP/strip-ancestor/.hg/strip-backup/d2ae7f538514-59bd8bc3-backup.hg

The change should be either gone or hidden

  $ hg log -G
  o  636bc07920e3 [draft] e
  |
  o  980f7dc84c29 [draft] d
  |
  o  cb9a9f314b8b [draft] a
  

The backup should not include it (as people tend to manipulate these directly)

  $ ls -1 .hg/strip-backup/
  d2ae7f538514-59bd8bc3-backup.hg
  $ hg debugbundle .hg/strip-backup/*.hg
  Stream params: {Compression: BZ}
  changegroup -- {nbchanges: 2, version: 03} (mandatory: True)
      d2ae7f538514cd87c17547b0de4cea71fe1af9fb
      07f0cc02c06869c81ebf33867edef30554020c0d
  cache:rev-branch-cache -- {} (mandatory: False)
  phase-heads -- {} (mandatory: True)
      07f0cc02c06869c81ebf33867edef30554020c0d draft

Shelve should still work

  $ hg unshelve
  unshelving change 'default'
  rebasing shelved changes
  $ hg status
  A a_file.txt

  $ cd ..

strip an unrelated changeset with a lower revnum
------------------------------------------------

  $ cp -aR reference-repo strip-unrelated
  $ cd strip-unrelated

The internal change is not directly stripped, but it is affected by the strip
and it is in the "temporary backup" zone. The zone that needs to be put in a
temporary bundle while we affect data under it.

  $ hg debugstrip 'desc(c)'
  saved backup bundle to $TESTTMP/strip-unrelated/.hg/strip-backup/07f0cc02c068-8fd0515f-backup.hg

The change should be either gone or hidden

  $ hg log -G
  o  636bc07920e3 [draft] e
  |
  o  980f7dc84c29 [draft] d
  |
  | o  d2ae7f538514 [draft] b
  |/
  o  cb9a9f314b8b [draft] a
  
The backup should not include it (as people tend to manipulate these directly)

  $ ls -1 .hg/strip-backup/
  07f0cc02c068-8fd0515f-backup.hg
  $ hg debugbundle .hg/strip-backup/*.hg
  Stream params: {Compression: BZ}
  changegroup -- {nbchanges: 1, version: 03} (mandatory: True)
      07f0cc02c06869c81ebf33867edef30554020c0d
  cache:rev-branch-cache -- {} (mandatory: False)
  phase-heads -- {} (mandatory: True)
      07f0cc02c06869c81ebf33867edef30554020c0d draft

Shelve should still work

  $ hg unshelve
  unshelving change 'default'
  rebasing shelved changes
  $ hg status
  A a_file.txt

  $ cd ..

explicitly strip the internal changeset
---------------------------------------

  $ cp -aR reference-repo strip-explicit
  $ cd strip-explicit

The internal change is directly selected for stripping.

  $ hg debugstrip --hidden $shelved_node

The change should be gone

  $ hg log -G --hidden
  o  636bc07920e3 [draft] e
  |
  o  980f7dc84c29 [draft] d
  |
  | o  07f0cc02c068 [draft] c
  | |
  | o  d2ae7f538514 [draft] b
  |/
  o  cb9a9f314b8b [draft] a
  

We don't need to backup anything

  $ ls -1 .hg/strip-backup/

Shelve should still work

  $ hg unshelve
  unshelving change 'default'
  rebasing shelved changes
  $ hg status
  A a_file.txt

  $ cd ..

Explicitly bundling the internal change
=======================================

  $ cd reference-repo

try to bundle it alone explicitly
---------------------------------

We should not allow it

  $ hg bundle --type v3 --exact --rev $shelved_node --hidden ../internal-01.hg
  abort: cannot bundle internal changesets
  (1 internal changesets selected)
  [255]
  $ hg debugbundle ../internal-01.hg
  abort: $ENOENT$: '../internal-01.hg' (no-windows !)
  abort: ../internal-01.hg: $ENOENT$ (windows !)
  [255]

try to bundle it with other, somewhat explicitly
------------------------------------------------

We should not allow it

  $ hg bundle --type v3 --exact --rev 'desc(b)':: --hidden ../internal-02.hg
  abort: cannot bundle internal changesets
  (1 internal changesets selected)
  [255]
  $ hg debugbundle ../internal-02.hg
  abort: $ENOENT$: '../internal-02.hg' (no-windows !)
  abort: ../internal-02.hg: $ENOENT$ (windows !)
  [255]

bundle visible ancestors
------------------------

This should succeed as the standard filtering is skipping the internal change naturally

  $ hg bundle --type v3 --exact --rev 'desc(b)':: ../internal-03.hg
  2 changesets found
  $ hg debugbundle ../internal-03.hg
  Stream params: {Compression: BZ}
  changegroup -- {nbchanges: 2, version: 03} (mandatory: True)
      d2ae7f538514cd87c17547b0de4cea71fe1af9fb
      07f0cc02c06869c81ebf33867edef30554020c0d
  cache:rev-branch-cache -- {} (mandatory: False)
  phase-heads -- {} (mandatory: True)
      07f0cc02c06869c81ebf33867edef30554020c0d draft

  $ cd ..