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