##// END OF EJS Templates
strip: improve help text for --no-backup option...
Sushil khanchi -
r38593:f442c949 default
parent child Browse files
Show More
@@ -1,238 +1,239 b''
1 1 """strip changesets and their descendants from history
2 2
3 3 This extension allows you to strip changesets and all their descendants from the
4 4 repository. See the command help for details.
5 5 """
6 6 from __future__ import absolute_import
7 7
8 8 from mercurial.i18n import _
9 9 from mercurial import (
10 10 bookmarks as bookmarksmod,
11 11 cmdutil,
12 12 error,
13 13 hg,
14 14 lock as lockmod,
15 15 merge,
16 16 node as nodemod,
17 17 pycompat,
18 18 registrar,
19 19 repair,
20 20 scmutil,
21 21 util,
22 22 )
23 23 nullid = nodemod.nullid
24 24 release = lockmod.release
25 25
26 26 cmdtable = {}
27 27 command = registrar.command(cmdtable)
28 28 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
29 29 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
30 30 # be specifying the version(s) of Mercurial they are tested with, or
31 31 # leave the attribute unspecified.
32 32 testedwith = 'ships-with-hg-core'
33 33
34 34 def checksubstate(repo, baserev=None):
35 35 '''return list of subrepos at a different revision than substate.
36 36 Abort if any subrepos have uncommitted changes.'''
37 37 inclsubs = []
38 38 wctx = repo[None]
39 39 if baserev:
40 40 bctx = repo[baserev]
41 41 else:
42 42 bctx = wctx.parents()[0]
43 43 for s in sorted(wctx.substate):
44 44 wctx.sub(s).bailifchanged(True)
45 45 if s not in bctx.substate or bctx.sub(s).dirty():
46 46 inclsubs.append(s)
47 47 return inclsubs
48 48
49 49 def checklocalchanges(repo, force=False, excsuffix=''):
50 50 cmdutil.checkunfinished(repo)
51 51 s = repo.status()
52 52 if not force:
53 53 if s.modified or s.added or s.removed or s.deleted:
54 54 _("local changes found") # i18n tool detection
55 55 raise error.Abort(_("local changes found" + excsuffix))
56 56 if checksubstate(repo):
57 57 _("local changed subrepos found") # i18n tool detection
58 58 raise error.Abort(_("local changed subrepos found" + excsuffix))
59 59 return s
60 60
61 61 def _findupdatetarget(repo, nodes):
62 62 unode, p2 = repo.changelog.parents(nodes[0])
63 63 currentbranch = repo[None].branch()
64 64
65 65 if (util.safehasattr(repo, 'mq') and p2 != nullid
66 66 and p2 in [x.node for x in repo.mq.applied]):
67 67 unode = p2
68 68 elif currentbranch != repo[unode].branch():
69 69 pwdir = 'parents(wdir())'
70 70 revset = 'max(((parents(%ln::%r) + %r) - %ln::%r) and branch(%s))'
71 71 branchtarget = repo.revs(revset, nodes, pwdir, pwdir, nodes, pwdir,
72 72 currentbranch)
73 73 if branchtarget:
74 74 cl = repo.changelog
75 75 unode = cl.node(branchtarget.first())
76 76
77 77 return unode
78 78
79 79 def strip(ui, repo, revs, update=True, backup=True, force=None, bookmarks=None):
80 80 with repo.wlock(), repo.lock():
81 81
82 82 if update:
83 83 checklocalchanges(repo, force=force)
84 84 urev = _findupdatetarget(repo, revs)
85 85 hg.clean(repo, urev)
86 86 repo.dirstate.write(repo.currenttransaction())
87 87
88 88 repair.strip(ui, repo, revs, backup)
89 89
90 90 repomarks = repo._bookmarks
91 91 if bookmarks:
92 92 with repo.transaction('strip') as tr:
93 93 if repo._activebookmark in bookmarks:
94 94 bookmarksmod.deactivate(repo)
95 95 repomarks.applychanges(repo, tr, [(b, None) for b in bookmarks])
96 96 for bookmark in sorted(bookmarks):
97 97 ui.write(_("bookmark '%s' deleted\n") % bookmark)
98 98
99 99 @command("strip",
100 100 [
101 101 ('r', 'rev', [], _('strip specified revision (optional, '
102 102 'can specify revisions without this '
103 103 'option)'), _('REV')),
104 104 ('f', 'force', None, _('force removal of changesets, discard '
105 105 'uncommitted changes (no backup)')),
106 ('', 'no-backup', None, _('no backups')),
107 ('', 'nobackup', None, _('no backups (DEPRECATED)')),
106 ('', 'no-backup', None, _('do not save backup bundle')),
107 ('', 'nobackup', None, _('do not save backup bundle '
108 '(DEPRECATED)')),
108 109 ('n', '', None, _('ignored (DEPRECATED)')),
109 110 ('k', 'keep', None, _("do not modify working directory during "
110 111 "strip")),
111 112 ('B', 'bookmark', [], _("remove revs only reachable from given"
112 113 " bookmark"))],
113 114 _('hg strip [-k] [-f] [-B bookmark] [-r] REV...'))
114 115 def stripcmd(ui, repo, *revs, **opts):
115 116 """strip changesets and all their descendants from the repository
116 117
117 118 The strip command removes the specified changesets and all their
118 119 descendants. If the working directory has uncommitted changes, the
119 120 operation is aborted unless the --force flag is supplied, in which
120 121 case changes will be discarded.
121 122
122 123 If a parent of the working directory is stripped, then the working
123 124 directory will automatically be updated to the most recent
124 125 available ancestor of the stripped parent after the operation
125 126 completes.
126 127
127 128 Any stripped changesets are stored in ``.hg/strip-backup`` as a
128 129 bundle (see :hg:`help bundle` and :hg:`help unbundle`). They can
129 130 be restored by running :hg:`unbundle .hg/strip-backup/BUNDLE`,
130 131 where BUNDLE is the bundle file created by the strip. Note that
131 132 the local revision numbers will in general be different after the
132 133 restore.
133 134
134 135 Use the --no-backup option to discard the backup bundle once the
135 136 operation completes.
136 137
137 138 Strip is not a history-rewriting operation and can be used on
138 139 changesets in the public phase. But if the stripped changesets have
139 140 been pushed to a remote repository you will likely pull them again.
140 141
141 142 Return 0 on success.
142 143 """
143 144 opts = pycompat.byteskwargs(opts)
144 145 backup = True
145 146 if opts.get('no_backup') or opts.get('nobackup'):
146 147 backup = False
147 148
148 149 cl = repo.changelog
149 150 revs = list(revs) + opts.get('rev')
150 151 revs = set(scmutil.revrange(repo, revs))
151 152
152 153 with repo.wlock():
153 154 bookmarks = set(opts.get('bookmark'))
154 155 if bookmarks:
155 156 repomarks = repo._bookmarks
156 157 if not bookmarks.issubset(repomarks):
157 158 raise error.Abort(_("bookmark '%s' not found") %
158 159 ','.join(sorted(bookmarks - set(repomarks.keys()))))
159 160
160 161 # If the requested bookmark is not the only one pointing to a
161 162 # a revision we have to only delete the bookmark and not strip
162 163 # anything. revsets cannot detect that case.
163 164 nodetobookmarks = {}
164 165 for mark, node in repomarks.iteritems():
165 166 nodetobookmarks.setdefault(node, []).append(mark)
166 167 for marks in nodetobookmarks.values():
167 168 if bookmarks.issuperset(marks):
168 169 rsrevs = scmutil.bookmarkrevs(repo, marks[0])
169 170 revs.update(set(rsrevs))
170 171 if not revs:
171 172 with repo.lock(), repo.transaction('bookmark') as tr:
172 173 bmchanges = [(b, None) for b in bookmarks]
173 174 repomarks.applychanges(repo, tr, bmchanges)
174 175 for bookmark in sorted(bookmarks):
175 176 ui.write(_("bookmark '%s' deleted\n") % bookmark)
176 177
177 178 if not revs:
178 179 raise error.Abort(_('empty revision set'))
179 180
180 181 descendants = set(cl.descendants(revs))
181 182 strippedrevs = revs.union(descendants)
182 183 roots = revs.difference(descendants)
183 184
184 185 # if one of the wdir parent is stripped we'll need
185 186 # to update away to an earlier revision
186 187 update = any(p != nullid and cl.rev(p) in strippedrevs
187 188 for p in repo.dirstate.parents())
188 189
189 190 rootnodes = set(cl.node(r) for r in roots)
190 191
191 192 q = getattr(repo, 'mq', None)
192 193 if q is not None and q.applied:
193 194 # refresh queue state if we're about to strip
194 195 # applied patches
195 196 if cl.rev(repo.lookup('qtip')) in strippedrevs:
196 197 q.applieddirty = True
197 198 start = 0
198 199 end = len(q.applied)
199 200 for i, statusentry in enumerate(q.applied):
200 201 if statusentry.node in rootnodes:
201 202 # if one of the stripped roots is an applied
202 203 # patch, only part of the queue is stripped
203 204 start = i
204 205 break
205 206 del q.applied[start:end]
206 207 q.savedirty()
207 208
208 209 revs = sorted(rootnodes)
209 210 if update and opts.get('keep'):
210 211 urev = _findupdatetarget(repo, revs)
211 212 uctx = repo[urev]
212 213
213 214 # only reset the dirstate for files that would actually change
214 215 # between the working context and uctx
215 216 descendantrevs = repo.revs(b"%d::.", uctx.rev())
216 217 changedfiles = []
217 218 for rev in descendantrevs:
218 219 # blindly reset the files, regardless of what actually changed
219 220 changedfiles.extend(repo[rev].files())
220 221
221 222 # reset files that only changed in the dirstate too
222 223 dirstate = repo.dirstate
223 224 dirchanges = [f for f in dirstate if dirstate[f] != 'n']
224 225 changedfiles.extend(dirchanges)
225 226
226 227 repo.dirstate.rebuild(urev, uctx.manifest(), changedfiles)
227 228 repo.dirstate.write(repo.currenttransaction())
228 229
229 230 # clear resolve state
230 231 merge.mergestate.clean(repo, repo['.'].node())
231 232
232 233 update = False
233 234
234 235
235 236 strip(ui, repo, revs, backup=backup, update=update,
236 237 force=opts.get('force'), bookmarks=bookmarks)
237 238
238 239 return 0
@@ -1,1348 +1,1348 b''
1 1 $ echo "[extensions]" >> $HGRCPATH
2 2 $ echo "strip=" >> $HGRCPATH
3 3 $ echo "drawdag=$TESTDIR/drawdag.py" >> $HGRCPATH
4 4
5 5 $ restore() {
6 6 > hg unbundle -q .hg/strip-backup/*
7 7 > rm .hg/strip-backup/*
8 8 > }
9 9 $ teststrip() {
10 10 > hg up -C $1
11 11 > echo % before update $1, strip $2
12 12 > hg parents
13 13 > hg --traceback strip $2
14 14 > echo % after update $1, strip $2
15 15 > hg parents
16 16 > restore
17 17 > }
18 18
19 19 $ hg init test
20 20 $ cd test
21 21
22 22 $ echo foo > bar
23 23 $ hg ci -Ama
24 24 adding bar
25 25
26 26 $ echo more >> bar
27 27 $ hg ci -Amb
28 28
29 29 $ echo blah >> bar
30 30 $ hg ci -Amc
31 31
32 32 $ hg up 1
33 33 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 34 $ echo blah >> bar
35 35 $ hg ci -Amd
36 36 created new head
37 37
38 38 $ echo final >> bar
39 39 $ hg ci -Ame
40 40
41 41 $ hg log
42 42 changeset: 4:443431ffac4f
43 43 tag: tip
44 44 user: test
45 45 date: Thu Jan 01 00:00:00 1970 +0000
46 46 summary: e
47 47
48 48 changeset: 3:65bd5f99a4a3
49 49 parent: 1:ef3a871183d7
50 50 user: test
51 51 date: Thu Jan 01 00:00:00 1970 +0000
52 52 summary: d
53 53
54 54 changeset: 2:264128213d29
55 55 user: test
56 56 date: Thu Jan 01 00:00:00 1970 +0000
57 57 summary: c
58 58
59 59 changeset: 1:ef3a871183d7
60 60 user: test
61 61 date: Thu Jan 01 00:00:00 1970 +0000
62 62 summary: b
63 63
64 64 changeset: 0:9ab35a2d17cb
65 65 user: test
66 66 date: Thu Jan 01 00:00:00 1970 +0000
67 67 summary: a
68 68
69 69
70 70 $ teststrip 4 4
71 71 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
72 72 % before update 4, strip 4
73 73 changeset: 4:443431ffac4f
74 74 tag: tip
75 75 user: test
76 76 date: Thu Jan 01 00:00:00 1970 +0000
77 77 summary: e
78 78
79 79 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 80 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
81 81 % after update 4, strip 4
82 82 changeset: 3:65bd5f99a4a3
83 83 tag: tip
84 84 parent: 1:ef3a871183d7
85 85 user: test
86 86 date: Thu Jan 01 00:00:00 1970 +0000
87 87 summary: d
88 88
89 89 $ teststrip 4 3
90 90 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 91 % before update 4, strip 3
92 92 changeset: 4:443431ffac4f
93 93 tag: tip
94 94 user: test
95 95 date: Thu Jan 01 00:00:00 1970 +0000
96 96 summary: e
97 97
98 98 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 99 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
100 100 % after update 4, strip 3
101 101 changeset: 1:ef3a871183d7
102 102 user: test
103 103 date: Thu Jan 01 00:00:00 1970 +0000
104 104 summary: b
105 105
106 106 $ teststrip 1 4
107 107 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 108 % before update 1, strip 4
109 109 changeset: 1:ef3a871183d7
110 110 user: test
111 111 date: Thu Jan 01 00:00:00 1970 +0000
112 112 summary: b
113 113
114 114 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
115 115 % after update 1, strip 4
116 116 changeset: 1:ef3a871183d7
117 117 user: test
118 118 date: Thu Jan 01 00:00:00 1970 +0000
119 119 summary: b
120 120
121 121 $ teststrip 4 2
122 122 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
123 123 % before update 4, strip 2
124 124 changeset: 4:443431ffac4f
125 125 tag: tip
126 126 user: test
127 127 date: Thu Jan 01 00:00:00 1970 +0000
128 128 summary: e
129 129
130 130 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
131 131 % after update 4, strip 2
132 132 changeset: 3:443431ffac4f
133 133 tag: tip
134 134 user: test
135 135 date: Thu Jan 01 00:00:00 1970 +0000
136 136 summary: e
137 137
138 138 $ teststrip 4 1
139 139 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 140 % before update 4, strip 1
141 141 changeset: 4:264128213d29
142 142 tag: tip
143 143 parent: 1:ef3a871183d7
144 144 user: test
145 145 date: Thu Jan 01 00:00:00 1970 +0000
146 146 summary: c
147 147
148 148 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
149 149 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
150 150 % after update 4, strip 1
151 151 changeset: 0:9ab35a2d17cb
152 152 tag: tip
153 153 user: test
154 154 date: Thu Jan 01 00:00:00 1970 +0000
155 155 summary: a
156 156
157 157 $ teststrip null 4
158 158 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
159 159 % before update null, strip 4
160 160 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
161 161 % after update null, strip 4
162 162
163 163 $ hg log
164 164 changeset: 4:264128213d29
165 165 tag: tip
166 166 parent: 1:ef3a871183d7
167 167 user: test
168 168 date: Thu Jan 01 00:00:00 1970 +0000
169 169 summary: c
170 170
171 171 changeset: 3:443431ffac4f
172 172 user: test
173 173 date: Thu Jan 01 00:00:00 1970 +0000
174 174 summary: e
175 175
176 176 changeset: 2:65bd5f99a4a3
177 177 user: test
178 178 date: Thu Jan 01 00:00:00 1970 +0000
179 179 summary: d
180 180
181 181 changeset: 1:ef3a871183d7
182 182 user: test
183 183 date: Thu Jan 01 00:00:00 1970 +0000
184 184 summary: b
185 185
186 186 changeset: 0:9ab35a2d17cb
187 187 user: test
188 188 date: Thu Jan 01 00:00:00 1970 +0000
189 189 summary: a
190 190
191 191 $ hg up -C 4
192 192 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 193 $ hg parents
194 194 changeset: 4:264128213d29
195 195 tag: tip
196 196 parent: 1:ef3a871183d7
197 197 user: test
198 198 date: Thu Jan 01 00:00:00 1970 +0000
199 199 summary: c
200 200
201 201
202 202 $ hg --traceback strip 4
203 203 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
204 204 saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg
205 205 $ hg parents
206 206 changeset: 1:ef3a871183d7
207 207 user: test
208 208 date: Thu Jan 01 00:00:00 1970 +0000
209 209 summary: b
210 210
211 211 $ hg debugbundle .hg/strip-backup/*
212 212 Stream params: {Compression: BZ}
213 213 changegroup -- {nbchanges: 1, version: 02} (mandatory: True)
214 214 264128213d290d868c54642d13aeaa3675551a78
215 215 cache:rev-branch-cache -- {} (mandatory: False)
216 216 phase-heads -- {} (mandatory: True)
217 217 264128213d290d868c54642d13aeaa3675551a78 draft
218 218 $ hg unbundle .hg/strip-backup/*
219 219 adding changesets
220 220 adding manifests
221 221 adding file changes
222 222 added 1 changesets with 0 changes to 1 files (+1 heads)
223 223 new changesets 264128213d29
224 224 (run 'hg heads' to see heads, 'hg merge' to merge)
225 225 $ rm .hg/strip-backup/*
226 226 $ hg log --graph
227 227 o changeset: 4:264128213d29
228 228 | tag: tip
229 229 | parent: 1:ef3a871183d7
230 230 | user: test
231 231 | date: Thu Jan 01 00:00:00 1970 +0000
232 232 | summary: c
233 233 |
234 234 | o changeset: 3:443431ffac4f
235 235 | | user: test
236 236 | | date: Thu Jan 01 00:00:00 1970 +0000
237 237 | | summary: e
238 238 | |
239 239 | o changeset: 2:65bd5f99a4a3
240 240 |/ user: test
241 241 | date: Thu Jan 01 00:00:00 1970 +0000
242 242 | summary: d
243 243 |
244 244 @ changeset: 1:ef3a871183d7
245 245 | user: test
246 246 | date: Thu Jan 01 00:00:00 1970 +0000
247 247 | summary: b
248 248 |
249 249 o changeset: 0:9ab35a2d17cb
250 250 user: test
251 251 date: Thu Jan 01 00:00:00 1970 +0000
252 252 summary: a
253 253
254 254 $ hg up -C 2
255 255 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
256 256 $ hg merge 4
257 257 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
258 258 (branch merge, don't forget to commit)
259 259
260 260 before strip of merge parent
261 261
262 262 $ hg parents
263 263 changeset: 2:65bd5f99a4a3
264 264 user: test
265 265 date: Thu Jan 01 00:00:00 1970 +0000
266 266 summary: d
267 267
268 268 changeset: 4:264128213d29
269 269 tag: tip
270 270 parent: 1:ef3a871183d7
271 271 user: test
272 272 date: Thu Jan 01 00:00:00 1970 +0000
273 273 summary: c
274 274
275 275 $ hg strip 4
276 276 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
277 277 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
278 278
279 279 after strip of merge parent
280 280
281 281 $ hg parents
282 282 changeset: 1:ef3a871183d7
283 283 user: test
284 284 date: Thu Jan 01 00:00:00 1970 +0000
285 285 summary: b
286 286
287 287 $ restore
288 288
289 289 $ hg up
290 290 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
291 291 updated to "264128213d29: c"
292 292 1 other heads for branch "default"
293 293 $ hg log -G
294 294 @ changeset: 4:264128213d29
295 295 | tag: tip
296 296 | parent: 1:ef3a871183d7
297 297 | user: test
298 298 | date: Thu Jan 01 00:00:00 1970 +0000
299 299 | summary: c
300 300 |
301 301 | o changeset: 3:443431ffac4f
302 302 | | user: test
303 303 | | date: Thu Jan 01 00:00:00 1970 +0000
304 304 | | summary: e
305 305 | |
306 306 | o changeset: 2:65bd5f99a4a3
307 307 |/ user: test
308 308 | date: Thu Jan 01 00:00:00 1970 +0000
309 309 | summary: d
310 310 |
311 311 o changeset: 1:ef3a871183d7
312 312 | user: test
313 313 | date: Thu Jan 01 00:00:00 1970 +0000
314 314 | summary: b
315 315 |
316 316 o changeset: 0:9ab35a2d17cb
317 317 user: test
318 318 date: Thu Jan 01 00:00:00 1970 +0000
319 319 summary: a
320 320
321 321
322 322 2 is parent of 3, only one strip should happen
323 323
324 324 $ hg strip "roots(2)" 3
325 325 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
326 326 $ hg log -G
327 327 @ changeset: 2:264128213d29
328 328 | tag: tip
329 329 | user: test
330 330 | date: Thu Jan 01 00:00:00 1970 +0000
331 331 | summary: c
332 332 |
333 333 o changeset: 1:ef3a871183d7
334 334 | user: test
335 335 | date: Thu Jan 01 00:00:00 1970 +0000
336 336 | summary: b
337 337 |
338 338 o changeset: 0:9ab35a2d17cb
339 339 user: test
340 340 date: Thu Jan 01 00:00:00 1970 +0000
341 341 summary: a
342 342
343 343 $ restore
344 344 $ hg log -G
345 345 o changeset: 4:443431ffac4f
346 346 | tag: tip
347 347 | user: test
348 348 | date: Thu Jan 01 00:00:00 1970 +0000
349 349 | summary: e
350 350 |
351 351 o changeset: 3:65bd5f99a4a3
352 352 | parent: 1:ef3a871183d7
353 353 | user: test
354 354 | date: Thu Jan 01 00:00:00 1970 +0000
355 355 | summary: d
356 356 |
357 357 | @ changeset: 2:264128213d29
358 358 |/ user: test
359 359 | date: Thu Jan 01 00:00:00 1970 +0000
360 360 | summary: c
361 361 |
362 362 o changeset: 1:ef3a871183d7
363 363 | user: test
364 364 | date: Thu Jan 01 00:00:00 1970 +0000
365 365 | summary: b
366 366 |
367 367 o changeset: 0:9ab35a2d17cb
368 368 user: test
369 369 date: Thu Jan 01 00:00:00 1970 +0000
370 370 summary: a
371 371
372 372 Failed hook while applying "saveheads" bundle.
373 373
374 374 $ hg strip 2 --config hooks.pretxnchangegroup.bad=false
375 375 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
376 376 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
377 377 transaction abort!
378 378 rollback completed
379 379 strip failed, backup bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob)
380 380 strip failed, unrecovered changes stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob)
381 381 (fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/test/.hg/strip-backup/*-temp.hg'") (glob)
382 382 abort: pretxnchangegroup.bad hook exited with status 1
383 383 [255]
384 384 $ restore
385 385 $ hg log -G
386 386 o changeset: 4:443431ffac4f
387 387 | tag: tip
388 388 | user: test
389 389 | date: Thu Jan 01 00:00:00 1970 +0000
390 390 | summary: e
391 391 |
392 392 o changeset: 3:65bd5f99a4a3
393 393 | parent: 1:ef3a871183d7
394 394 | user: test
395 395 | date: Thu Jan 01 00:00:00 1970 +0000
396 396 | summary: d
397 397 |
398 398 | o changeset: 2:264128213d29
399 399 |/ user: test
400 400 | date: Thu Jan 01 00:00:00 1970 +0000
401 401 | summary: c
402 402 |
403 403 @ changeset: 1:ef3a871183d7
404 404 | user: test
405 405 | date: Thu Jan 01 00:00:00 1970 +0000
406 406 | summary: b
407 407 |
408 408 o changeset: 0:9ab35a2d17cb
409 409 user: test
410 410 date: Thu Jan 01 00:00:00 1970 +0000
411 411 summary: a
412 412
413 413
414 414 2 different branches: 2 strips
415 415
416 416 $ hg strip 2 4
417 417 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
418 418 $ hg log -G
419 419 o changeset: 2:65bd5f99a4a3
420 420 | tag: tip
421 421 | user: test
422 422 | date: Thu Jan 01 00:00:00 1970 +0000
423 423 | summary: d
424 424 |
425 425 @ changeset: 1:ef3a871183d7
426 426 | user: test
427 427 | date: Thu Jan 01 00:00:00 1970 +0000
428 428 | summary: b
429 429 |
430 430 o changeset: 0:9ab35a2d17cb
431 431 user: test
432 432 date: Thu Jan 01 00:00:00 1970 +0000
433 433 summary: a
434 434
435 435 $ restore
436 436
437 437 2 different branches and a common ancestor: 1 strip
438 438
439 439 $ hg strip 1 "2|4"
440 440 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
441 441 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
442 442 $ restore
443 443
444 444 verify fncache is kept up-to-date
445 445
446 446 $ touch a
447 447 $ hg ci -qAm a
448 448 #if repofncache
449 449 $ cat .hg/store/fncache | sort
450 450 data/a.i
451 451 data/bar.i
452 452 #endif
453 453
454 454 $ hg strip tip
455 455 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
456 456 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
457 457 #if repofncache
458 458 $ cat .hg/store/fncache
459 459 data/bar.i
460 460 #endif
461 461
462 462 stripping an empty revset
463 463
464 464 $ hg strip "1 and not 1"
465 465 abort: empty revision set
466 466 [255]
467 467
468 468 remove branchy history for qimport tests
469 469
470 470 $ hg strip 3
471 471 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
472 472
473 473
474 474 strip of applied mq should cleanup status file
475 475
476 476 $ echo "mq=" >> $HGRCPATH
477 477 $ hg up -C 3
478 478 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
479 479 $ echo fooagain >> bar
480 480 $ hg ci -mf
481 481 $ hg qimport -r tip:2
482 482
483 483 applied patches before strip
484 484
485 485 $ hg qapplied
486 486 d
487 487 e
488 488 f
489 489
490 490 stripping revision in queue
491 491
492 492 $ hg strip 3
493 493 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
494 494 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
495 495
496 496 applied patches after stripping rev in queue
497 497
498 498 $ hg qapplied
499 499 d
500 500
501 501 stripping ancestor of queue
502 502
503 503 $ hg strip 1
504 504 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
505 505 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
506 506
507 507 applied patches after stripping ancestor of queue
508 508
509 509 $ hg qapplied
510 510
511 511 Verify strip protects against stripping wc parent when there are uncommitted mods
512 512
513 513 $ echo b > b
514 514 $ echo bb > bar
515 515 $ hg add b
516 516 $ hg ci -m 'b'
517 517 $ hg log --graph
518 518 @ changeset: 1:76dcf9fab855
519 519 | tag: tip
520 520 | user: test
521 521 | date: Thu Jan 01 00:00:00 1970 +0000
522 522 | summary: b
523 523 |
524 524 o changeset: 0:9ab35a2d17cb
525 525 user: test
526 526 date: Thu Jan 01 00:00:00 1970 +0000
527 527 summary: a
528 528
529 529 $ hg up 0
530 530 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
531 531 $ echo c > bar
532 532 $ hg up -t false
533 533 merging bar
534 534 merging bar failed!
535 535 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
536 536 use 'hg resolve' to retry unresolved file merges
537 537 [1]
538 538 $ hg sum
539 539 parent: 1:76dcf9fab855 tip
540 540 b
541 541 branch: default
542 542 commit: 1 modified, 1 unknown, 1 unresolved
543 543 update: (current)
544 544 phases: 2 draft
545 545 mq: 3 unapplied
546 546
547 547 $ echo c > b
548 548 $ hg strip tip
549 549 abort: local changes found
550 550 [255]
551 551 $ hg strip tip --keep
552 552 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
553 553 $ hg log --graph
554 554 @ changeset: 0:9ab35a2d17cb
555 555 tag: tip
556 556 user: test
557 557 date: Thu Jan 01 00:00:00 1970 +0000
558 558 summary: a
559 559
560 560 $ hg status
561 561 M bar
562 562 ? b
563 563 ? bar.orig
564 564
565 565 $ rm bar.orig
566 566 $ hg sum
567 567 parent: 0:9ab35a2d17cb tip
568 568 a
569 569 branch: default
570 570 commit: 1 modified, 1 unknown
571 571 update: (current)
572 572 phases: 1 draft
573 573 mq: 3 unapplied
574 574
575 575 Strip adds, removes, modifies with --keep
576 576
577 577 $ touch b
578 578 $ hg add b
579 579 $ hg commit -mb
580 580 $ touch c
581 581
582 582 ... with a clean working dir
583 583
584 584 $ hg add c
585 585 $ hg rm bar
586 586 $ hg commit -mc
587 587 $ hg status
588 588 $ hg strip --keep tip
589 589 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
590 590 $ hg status
591 591 ! bar
592 592 ? c
593 593
594 594 ... with a dirty working dir
595 595
596 596 $ hg add c
597 597 $ hg rm bar
598 598 $ hg commit -mc
599 599 $ hg status
600 600 $ echo b > b
601 601 $ echo d > d
602 602 $ hg strip --keep tip
603 603 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
604 604 $ hg status
605 605 M b
606 606 ! bar
607 607 ? c
608 608 ? d
609 609
610 610 ... after updating the dirstate
611 611 $ hg add c
612 612 $ hg commit -mc
613 613 $ hg rm c
614 614 $ hg commit -mc
615 615 $ hg strip --keep '.^' -q
616 616 $ cd ..
617 617
618 618 stripping many nodes on a complex graph (issue3299)
619 619
620 620 $ hg init issue3299
621 621 $ cd issue3299
622 622 $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
623 623 $ hg strip 'not ancestors(x)'
624 624 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
625 625
626 626 test hg strip -B bookmark
627 627
628 628 $ cd ..
629 629 $ hg init bookmarks
630 630 $ cd bookmarks
631 631 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b<m+2:d<2.:e<m+1:f'
632 632 $ hg bookmark -r 'a' 'todelete'
633 633 $ hg bookmark -r 'b' 'B'
634 634 $ hg bookmark -r 'b' 'nostrip'
635 635 $ hg bookmark -r 'c' 'delete'
636 636 $ hg bookmark -r 'd' 'multipledelete1'
637 637 $ hg bookmark -r 'e' 'multipledelete2'
638 638 $ hg bookmark -r 'f' 'singlenode1'
639 639 $ hg bookmark -r 'f' 'singlenode2'
640 640 $ hg up -C todelete
641 641 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
642 642 (activating bookmark todelete)
643 643 $ hg strip -B nostrip
644 644 bookmark 'nostrip' deleted
645 645 abort: empty revision set
646 646 [255]
647 647 $ hg strip -B todelete
648 648 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
649 649 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
650 650 bookmark 'todelete' deleted
651 651 $ hg id -ir dcbb326fdec2
652 652 abort: unknown revision 'dcbb326fdec2'!
653 653 [255]
654 654 $ hg id -ir d62d843c9a01
655 655 d62d843c9a01
656 656 $ hg bookmarks
657 657 B 9:ff43616e5d0f
658 658 delete 6:2702dd0c91e7
659 659 multipledelete1 11:e46a4836065c
660 660 multipledelete2 12:b4594d867745
661 661 singlenode1 13:43227190fef8
662 662 singlenode2 13:43227190fef8
663 663 $ hg strip -B multipledelete1 -B multipledelete2
664 664 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/e46a4836065c-89ec65c2-backup.hg
665 665 bookmark 'multipledelete1' deleted
666 666 bookmark 'multipledelete2' deleted
667 667 $ hg id -ir e46a4836065c
668 668 abort: unknown revision 'e46a4836065c'!
669 669 [255]
670 670 $ hg id -ir b4594d867745
671 671 abort: unknown revision 'b4594d867745'!
672 672 [255]
673 673 $ hg strip -B singlenode1 -B singlenode2
674 674 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg
675 675 bookmark 'singlenode1' deleted
676 676 bookmark 'singlenode2' deleted
677 677 $ hg id -ir 43227190fef8
678 678 abort: unknown revision '43227190fef8'!
679 679 [255]
680 680 $ hg strip -B unknownbookmark
681 681 abort: bookmark 'unknownbookmark' not found
682 682 [255]
683 683 $ hg strip -B unknownbookmark1 -B unknownbookmark2
684 684 abort: bookmark 'unknownbookmark1,unknownbookmark2' not found
685 685 [255]
686 686 $ hg strip -B delete -B unknownbookmark
687 687 abort: bookmark 'unknownbookmark' not found
688 688 [255]
689 689 $ hg strip -B delete
690 690 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
691 691 bookmark 'delete' deleted
692 692 $ hg id -ir 6:2702dd0c91e7
693 693 abort: unknown revision '2702dd0c91e7'!
694 694 [255]
695 695 $ hg update B
696 696 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
697 697 (activating bookmark B)
698 698 $ echo a > a
699 699 $ hg add a
700 700 $ hg strip -B B
701 701 abort: local changes found
702 702 [255]
703 703 $ hg bookmarks
704 704 * B 6:ff43616e5d0f
705 705
706 706 Make sure no one adds back a -b option:
707 707
708 708 $ hg strip -b tip
709 709 hg strip: option -b not recognized
710 710 hg strip [-k] [-f] [-B bookmark] [-r] REV...
711 711
712 712 strip changesets and all their descendants from the repository
713 713
714 714 (use 'hg help -e strip' to show help for the strip extension)
715 715
716 716 options ([+] can be repeated):
717 717
718 718 -r --rev REV [+] strip specified revision (optional, can specify
719 719 revisions without this option)
720 720 -f --force force removal of changesets, discard uncommitted
721 721 changes (no backup)
722 --no-backup no backups
722 --no-backup do not save backup bundle
723 723 -k --keep do not modify working directory during strip
724 724 -B --bookmark VALUE [+] remove revs only reachable from given bookmark
725 725 --mq operate on patch repository
726 726
727 727 (use 'hg strip -h' to show more help)
728 728 [255]
729 729
730 730 $ cd ..
731 731
732 732 Verify bundles don't get overwritten:
733 733
734 734 $ hg init doublebundle
735 735 $ cd doublebundle
736 736 $ touch a
737 737 $ hg commit -Aqm a
738 738 $ touch b
739 739 $ hg commit -Aqm b
740 740 $ hg strip -r 0
741 741 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
742 742 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-e68910bd-backup.hg
743 743 $ ls .hg/strip-backup
744 744 3903775176ed-e68910bd-backup.hg
745 745 #if repobundlerepo
746 746 $ hg pull -q -r 3903775176ed .hg/strip-backup/3903775176ed-e68910bd-backup.hg
747 747 $ hg strip -r 0
748 748 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg
749 749 $ ls .hg/strip-backup
750 750 3903775176ed-54390173-backup.hg
751 751 3903775176ed-e68910bd-backup.hg
752 752 #endif
753 753 $ cd ..
754 754
755 755 Test that we only bundle the stripped changesets (issue4736)
756 756 ------------------------------------------------------------
757 757
758 758 initialization (previous repo is empty anyway)
759 759
760 760 $ hg init issue4736
761 761 $ cd issue4736
762 762 $ echo a > a
763 763 $ hg add a
764 764 $ hg commit -m commitA
765 765 $ echo b > b
766 766 $ hg add b
767 767 $ hg commit -m commitB
768 768 $ echo c > c
769 769 $ hg add c
770 770 $ hg commit -m commitC
771 771 $ hg up 'desc(commitB)'
772 772 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
773 773 $ echo d > d
774 774 $ hg add d
775 775 $ hg commit -m commitD
776 776 created new head
777 777 $ hg up 'desc(commitC)'
778 778 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
779 779 $ hg merge 'desc(commitD)'
780 780 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
781 781 (branch merge, don't forget to commit)
782 782 $ hg ci -m 'mergeCD'
783 783 $ hg log -G
784 784 @ changeset: 4:d8db9d137221
785 785 |\ tag: tip
786 786 | | parent: 2:5c51d8d6557d
787 787 | | parent: 3:6625a5168474
788 788 | | user: test
789 789 | | date: Thu Jan 01 00:00:00 1970 +0000
790 790 | | summary: mergeCD
791 791 | |
792 792 | o changeset: 3:6625a5168474
793 793 | | parent: 1:eca11cf91c71
794 794 | | user: test
795 795 | | date: Thu Jan 01 00:00:00 1970 +0000
796 796 | | summary: commitD
797 797 | |
798 798 o | changeset: 2:5c51d8d6557d
799 799 |/ user: test
800 800 | date: Thu Jan 01 00:00:00 1970 +0000
801 801 | summary: commitC
802 802 |
803 803 o changeset: 1:eca11cf91c71
804 804 | user: test
805 805 | date: Thu Jan 01 00:00:00 1970 +0000
806 806 | summary: commitB
807 807 |
808 808 o changeset: 0:105141ef12d0
809 809 user: test
810 810 date: Thu Jan 01 00:00:00 1970 +0000
811 811 summary: commitA
812 812
813 813
814 814 Check bundle behavior:
815 815
816 816 $ hg bundle -r 'desc(mergeCD)' --base 'desc(commitC)' ../issue4736.hg
817 817 2 changesets found
818 818 #if repobundlerepo
819 819 $ hg log -r 'bundle()' -R ../issue4736.hg
820 820 changeset: 3:6625a5168474
821 821 parent: 1:eca11cf91c71
822 822 user: test
823 823 date: Thu Jan 01 00:00:00 1970 +0000
824 824 summary: commitD
825 825
826 826 changeset: 4:d8db9d137221
827 827 tag: tip
828 828 parent: 2:5c51d8d6557d
829 829 parent: 3:6625a5168474
830 830 user: test
831 831 date: Thu Jan 01 00:00:00 1970 +0000
832 832 summary: mergeCD
833 833
834 834 #endif
835 835
836 836 check strip behavior
837 837
838 838 $ hg --config extensions.strip= strip 'desc(commitD)' --debug
839 839 resolving manifests
840 840 branchmerge: False, force: True, partial: False
841 841 ancestor: d8db9d137221+, local: d8db9d137221+, remote: eca11cf91c71
842 842 c: other deleted -> r
843 843 removing c
844 844 d: other deleted -> r
845 845 removing d
846 846 starting 4 threads for background file closing (?)
847 847 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
848 848 2 changesets found
849 849 list of changesets:
850 850 6625a516847449b6f0fa3737b9ba56e9f0f3032c
851 851 d8db9d1372214336d2b5570f20ee468d2c72fa8b
852 852 bundle2-output-bundle: "HG20", (1 params) 3 parts total
853 853 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
854 854 bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
855 855 bundle2-output-part: "phase-heads" 24 bytes payload
856 856 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg
857 857 updating the branch cache
858 858 invalid branchheads cache (served): tip differs
859 859 $ hg log -G
860 860 o changeset: 2:5c51d8d6557d
861 861 | tag: tip
862 862 | user: test
863 863 | date: Thu Jan 01 00:00:00 1970 +0000
864 864 | summary: commitC
865 865 |
866 866 @ changeset: 1:eca11cf91c71
867 867 | user: test
868 868 | date: Thu Jan 01 00:00:00 1970 +0000
869 869 | summary: commitB
870 870 |
871 871 o changeset: 0:105141ef12d0
872 872 user: test
873 873 date: Thu Jan 01 00:00:00 1970 +0000
874 874 summary: commitA
875 875
876 876
877 877 strip backup content
878 878
879 879 #if repobundlerepo
880 880 $ hg log -r 'bundle()' -R .hg/strip-backup/6625a5168474-*-backup.hg
881 881 changeset: 3:6625a5168474
882 882 parent: 1:eca11cf91c71
883 883 user: test
884 884 date: Thu Jan 01 00:00:00 1970 +0000
885 885 summary: commitD
886 886
887 887 changeset: 4:d8db9d137221
888 888 tag: tip
889 889 parent: 2:5c51d8d6557d
890 890 parent: 3:6625a5168474
891 891 user: test
892 892 date: Thu Jan 01 00:00:00 1970 +0000
893 893 summary: mergeCD
894 894
895 895
896 896 #endif
897 897
898 898 Check that the phase cache is properly invalidated after a strip with bookmark.
899 899
900 900 $ cat > ../stripstalephasecache.py << EOF
901 901 > from mercurial import extensions, localrepo
902 902 > def transactioncallback(orig, repo, desc, *args, **kwargs):
903 903 > def test(transaction):
904 904 > # observe cache inconsistency
905 905 > try:
906 906 > [repo.changelog.node(r) for r in repo.revs(b"not public()")]
907 907 > except IndexError:
908 908 > repo.ui.status(b"Index error!\n")
909 909 > transaction = orig(repo, desc, *args, **kwargs)
910 910 > # warm up the phase cache
911 911 > list(repo.revs(b"not public()"))
912 912 > if desc != b'strip':
913 913 > transaction.addpostclose(b"phase invalidation test", test)
914 914 > return transaction
915 915 > def extsetup(ui):
916 916 > extensions.wrapfunction(localrepo.localrepository, b"transaction",
917 917 > transactioncallback)
918 918 > EOF
919 919 $ hg up -C 2
920 920 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
921 921 $ echo k > k
922 922 $ hg add k
923 923 $ hg commit -m commitK
924 924 $ echo l > l
925 925 $ hg add l
926 926 $ hg commit -m commitL
927 927 $ hg book -r tip blah
928 928 $ hg strip ".^" --config extensions.crash=$TESTTMP/stripstalephasecache.py
929 929 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
930 930 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/8f0b4384875c-4fa10deb-backup.hg
931 931 $ hg up -C 1
932 932 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
933 933
934 934 Error during post-close callback of the strip transaction
935 935 (They should be gracefully handled and reported)
936 936
937 937 $ cat > ../crashstrip.py << EOF
938 938 > from mercurial import error
939 939 > def reposetup(ui, repo):
940 940 > class crashstriprepo(repo.__class__):
941 941 > def transaction(self, desc, *args, **kwargs):
942 942 > tr = super(crashstriprepo, self).transaction(desc, *args, **kwargs)
943 943 > if desc == b'strip':
944 944 > def crash(tra): raise error.Abort(b'boom')
945 945 > tr.addpostclose(b'crash', crash)
946 946 > return tr
947 947 > repo.__class__ = crashstriprepo
948 948 > EOF
949 949 $ hg strip tip --config extensions.crash=$TESTTMP/crashstrip.py
950 950 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg
951 951 strip failed, backup bundle stored in '$TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg'
952 952 abort: boom
953 953 [255]
954 954
955 955 test stripping a working directory parent doesn't switch named branches
956 956
957 957 $ hg log -G
958 958 @ changeset: 1:eca11cf91c71
959 959 | tag: tip
960 960 | user: test
961 961 | date: Thu Jan 01 00:00:00 1970 +0000
962 962 | summary: commitB
963 963 |
964 964 o changeset: 0:105141ef12d0
965 965 user: test
966 966 date: Thu Jan 01 00:00:00 1970 +0000
967 967 summary: commitA
968 968
969 969
970 970 $ hg branch new-branch
971 971 marked working directory as branch new-branch
972 972 (branches are permanent and global, did you want a bookmark?)
973 973 $ hg ci -m "start new branch"
974 974 $ echo 'foo' > foo.txt
975 975 $ hg ci -Aqm foo
976 976 $ hg up default
977 977 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
978 978 $ echo 'bar' > bar.txt
979 979 $ hg ci -Aqm bar
980 980 $ hg up new-branch
981 981 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
982 982 $ hg merge default
983 983 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
984 984 (branch merge, don't forget to commit)
985 985 $ hg log -G
986 986 @ changeset: 4:35358f982181
987 987 | tag: tip
988 988 | parent: 1:eca11cf91c71
989 989 | user: test
990 990 | date: Thu Jan 01 00:00:00 1970 +0000
991 991 | summary: bar
992 992 |
993 993 | @ changeset: 3:f62c6c09b707
994 994 | | branch: new-branch
995 995 | | user: test
996 996 | | date: Thu Jan 01 00:00:00 1970 +0000
997 997 | | summary: foo
998 998 | |
999 999 | o changeset: 2:b1d33a8cadd9
1000 1000 |/ branch: new-branch
1001 1001 | user: test
1002 1002 | date: Thu Jan 01 00:00:00 1970 +0000
1003 1003 | summary: start new branch
1004 1004 |
1005 1005 o changeset: 1:eca11cf91c71
1006 1006 | user: test
1007 1007 | date: Thu Jan 01 00:00:00 1970 +0000
1008 1008 | summary: commitB
1009 1009 |
1010 1010 o changeset: 0:105141ef12d0
1011 1011 user: test
1012 1012 date: Thu Jan 01 00:00:00 1970 +0000
1013 1013 summary: commitA
1014 1014
1015 1015
1016 1016 $ hg strip --force -r 35358f982181
1017 1017 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1018 1018 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/35358f982181-50d992d4-backup.hg
1019 1019 $ hg log -G
1020 1020 @ changeset: 3:f62c6c09b707
1021 1021 | branch: new-branch
1022 1022 | tag: tip
1023 1023 | user: test
1024 1024 | date: Thu Jan 01 00:00:00 1970 +0000
1025 1025 | summary: foo
1026 1026 |
1027 1027 o changeset: 2:b1d33a8cadd9
1028 1028 | branch: new-branch
1029 1029 | user: test
1030 1030 | date: Thu Jan 01 00:00:00 1970 +0000
1031 1031 | summary: start new branch
1032 1032 |
1033 1033 o changeset: 1:eca11cf91c71
1034 1034 | user: test
1035 1035 | date: Thu Jan 01 00:00:00 1970 +0000
1036 1036 | summary: commitB
1037 1037 |
1038 1038 o changeset: 0:105141ef12d0
1039 1039 user: test
1040 1040 date: Thu Jan 01 00:00:00 1970 +0000
1041 1041 summary: commitA
1042 1042
1043 1043
1044 1044 $ hg up default
1045 1045 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1046 1046 $ echo 'bar' > bar.txt
1047 1047 $ hg ci -Aqm bar
1048 1048 $ hg up new-branch
1049 1049 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1050 1050 $ hg merge default
1051 1051 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1052 1052 (branch merge, don't forget to commit)
1053 1053 $ hg ci -m merge
1054 1054 $ hg log -G
1055 1055 @ changeset: 5:4cf5e92caec2
1056 1056 |\ branch: new-branch
1057 1057 | | tag: tip
1058 1058 | | parent: 3:f62c6c09b707
1059 1059 | | parent: 4:35358f982181
1060 1060 | | user: test
1061 1061 | | date: Thu Jan 01 00:00:00 1970 +0000
1062 1062 | | summary: merge
1063 1063 | |
1064 1064 | o changeset: 4:35358f982181
1065 1065 | | parent: 1:eca11cf91c71
1066 1066 | | user: test
1067 1067 | | date: Thu Jan 01 00:00:00 1970 +0000
1068 1068 | | summary: bar
1069 1069 | |
1070 1070 o | changeset: 3:f62c6c09b707
1071 1071 | | branch: new-branch
1072 1072 | | user: test
1073 1073 | | date: Thu Jan 01 00:00:00 1970 +0000
1074 1074 | | summary: foo
1075 1075 | |
1076 1076 o | changeset: 2:b1d33a8cadd9
1077 1077 |/ branch: new-branch
1078 1078 | user: test
1079 1079 | date: Thu Jan 01 00:00:00 1970 +0000
1080 1080 | summary: start new branch
1081 1081 |
1082 1082 o changeset: 1:eca11cf91c71
1083 1083 | user: test
1084 1084 | date: Thu Jan 01 00:00:00 1970 +0000
1085 1085 | summary: commitB
1086 1086 |
1087 1087 o changeset: 0:105141ef12d0
1088 1088 user: test
1089 1089 date: Thu Jan 01 00:00:00 1970 +0000
1090 1090 summary: commitA
1091 1091
1092 1092
1093 1093 $ hg strip -r 35358f982181
1094 1094 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1095 1095 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/35358f982181-a6f020aa-backup.hg
1096 1096 $ hg log -G
1097 1097 @ changeset: 3:f62c6c09b707
1098 1098 | branch: new-branch
1099 1099 | tag: tip
1100 1100 | user: test
1101 1101 | date: Thu Jan 01 00:00:00 1970 +0000
1102 1102 | summary: foo
1103 1103 |
1104 1104 o changeset: 2:b1d33a8cadd9
1105 1105 | branch: new-branch
1106 1106 | user: test
1107 1107 | date: Thu Jan 01 00:00:00 1970 +0000
1108 1108 | summary: start new branch
1109 1109 |
1110 1110 o changeset: 1:eca11cf91c71
1111 1111 | user: test
1112 1112 | date: Thu Jan 01 00:00:00 1970 +0000
1113 1113 | summary: commitB
1114 1114 |
1115 1115 o changeset: 0:105141ef12d0
1116 1116 user: test
1117 1117 date: Thu Jan 01 00:00:00 1970 +0000
1118 1118 summary: commitA
1119 1119
1120 1120
1121 1121 $ hg unbundle -u $TESTTMP/issue4736/.hg/strip-backup/35358f982181-a6f020aa-backup.hg
1122 1122 adding changesets
1123 1123 adding manifests
1124 1124 adding file changes
1125 1125 added 2 changesets with 1 changes to 1 files
1126 1126 new changesets 35358f982181:4cf5e92caec2
1127 1127 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1128 1128
1129 1129 $ hg strip -k -r 35358f982181
1130 1130 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/35358f982181-a6f020aa-backup.hg
1131 1131 $ hg log -G
1132 1132 @ changeset: 3:f62c6c09b707
1133 1133 | branch: new-branch
1134 1134 | tag: tip
1135 1135 | user: test
1136 1136 | date: Thu Jan 01 00:00:00 1970 +0000
1137 1137 | summary: foo
1138 1138 |
1139 1139 o changeset: 2:b1d33a8cadd9
1140 1140 | branch: new-branch
1141 1141 | user: test
1142 1142 | date: Thu Jan 01 00:00:00 1970 +0000
1143 1143 | summary: start new branch
1144 1144 |
1145 1145 o changeset: 1:eca11cf91c71
1146 1146 | user: test
1147 1147 | date: Thu Jan 01 00:00:00 1970 +0000
1148 1148 | summary: commitB
1149 1149 |
1150 1150 o changeset: 0:105141ef12d0
1151 1151 user: test
1152 1152 date: Thu Jan 01 00:00:00 1970 +0000
1153 1153 summary: commitA
1154 1154
1155 1155 $ hg diff
1156 1156 diff -r f62c6c09b707 bar.txt
1157 1157 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1158 1158 +++ b/bar.txt Thu Jan 01 00:00:00 1970 +0000
1159 1159 @@ -0,0 +1,1 @@
1160 1160 +bar
1161 1161
1162 1162 Use delayedstrip to strip inside a transaction
1163 1163
1164 1164 $ cd $TESTTMP
1165 1165 $ hg init delayedstrip
1166 1166 $ cd delayedstrip
1167 1167 $ hg debugdrawdag <<'EOS'
1168 1168 > D
1169 1169 > |
1170 1170 > C F H # Commit on top of "I",
1171 1171 > | |/| # Strip B+D+I+E+G+H+Z
1172 1172 > I B E G
1173 1173 > \|/
1174 1174 > A Z
1175 1175 > EOS
1176 1176 $ cp -R . ../scmutilcleanup
1177 1177
1178 1178 $ hg up -C I
1179 1179 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1180 1180 $ echo 3 >> I
1181 1181 $ cat > $TESTTMP/delayedstrip.py <<EOF
1182 1182 > from __future__ import absolute_import
1183 1183 > from mercurial import commands, registrar, repair
1184 1184 > cmdtable = {}
1185 1185 > command = registrar.command(cmdtable)
1186 1186 > @command(b'testdelayedstrip')
1187 1187 > def testdelayedstrip(ui, repo):
1188 1188 > def getnodes(expr):
1189 1189 > return [repo.changelog.node(r) for r in repo.revs(expr)]
1190 1190 > with repo.wlock():
1191 1191 > with repo.lock():
1192 1192 > with repo.transaction(b'delayedstrip'):
1193 1193 > repair.delayedstrip(ui, repo, getnodes(b'B+I+Z+D+E'), b'J')
1194 1194 > repair.delayedstrip(ui, repo, getnodes(b'G+H+Z'), b'I')
1195 1195 > commands.commit(ui, repo, message=b'J', date=b'0 0')
1196 1196 > EOF
1197 1197 $ hg testdelayedstrip --config extensions.t=$TESTTMP/delayedstrip.py
1198 1198 warning: orphaned descendants detected, not stripping 08ebfeb61bac, 112478962961, 7fb047a69f22
1199 1199 saved backup bundle to $TESTTMP/delayedstrip/.hg/strip-backup/f585351a92f8-17475721-I.hg
1200 1200
1201 1201 $ hg log -G -T '{rev}:{node|short} {desc}' -r 'sort(all(), topo)'
1202 1202 @ 6:2f2d51af6205 J
1203 1203 |
1204 1204 o 3:08ebfeb61bac I
1205 1205 |
1206 1206 | o 5:64a8289d2492 F
1207 1207 | |
1208 1208 | o 2:7fb047a69f22 E
1209 1209 |/
1210 1210 | o 4:26805aba1e60 C
1211 1211 | |
1212 1212 | o 1:112478962961 B
1213 1213 |/
1214 1214 o 0:426bada5c675 A
1215 1215
1216 1216 Test high-level scmutil.cleanupnodes API
1217 1217
1218 1218 $ cd $TESTTMP/scmutilcleanup
1219 1219 $ hg debugdrawdag <<'EOS'
1220 1220 > D2 F2 G2 # D2, F2, G2 are replacements for D, F, G
1221 1221 > | | |
1222 1222 > C H G
1223 1223 > EOS
1224 1224 $ for i in B C D F G I Z; do
1225 1225 > hg bookmark -i -r $i b-$i
1226 1226 > done
1227 1227 $ hg bookmark -i -r E 'b-F@divergent1'
1228 1228 $ hg bookmark -i -r H 'b-F@divergent2'
1229 1229 $ hg bookmark -i -r G 'b-F@divergent3'
1230 1230 $ cp -R . ../scmutilcleanup.obsstore
1231 1231
1232 1232 $ cat > $TESTTMP/scmutilcleanup.py <<EOF
1233 1233 > from mercurial import registrar, scmutil
1234 1234 > cmdtable = {}
1235 1235 > command = registrar.command(cmdtable)
1236 1236 > @command(b'testnodescleanup')
1237 1237 > def testnodescleanup(ui, repo):
1238 1238 > def nodes(expr):
1239 1239 > return [repo.changelog.node(r) for r in repo.revs(expr)]
1240 1240 > def node(expr):
1241 1241 > return nodes(expr)[0]
1242 1242 > with repo.wlock():
1243 1243 > with repo.lock():
1244 1244 > with repo.transaction(b'delayedstrip'):
1245 1245 > mapping = {node(b'F'): [node(b'F2')],
1246 1246 > node(b'D'): [node(b'D2')],
1247 1247 > node(b'G'): [node(b'G2')]}
1248 1248 > scmutil.cleanupnodes(repo, mapping, b'replace')
1249 1249 > scmutil.cleanupnodes(repo, nodes(b'((B::)+I+Z)-D2'),
1250 1250 > b'replace')
1251 1251 > EOF
1252 1252 $ hg testnodescleanup --config extensions.t=$TESTTMP/scmutilcleanup.py
1253 1253 warning: orphaned descendants detected, not stripping 112478962961, 1fc8102cda62, 26805aba1e60
1254 1254 saved backup bundle to $TESTTMP/scmutilcleanup/.hg/strip-backup/f585351a92f8-73fb7c03-replace.hg
1255 1255
1256 1256 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1257 1257 o 8:1473d4b996d1 G2 b-F@divergent3 b-G
1258 1258 |
1259 1259 | o 7:d11b3456a873 F2 b-F
1260 1260 | |
1261 1261 | o 5:5cb05ba470a7 H
1262 1262 |/|
1263 1263 | o 3:7fb047a69f22 E b-F@divergent1
1264 1264 | |
1265 1265 | | o 6:7c78f703e465 D2 b-D
1266 1266 | | |
1267 1267 | | o 4:26805aba1e60 C
1268 1268 | | |
1269 1269 | | o 2:112478962961 B
1270 1270 | |/
1271 1271 o | 1:1fc8102cda62 G
1272 1272 /
1273 1273 o 0:426bada5c675 A b-B b-C b-I
1274 1274
1275 1275 $ hg bookmark
1276 1276 b-B 0:426bada5c675
1277 1277 b-C 0:426bada5c675
1278 1278 b-D 6:7c78f703e465
1279 1279 b-F 7:d11b3456a873
1280 1280 b-F@divergent1 3:7fb047a69f22
1281 1281 b-F@divergent3 8:1473d4b996d1
1282 1282 b-G 8:1473d4b996d1
1283 1283 b-I 0:426bada5c675
1284 1284 b-Z -1:000000000000
1285 1285
1286 1286 Test the above using obsstore "by the way". Not directly related to strip, but
1287 1287 we have reusable code here
1288 1288
1289 1289 $ cd $TESTTMP/scmutilcleanup.obsstore
1290 1290 $ cat >> .hg/hgrc <<EOF
1291 1291 > [experimental]
1292 1292 > evolution=true
1293 1293 > evolution.track-operation=1
1294 1294 > EOF
1295 1295
1296 1296 $ hg testnodescleanup --config extensions.t=$TESTTMP/scmutilcleanup.py
1297 1297 4 new orphan changesets
1298 1298
1299 1299 $ rm .hg/localtags
1300 1300 $ hg log -G -T '{rev}:{node|short} {desc} {bookmarks}' -r 'sort(all(), topo)'
1301 1301 * 12:1473d4b996d1 G2 b-F@divergent3 b-G
1302 1302 |
1303 1303 | * 11:d11b3456a873 F2 b-F
1304 1304 | |
1305 1305 | * 8:5cb05ba470a7 H
1306 1306 |/|
1307 1307 | o 4:7fb047a69f22 E b-F@divergent1
1308 1308 | |
1309 1309 | | * 10:7c78f703e465 D2 b-D
1310 1310 | | |
1311 1311 | | x 6:26805aba1e60 C
1312 1312 | | |
1313 1313 | | x 3:112478962961 B
1314 1314 | |/
1315 1315 x | 1:1fc8102cda62 G
1316 1316 /
1317 1317 o 0:426bada5c675 A b-B b-C b-I
1318 1318
1319 1319 $ hg debugobsolete
1320 1320 1fc8102cda6204549f031015641606ccf5513ec3 1473d4b996d1d1b121de6b39fab6a04fbf9d873e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
1321 1321 64a8289d249234b9886244d379f15e6b650b28e3 d11b3456a873daec7c7bc53e5622e8df6d741bd2 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'replace', 'user': 'test'}
1322 1322 f585351a92f85104bff7c284233c338b10eb1df7 7c78f703e465d73102cc8780667ce269c5208a40 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'replace', 'user': 'test'}
1323 1323 48b9aae0607f43ff110d84e6883c151942add5ab 0 {0000000000000000000000000000000000000000} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1324 1324 112478962961147124edd43549aedd1a335e44bf 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1325 1325 08ebfeb61bac6e3f12079de774d285a0d6689eba 0 {426bada5c67598ca65036d57d9e4b64b0c1ce7a0} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1326 1326 26805aba1e600a82e93661149f2313866a221a7b 0 {112478962961147124edd43549aedd1a335e44bf} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'replace', 'user': 'test'}
1327 1327 $ cd ..
1328 1328
1329 1329 Test that obsmarkers are restored even when not using generaldelta
1330 1330
1331 1331 $ hg --config format.usegeneraldelta=no init issue5678
1332 1332 $ cd issue5678
1333 1333 $ cat >> .hg/hgrc <<EOF
1334 1334 > [experimental]
1335 1335 > evolution=true
1336 1336 > EOF
1337 1337 $ echo a > a
1338 1338 $ hg ci -Aqm a
1339 1339 $ hg ci --amend -m a2
1340 1340 $ hg debugobsolete
1341 1341 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 489bac576828490c0bb8d45eac9e5e172e4ec0a8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1342 1342 $ hg strip .
1343 1343 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1344 1344 saved backup bundle to $TESTTMP/issue5678/.hg/strip-backup/489bac576828-bef27e14-backup.hg
1345 1345 $ hg unbundle -q .hg/strip-backup/*
1346 1346 $ hg debugobsolete
1347 1347 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b 489bac576828490c0bb8d45eac9e5e172e4ec0a8 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1348 1348 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now