##// END OF EJS Templates
strip: don't use "full" and "partial" to describe bundles...
Martin von Zweigbergk -
r29954:769aee32 default
parent child Browse files
Show More
@@ -1,357 +1,358 b''
1 # repair.py - functions for repository repair for mercurial
1 # repair.py - functions for repository repair for mercurial
2 #
2 #
3 # Copyright 2005, 2006 Chris Mason <mason@suse.com>
3 # Copyright 2005, 2006 Chris Mason <mason@suse.com>
4 # Copyright 2007 Matt Mackall
4 # Copyright 2007 Matt Mackall
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 from __future__ import absolute_import
9 from __future__ import absolute_import
10
10
11 import errno
11 import errno
12 import hashlib
12 import hashlib
13
13
14 from .i18n import _
14 from .i18n import _
15 from .node import short
15 from .node import short
16 from . import (
16 from . import (
17 bundle2,
17 bundle2,
18 changegroup,
18 changegroup,
19 error,
19 error,
20 exchange,
20 exchange,
21 obsolete,
21 obsolete,
22 util,
22 util,
23 )
23 )
24
24
25 def _bundle(repo, bases, heads, node, suffix, compress=True):
25 def _bundle(repo, bases, heads, node, suffix, compress=True):
26 """create a bundle with the specified revisions as a backup"""
26 """create a bundle with the specified revisions as a backup"""
27 cgversion = changegroup.safeversion(repo)
27 cgversion = changegroup.safeversion(repo)
28
28
29 cg = changegroup.changegroupsubset(repo, bases, heads, 'strip',
29 cg = changegroup.changegroupsubset(repo, bases, heads, 'strip',
30 version=cgversion)
30 version=cgversion)
31 backupdir = "strip-backup"
31 backupdir = "strip-backup"
32 vfs = repo.vfs
32 vfs = repo.vfs
33 if not vfs.isdir(backupdir):
33 if not vfs.isdir(backupdir):
34 vfs.mkdir(backupdir)
34 vfs.mkdir(backupdir)
35
35
36 # Include a hash of all the nodes in the filename for uniqueness
36 # Include a hash of all the nodes in the filename for uniqueness
37 allcommits = repo.set('%ln::%ln', bases, heads)
37 allcommits = repo.set('%ln::%ln', bases, heads)
38 allhashes = sorted(c.hex() for c in allcommits)
38 allhashes = sorted(c.hex() for c in allcommits)
39 totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
39 totalhash = hashlib.sha1(''.join(allhashes)).hexdigest()
40 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
40 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
41
41
42 comp = None
42 comp = None
43 if cgversion != '01':
43 if cgversion != '01':
44 bundletype = "HG20"
44 bundletype = "HG20"
45 if compress:
45 if compress:
46 comp = 'BZ'
46 comp = 'BZ'
47 elif compress:
47 elif compress:
48 bundletype = "HG10BZ"
48 bundletype = "HG10BZ"
49 else:
49 else:
50 bundletype = "HG10UN"
50 bundletype = "HG10UN"
51 return bundle2.writebundle(repo.ui, cg, name, bundletype, vfs,
51 return bundle2.writebundle(repo.ui, cg, name, bundletype, vfs,
52 compression=comp)
52 compression=comp)
53
53
54 def _collectfiles(repo, striprev):
54 def _collectfiles(repo, striprev):
55 """find out the filelogs affected by the strip"""
55 """find out the filelogs affected by the strip"""
56 files = set()
56 files = set()
57
57
58 for x in xrange(striprev, len(repo)):
58 for x in xrange(striprev, len(repo)):
59 files.update(repo[x].files())
59 files.update(repo[x].files())
60
60
61 return sorted(files)
61 return sorted(files)
62
62
63 def _collectbrokencsets(repo, files, striprev):
63 def _collectbrokencsets(repo, files, striprev):
64 """return the changesets which will be broken by the truncation"""
64 """return the changesets which will be broken by the truncation"""
65 s = set()
65 s = set()
66 def collectone(revlog):
66 def collectone(revlog):
67 _, brokenset = revlog.getstrippoint(striprev)
67 _, brokenset = revlog.getstrippoint(striprev)
68 s.update([revlog.linkrev(r) for r in brokenset])
68 s.update([revlog.linkrev(r) for r in brokenset])
69
69
70 collectone(repo.manifest)
70 collectone(repo.manifest)
71 for fname in files:
71 for fname in files:
72 collectone(repo.file(fname))
72 collectone(repo.file(fname))
73
73
74 return s
74 return s
75
75
76 def strip(ui, repo, nodelist, backup=True, topic='backup'):
76 def strip(ui, repo, nodelist, backup=True, topic='backup'):
77 # This function operates within a transaction of its own, but does
77 # This function operates within a transaction of its own, but does
78 # not take any lock on the repo.
78 # not take any lock on the repo.
79 # Simple way to maintain backwards compatibility for this
79 # Simple way to maintain backwards compatibility for this
80 # argument.
80 # argument.
81 if backup in ['none', 'strip']:
81 if backup in ['none', 'strip']:
82 backup = False
82 backup = False
83
83
84 repo = repo.unfiltered()
84 repo = repo.unfiltered()
85 repo.destroying()
85 repo.destroying()
86
86
87 cl = repo.changelog
87 cl = repo.changelog
88 # TODO handle undo of merge sets
88 # TODO handle undo of merge sets
89 if isinstance(nodelist, str):
89 if isinstance(nodelist, str):
90 nodelist = [nodelist]
90 nodelist = [nodelist]
91 striplist = [cl.rev(node) for node in nodelist]
91 striplist = [cl.rev(node) for node in nodelist]
92 striprev = min(striplist)
92 striprev = min(striplist)
93
93
94 # Some revisions with rev > striprev may not be descendants of striprev.
94 # Some revisions with rev > striprev may not be descendants of striprev.
95 # We have to find these revisions and put them in a bundle, so that
95 # We have to find these revisions and put them in a bundle, so that
96 # we can restore them after the truncations.
96 # we can restore them after the truncations.
97 # To create the bundle we use repo.changegroupsubset which requires
97 # To create the bundle we use repo.changegroupsubset which requires
98 # the list of heads and bases of the set of interesting revisions.
98 # the list of heads and bases of the set of interesting revisions.
99 # (head = revision in the set that has no descendant in the set;
99 # (head = revision in the set that has no descendant in the set;
100 # base = revision in the set that has no ancestor in the set)
100 # base = revision in the set that has no ancestor in the set)
101 tostrip = set(striplist)
101 tostrip = set(striplist)
102 for rev in striplist:
102 for rev in striplist:
103 for desc in cl.descendants([rev]):
103 for desc in cl.descendants([rev]):
104 tostrip.add(desc)
104 tostrip.add(desc)
105
105
106 files = _collectfiles(repo, striprev)
106 files = _collectfiles(repo, striprev)
107 saverevs = _collectbrokencsets(repo, files, striprev)
107 saverevs = _collectbrokencsets(repo, files, striprev)
108
108
109 # compute heads
109 # compute heads
110 saveheads = set(saverevs)
110 saveheads = set(saverevs)
111 for r in xrange(striprev + 1, len(cl)):
111 for r in xrange(striprev + 1, len(cl)):
112 if r not in tostrip:
112 if r not in tostrip:
113 saverevs.add(r)
113 saverevs.add(r)
114 saveheads.difference_update(cl.parentrevs(r))
114 saveheads.difference_update(cl.parentrevs(r))
115 saveheads.add(r)
115 saveheads.add(r)
116 saveheads = [cl.node(r) for r in saveheads]
116 saveheads = [cl.node(r) for r in saveheads]
117
117
118 # compute base nodes
118 # compute base nodes
119 if saverevs:
119 if saverevs:
120 descendants = set(cl.descendants(saverevs))
120 descendants = set(cl.descendants(saverevs))
121 saverevs.difference_update(descendants)
121 saverevs.difference_update(descendants)
122 savebases = [cl.node(r) for r in saverevs]
122 savebases = [cl.node(r) for r in saverevs]
123 stripbases = [cl.node(r) for r in tostrip]
123 stripbases = [cl.node(r) for r in tostrip]
124
124
125 # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but
125 # For a set s, max(parents(s) - s) is the same as max(heads(::s - s)), but
126 # is much faster
126 # is much faster
127 newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
127 newbmtarget = repo.revs('max(parents(%ld) - (%ld))', tostrip, tostrip)
128 if newbmtarget:
128 if newbmtarget:
129 newbmtarget = repo[newbmtarget.first()].node()
129 newbmtarget = repo[newbmtarget.first()].node()
130 else:
130 else:
131 newbmtarget = '.'
131 newbmtarget = '.'
132
132
133 bm = repo._bookmarks
133 bm = repo._bookmarks
134 updatebm = []
134 updatebm = []
135 for m in bm:
135 for m in bm:
136 rev = repo[bm[m]].rev()
136 rev = repo[bm[m]].rev()
137 if rev in tostrip:
137 if rev in tostrip:
138 updatebm.append(m)
138 updatebm.append(m)
139
139
140 # create a changegroup for all the branches we need to keep
140 # create a changegroup for all the branches we need to keep
141 backupfile = None
141 backupfile = None
142 vfs = repo.vfs
142 vfs = repo.vfs
143 node = nodelist[-1]
143 node = nodelist[-1]
144 if backup:
144 if backup:
145 backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
145 backupfile = _bundle(repo, stripbases, cl.heads(), node, topic)
146 repo.ui.status(_("saved backup bundle to %s\n") %
146 repo.ui.status(_("saved backup bundle to %s\n") %
147 vfs.join(backupfile))
147 vfs.join(backupfile))
148 repo.ui.log("backupbundle", "saved backup bundle to %s\n",
148 repo.ui.log("backupbundle", "saved backup bundle to %s\n",
149 vfs.join(backupfile))
149 vfs.join(backupfile))
150 chgrpfile = None
150 tmpbundlefile = None
151 if saveheads:
151 if saveheads:
152 # do not compress partial bundle if we remove it from disk later
152 # do not compress temporary bundle if we remove it from disk later
153 chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
153 tmpbundlefile = _bundle(repo, savebases, saveheads, node, 'temp',
154 compress=False)
154 compress=False)
155
155
156 mfst = repo.manifest
156 mfst = repo.manifest
157
157
158 curtr = repo.currenttransaction()
158 curtr = repo.currenttransaction()
159 if curtr is not None:
159 if curtr is not None:
160 del curtr # avoid carrying reference to transaction for nothing
160 del curtr # avoid carrying reference to transaction for nothing
161 msg = _('programming error: cannot strip from inside a transaction')
161 msg = _('programming error: cannot strip from inside a transaction')
162 raise error.Abort(msg, hint=_('contact your extension maintainer'))
162 raise error.Abort(msg, hint=_('contact your extension maintainer'))
163
163
164 try:
164 try:
165 with repo.transaction("strip") as tr:
165 with repo.transaction("strip") as tr:
166 offset = len(tr.entries)
166 offset = len(tr.entries)
167
167
168 tr.startgroup()
168 tr.startgroup()
169 cl.strip(striprev, tr)
169 cl.strip(striprev, tr)
170 mfst.strip(striprev, tr)
170 mfst.strip(striprev, tr)
171 if 'treemanifest' in repo.requirements: # safe but unnecessary
171 if 'treemanifest' in repo.requirements: # safe but unnecessary
172 # otherwise
172 # otherwise
173 for unencoded, encoded, size in repo.store.datafiles():
173 for unencoded, encoded, size in repo.store.datafiles():
174 if (unencoded.startswith('meta/') and
174 if (unencoded.startswith('meta/') and
175 unencoded.endswith('00manifest.i')):
175 unencoded.endswith('00manifest.i')):
176 dir = unencoded[5:-12]
176 dir = unencoded[5:-12]
177 repo.manifest.dirlog(dir).strip(striprev, tr)
177 repo.manifest.dirlog(dir).strip(striprev, tr)
178 for fn in files:
178 for fn in files:
179 repo.file(fn).strip(striprev, tr)
179 repo.file(fn).strip(striprev, tr)
180 tr.endgroup()
180 tr.endgroup()
181
181
182 for i in xrange(offset, len(tr.entries)):
182 for i in xrange(offset, len(tr.entries)):
183 file, troffset, ignore = tr.entries[i]
183 file, troffset, ignore = tr.entries[i]
184 repo.svfs(file, 'a').truncate(troffset)
184 repo.svfs(file, 'a').truncate(troffset)
185 if troffset == 0:
185 if troffset == 0:
186 repo.store.markremoved(file)
186 repo.store.markremoved(file)
187
187
188 if chgrpfile:
188 if tmpbundlefile:
189 ui.note(_("adding branch\n"))
189 ui.note(_("adding branch\n"))
190 f = vfs.open(chgrpfile, "rb")
190 f = vfs.open(tmpbundlefile, "rb")
191 gen = exchange.readbundle(ui, f, chgrpfile, vfs)
191 gen = exchange.readbundle(ui, f, tmpbundlefile, vfs)
192 if not repo.ui.verbose:
192 if not repo.ui.verbose:
193 # silence internal shuffling chatter
193 # silence internal shuffling chatter
194 repo.ui.pushbuffer()
194 repo.ui.pushbuffer()
195 if isinstance(gen, bundle2.unbundle20):
195 if isinstance(gen, bundle2.unbundle20):
196 with repo.transaction('strip') as tr:
196 with repo.transaction('strip') as tr:
197 tr.hookargs = {'source': 'strip',
197 tr.hookargs = {'source': 'strip',
198 'url': 'bundle:' + vfs.join(chgrpfile)}
198 'url': 'bundle:' + vfs.join(tmpbundlefile)}
199 bundle2.applybundle(repo, gen, tr, source='strip',
199 bundle2.applybundle(repo, gen, tr, source='strip',
200 url='bundle:' + vfs.join(chgrpfile))
200 url='bundle:' + vfs.join(tmpbundlefile))
201 else:
201 else:
202 gen.apply(repo, 'strip', 'bundle:' + vfs.join(chgrpfile), True)
202 gen.apply(repo, 'strip', 'bundle:' + vfs.join(tmpbundlefile),
203 True)
203 if not repo.ui.verbose:
204 if not repo.ui.verbose:
204 repo.ui.popbuffer()
205 repo.ui.popbuffer()
205 f.close()
206 f.close()
206 repo._phasecache.invalidate()
207 repo._phasecache.invalidate()
207
208
208 for m in updatebm:
209 for m in updatebm:
209 bm[m] = repo[newbmtarget].node()
210 bm[m] = repo[newbmtarget].node()
210 lock = tr = None
211 lock = tr = None
211 try:
212 try:
212 lock = repo.lock()
213 lock = repo.lock()
213 tr = repo.transaction('repair')
214 tr = repo.transaction('repair')
214 bm.recordchange(tr)
215 bm.recordchange(tr)
215 tr.close()
216 tr.close()
216 finally:
217 finally:
217 tr.release()
218 tr.release()
218 lock.release()
219 lock.release()
219
220
220 # remove undo files
221 # remove undo files
221 for undovfs, undofile in repo.undofiles():
222 for undovfs, undofile in repo.undofiles():
222 try:
223 try:
223 undovfs.unlink(undofile)
224 undovfs.unlink(undofile)
224 except OSError as e:
225 except OSError as e:
225 if e.errno != errno.ENOENT:
226 if e.errno != errno.ENOENT:
226 ui.warn(_('error removing %s: %s\n') %
227 ui.warn(_('error removing %s: %s\n') %
227 (undovfs.join(undofile), str(e)))
228 (undovfs.join(undofile), str(e)))
228
229
229 except: # re-raises
230 except: # re-raises
230 if backupfile:
231 if backupfile:
231 ui.warn(_("strip failed, full bundle stored in '%s'\n")
232 ui.warn(_("strip failed, backup bundle stored in '%s'\n")
232 % vfs.join(backupfile))
233 % vfs.join(backupfile))
233 if chgrpfile:
234 if tmpbundlefile:
234 ui.warn(_("strip failed, unrecovered changes stored in '%s'\n")
235 ui.warn(_("strip failed, unrecovered changes stored in '%s'\n")
235 % vfs.join(chgrpfile))
236 % vfs.join(tmpbundlefile))
236 ui.warn(_("(fix the problem, then recover the changesets with "
237 ui.warn(_("(fix the problem, then recover the changesets with "
237 "\"hg unbundle '%s'\")\n") % vfs.join(chgrpfile))
238 "\"hg unbundle '%s'\")\n") % vfs.join(tmpbundlefile))
238 raise
239 raise
239 else:
240 else:
240 if chgrpfile:
241 if tmpbundlefile:
241 # Remove partial backup only if there were no exceptions
242 # Remove temporary bundle only if there were no exceptions
242 vfs.unlink(chgrpfile)
243 vfs.unlink(tmpbundlefile)
243
244
244 repo.destroyed()
245 repo.destroyed()
245
246
246 def rebuildfncache(ui, repo):
247 def rebuildfncache(ui, repo):
247 """Rebuilds the fncache file from repo history.
248 """Rebuilds the fncache file from repo history.
248
249
249 Missing entries will be added. Extra entries will be removed.
250 Missing entries will be added. Extra entries will be removed.
250 """
251 """
251 repo = repo.unfiltered()
252 repo = repo.unfiltered()
252
253
253 if 'fncache' not in repo.requirements:
254 if 'fncache' not in repo.requirements:
254 ui.warn(_('(not rebuilding fncache because repository does not '
255 ui.warn(_('(not rebuilding fncache because repository does not '
255 'support fncache)\n'))
256 'support fncache)\n'))
256 return
257 return
257
258
258 with repo.lock():
259 with repo.lock():
259 fnc = repo.store.fncache
260 fnc = repo.store.fncache
260 # Trigger load of fncache.
261 # Trigger load of fncache.
261 if 'irrelevant' in fnc:
262 if 'irrelevant' in fnc:
262 pass
263 pass
263
264
264 oldentries = set(fnc.entries)
265 oldentries = set(fnc.entries)
265 newentries = set()
266 newentries = set()
266 seenfiles = set()
267 seenfiles = set()
267
268
268 repolen = len(repo)
269 repolen = len(repo)
269 for rev in repo:
270 for rev in repo:
270 ui.progress(_('rebuilding'), rev, total=repolen,
271 ui.progress(_('rebuilding'), rev, total=repolen,
271 unit=_('changesets'))
272 unit=_('changesets'))
272
273
273 ctx = repo[rev]
274 ctx = repo[rev]
274 for f in ctx.files():
275 for f in ctx.files():
275 # This is to minimize I/O.
276 # This is to minimize I/O.
276 if f in seenfiles:
277 if f in seenfiles:
277 continue
278 continue
278 seenfiles.add(f)
279 seenfiles.add(f)
279
280
280 i = 'data/%s.i' % f
281 i = 'data/%s.i' % f
281 d = 'data/%s.d' % f
282 d = 'data/%s.d' % f
282
283
283 if repo.store._exists(i):
284 if repo.store._exists(i):
284 newentries.add(i)
285 newentries.add(i)
285 if repo.store._exists(d):
286 if repo.store._exists(d):
286 newentries.add(d)
287 newentries.add(d)
287
288
288 ui.progress(_('rebuilding'), None)
289 ui.progress(_('rebuilding'), None)
289
290
290 if 'treemanifest' in repo.requirements: # safe but unnecessary otherwise
291 if 'treemanifest' in repo.requirements: # safe but unnecessary otherwise
291 for dir in util.dirs(seenfiles):
292 for dir in util.dirs(seenfiles):
292 i = 'meta/%s/00manifest.i' % dir
293 i = 'meta/%s/00manifest.i' % dir
293 d = 'meta/%s/00manifest.d' % dir
294 d = 'meta/%s/00manifest.d' % dir
294
295
295 if repo.store._exists(i):
296 if repo.store._exists(i):
296 newentries.add(i)
297 newentries.add(i)
297 if repo.store._exists(d):
298 if repo.store._exists(d):
298 newentries.add(d)
299 newentries.add(d)
299
300
300 addcount = len(newentries - oldentries)
301 addcount = len(newentries - oldentries)
301 removecount = len(oldentries - newentries)
302 removecount = len(oldentries - newentries)
302 for p in sorted(oldentries - newentries):
303 for p in sorted(oldentries - newentries):
303 ui.write(_('removing %s\n') % p)
304 ui.write(_('removing %s\n') % p)
304 for p in sorted(newentries - oldentries):
305 for p in sorted(newentries - oldentries):
305 ui.write(_('adding %s\n') % p)
306 ui.write(_('adding %s\n') % p)
306
307
307 if addcount or removecount:
308 if addcount or removecount:
308 ui.write(_('%d items added, %d removed from fncache\n') %
309 ui.write(_('%d items added, %d removed from fncache\n') %
309 (addcount, removecount))
310 (addcount, removecount))
310 fnc.entries = newentries
311 fnc.entries = newentries
311 fnc._dirty = True
312 fnc._dirty = True
312
313
313 with repo.transaction('fncache') as tr:
314 with repo.transaction('fncache') as tr:
314 fnc.write(tr)
315 fnc.write(tr)
315 else:
316 else:
316 ui.write(_('fncache already up to date\n'))
317 ui.write(_('fncache already up to date\n'))
317
318
318 def stripbmrevset(repo, mark):
319 def stripbmrevset(repo, mark):
319 """
320 """
320 The revset to strip when strip is called with -B mark
321 The revset to strip when strip is called with -B mark
321
322
322 Needs to live here so extensions can use it and wrap it even when strip is
323 Needs to live here so extensions can use it and wrap it even when strip is
323 not enabled or not present on a box.
324 not enabled or not present on a box.
324 """
325 """
325 return repo.revs("ancestors(bookmark(%s)) - "
326 return repo.revs("ancestors(bookmark(%s)) - "
326 "ancestors(head() and not bookmark(%s)) - "
327 "ancestors(head() and not bookmark(%s)) - "
327 "ancestors(bookmark() and not bookmark(%s))",
328 "ancestors(bookmark() and not bookmark(%s))",
328 mark, mark, mark)
329 mark, mark, mark)
329
330
330 def deleteobsmarkers(obsstore, indices):
331 def deleteobsmarkers(obsstore, indices):
331 """Delete some obsmarkers from obsstore and return how many were deleted
332 """Delete some obsmarkers from obsstore and return how many were deleted
332
333
333 'indices' is a list of ints which are the indices
334 'indices' is a list of ints which are the indices
334 of the markers to be deleted.
335 of the markers to be deleted.
335
336
336 Every invocation of this function completely rewrites the obsstore file,
337 Every invocation of this function completely rewrites the obsstore file,
337 skipping the markers we want to be removed. The new temporary file is
338 skipping the markers we want to be removed. The new temporary file is
338 created, remaining markers are written there and on .close() this file
339 created, remaining markers are written there and on .close() this file
339 gets atomically renamed to obsstore, thus guaranteeing consistency."""
340 gets atomically renamed to obsstore, thus guaranteeing consistency."""
340 if not indices:
341 if not indices:
341 # we don't want to rewrite the obsstore with the same content
342 # we don't want to rewrite the obsstore with the same content
342 return
343 return
343
344
344 left = []
345 left = []
345 current = obsstore._all
346 current = obsstore._all
346 n = 0
347 n = 0
347 for i, m in enumerate(current):
348 for i, m in enumerate(current):
348 if i in indices:
349 if i in indices:
349 n += 1
350 n += 1
350 continue
351 continue
351 left.append(m)
352 left.append(m)
352
353
353 newobsstorefile = obsstore.svfs('obsstore', 'w', atomictemp=True)
354 newobsstorefile = obsstore.svfs('obsstore', 'w', atomictemp=True)
354 for bytes in obsolete.encodemarkers(left, True, obsstore._version):
355 for bytes in obsolete.encodemarkers(left, True, obsstore._version):
355 newobsstorefile.write(bytes)
356 newobsstorefile.write(bytes)
356 newobsstorefile.close()
357 newobsstorefile.close()
357 return n
358 return n
@@ -1,869 +1,869 b''
1 commit hooks can see env vars
1 commit hooks can see env vars
2 (and post-transaction one are run unlocked)
2 (and post-transaction one are run unlocked)
3
3
4
4
5 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
5 $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
6 > def showargs(ui, repo, hooktype, **kwargs):
6 > def showargs(ui, repo, hooktype, **kwargs):
7 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
7 > ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
8 > EOF
8 > EOF
9
9
10 $ hg init a
10 $ hg init a
11 $ cd a
11 $ cd a
12 $ cat > .hg/hgrc <<EOF
12 $ cat > .hg/hgrc <<EOF
13 > [hooks]
13 > [hooks]
14 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
14 > commit = sh -c "HG_LOCAL= HG_TAG= printenv.py commit"
15 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
15 > commit.b = sh -c "HG_LOCAL= HG_TAG= printenv.py commit.b"
16 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
16 > precommit = sh -c "HG_LOCAL= HG_NODE= HG_TAG= printenv.py precommit"
17 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
17 > pretxncommit = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxncommit"
18 > pretxncommit.tip = hg -q tip
18 > pretxncommit.tip = hg -q tip
19 > pre-identify = printenv.py pre-identify 1
19 > pre-identify = printenv.py pre-identify 1
20 > pre-cat = printenv.py pre-cat
20 > pre-cat = printenv.py pre-cat
21 > post-cat = printenv.py post-cat
21 > post-cat = printenv.py post-cat
22 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
22 > pretxnopen = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnopen"
23 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
23 > pretxnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py pretxnclose"
24 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
24 > txnclose = sh -c "HG_LOCAL= HG_TAG= printenv.py txnclose"
25 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
25 > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
26 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
26 > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= printenv.py txnabort"
27 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
27 > txnclose.checklock = sh -c "hg debuglock > /dev/null"
28 > EOF
28 > EOF
29 $ echo a > a
29 $ echo a > a
30 $ hg add a
30 $ hg add a
31 $ hg commit -m a
31 $ hg commit -m a
32 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
32 precommit hook: HG_PARENT1=0000000000000000000000000000000000000000
33 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
33 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
34 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
34 pretxncommit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000 HG_PENDING=$TESTTMP/a
35 0:cb9a9f314b8b
35 0:cb9a9f314b8b
36 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
36 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
37 txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
37 txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
38 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
38 commit hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
39 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
39 commit.b hook: HG_NODE=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PARENT1=0000000000000000000000000000000000000000
40
40
41 $ hg clone . ../b
41 $ hg clone . ../b
42 updating to branch default
42 updating to branch default
43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
44 $ cd ../b
44 $ cd ../b
45
45
46 changegroup hooks can see env vars
46 changegroup hooks can see env vars
47
47
48 $ cat > .hg/hgrc <<EOF
48 $ cat > .hg/hgrc <<EOF
49 > [hooks]
49 > [hooks]
50 > prechangegroup = printenv.py prechangegroup
50 > prechangegroup = printenv.py prechangegroup
51 > changegroup = printenv.py changegroup
51 > changegroup = printenv.py changegroup
52 > incoming = printenv.py incoming
52 > incoming = printenv.py incoming
53 > EOF
53 > EOF
54
54
55 pretxncommit and commit hooks can see both parents of merge
55 pretxncommit and commit hooks can see both parents of merge
56
56
57 $ cd ../a
57 $ cd ../a
58 $ echo b >> a
58 $ echo b >> a
59 $ hg commit -m a1 -d "1 0"
59 $ hg commit -m a1 -d "1 0"
60 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
60 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
61 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
61 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
62 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
62 pretxncommit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
63 1:ab228980c14d
63 1:ab228980c14d
64 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
64 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
65 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
65 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
66 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
66 commit hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
67 commit.b hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
68 $ hg update -C 0
68 $ hg update -C 0
69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
69 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70 $ echo b > b
70 $ echo b > b
71 $ hg add b
71 $ hg add b
72 $ hg commit -m b -d '1 0'
72 $ hg commit -m b -d '1 0'
73 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
73 precommit hook: HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
74 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
74 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
75 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
75 pretxncommit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b HG_PENDING=$TESTTMP/a
76 2:ee9deb46ab31
76 2:ee9deb46ab31
77 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
77 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
78 created new head
78 created new head
79 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
79 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
80 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
80 commit hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
81 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
81 commit.b hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT1=cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b
82 $ hg merge 1
82 $ hg merge 1
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
83 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
84 (branch merge, don't forget to commit)
84 (branch merge, don't forget to commit)
85 $ hg commit -m merge -d '2 0'
85 $ hg commit -m merge -d '2 0'
86 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
86 precommit hook: HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
87 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
87 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
88 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
88 pretxncommit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd HG_PENDING=$TESTTMP/a
89 3:07f3376c1e65
89 3:07f3376c1e65
90 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
90 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
91 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
91 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
92 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
92 commit hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
93 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
93 commit.b hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PARENT1=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_PARENT2=ab228980c14deea8b9555d91c9581127383e40fd
94
94
95 test generic hooks
95 test generic hooks
96
96
97 $ hg id
97 $ hg id
98 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
98 pre-identify hook: HG_ARGS=id HG_OPTS={'bookmarks': None, 'branch': None, 'id': None, 'insecure': None, 'num': None, 'remotecmd': '', 'rev': '', 'ssh': '', 'tags': None} HG_PATS=[]
99 abort: pre-identify hook exited with status 1
99 abort: pre-identify hook exited with status 1
100 [255]
100 [255]
101 $ hg cat b
101 $ hg cat b
102 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
102 pre-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b']
103 b
103 b
104 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
104 post-cat hook: HG_ARGS=cat b HG_OPTS={'decode': None, 'exclude': [], 'include': [], 'output': '', 'rev': ''} HG_PATS=['b'] HG_RESULT=0
105
105
106 $ cd ../b
106 $ cd ../b
107 $ hg pull ../a
107 $ hg pull ../a
108 pulling from ../a
108 pulling from ../a
109 searching for changes
109 searching for changes
110 prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
110 prechangegroup hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
111 adding changesets
111 adding changesets
112 adding manifests
112 adding manifests
113 adding file changes
113 adding file changes
114 added 3 changesets with 2 changes to 2 files
114 added 3 changesets with 2 changes to 2 files
115 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
115 changegroup hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_NODE_LAST=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
116 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
116 incoming hook: HG_NODE=ab228980c14deea8b9555d91c9581127383e40fd HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
117 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
117 incoming hook: HG_NODE=ee9deb46ab31e4cc3310f3cf0c3d668e4d8fffc2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
118 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
118 incoming hook: HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
119 (run 'hg update' to get a working copy)
119 (run 'hg update' to get a working copy)
120
120
121 tag hooks can see env vars
121 tag hooks can see env vars
122
122
123 $ cd ../a
123 $ cd ../a
124 $ cat >> .hg/hgrc <<EOF
124 $ cat >> .hg/hgrc <<EOF
125 > pretag = printenv.py pretag
125 > pretag = printenv.py pretag
126 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
126 > tag = sh -c "HG_PARENT1= HG_PARENT2= printenv.py tag"
127 > EOF
127 > EOF
128 $ hg tag -d '3 0' a
128 $ hg tag -d '3 0' a
129 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
129 pretag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
130 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
130 precommit hook: HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
131 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
131 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
132 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
132 pretxncommit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2 HG_PENDING=$TESTTMP/a
133 4:539e4b31b6dc
133 4:539e4b31b6dc
134 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
134 pretxnclose hook: HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
135 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
135 tag hook: HG_LOCAL=0 HG_NODE=07f3376c1e655977439df2a814e3cc14b27abac2 HG_TAG=a
136 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
136 txnclose hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
137 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
137 commit hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
138 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
138 commit.b hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PARENT1=07f3376c1e655977439df2a814e3cc14b27abac2
139 $ hg tag -l la
139 $ hg tag -l la
140 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
140 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
141 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
141 tag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=la
142
142
143 pretag hook can forbid tagging
143 pretag hook can forbid tagging
144
144
145 $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc
145 $ echo "pretag.forbid = printenv.py pretag.forbid 1" >> .hg/hgrc
146 $ hg tag -d '4 0' fa
146 $ hg tag -d '4 0' fa
147 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
147 pretag hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
148 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
148 pretag.forbid hook: HG_LOCAL=0 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fa
149 abort: pretag.forbid hook exited with status 1
149 abort: pretag.forbid hook exited with status 1
150 [255]
150 [255]
151 $ hg tag -l fla
151 $ hg tag -l fla
152 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
152 pretag hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
153 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
153 pretag.forbid hook: HG_LOCAL=1 HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_TAG=fla
154 abort: pretag.forbid hook exited with status 1
154 abort: pretag.forbid hook exited with status 1
155 [255]
155 [255]
156
156
157 pretxncommit hook can see changeset, can roll back txn, changeset no
157 pretxncommit hook can see changeset, can roll back txn, changeset no
158 more there after
158 more there after
159
159
160 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
160 $ echo "pretxncommit.forbid0 = hg tip -q" >> .hg/hgrc
161 $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc
161 $ echo "pretxncommit.forbid1 = printenv.py pretxncommit.forbid 1" >> .hg/hgrc
162 $ echo z > z
162 $ echo z > z
163 $ hg add z
163 $ hg add z
164 $ hg -q tip
164 $ hg -q tip
165 4:539e4b31b6dc
165 4:539e4b31b6dc
166 $ hg commit -m 'fail' -d '4 0'
166 $ hg commit -m 'fail' -d '4 0'
167 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
167 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
168 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
168 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
169 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
169 pretxncommit hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
170 5:6f611f8018c1
170 5:6f611f8018c1
171 5:6f611f8018c1
171 5:6f611f8018c1
172 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
172 pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
173 transaction abort!
173 transaction abort!
174 txnabort python hook: txnid,txnname
174 txnabort python hook: txnid,txnname
175 txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
175 txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
176 rollback completed
176 rollback completed
177 abort: pretxncommit.forbid1 hook exited with status 1
177 abort: pretxncommit.forbid1 hook exited with status 1
178 [255]
178 [255]
179 $ hg -q tip
179 $ hg -q tip
180 4:539e4b31b6dc
180 4:539e4b31b6dc
181
181
182 (Check that no 'changelog.i.a' file were left behind)
182 (Check that no 'changelog.i.a' file were left behind)
183
183
184 $ ls -1 .hg/store/
184 $ ls -1 .hg/store/
185 00changelog.i
185 00changelog.i
186 00manifest.i
186 00manifest.i
187 data
187 data
188 fncache
188 fncache
189 journal.phaseroots
189 journal.phaseroots
190 phaseroots
190 phaseroots
191 undo
191 undo
192 undo.backup.fncache
192 undo.backup.fncache
193 undo.backupfiles
193 undo.backupfiles
194 undo.phaseroots
194 undo.phaseroots
195
195
196
196
197 precommit hook can prevent commit
197 precommit hook can prevent commit
198
198
199 $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc
199 $ echo "precommit.forbid = printenv.py precommit.forbid 1" >> .hg/hgrc
200 $ hg commit -m 'fail' -d '4 0'
200 $ hg commit -m 'fail' -d '4 0'
201 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
201 precommit hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
202 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
202 precommit.forbid hook: HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10
203 abort: precommit.forbid hook exited with status 1
203 abort: precommit.forbid hook exited with status 1
204 [255]
204 [255]
205 $ hg -q tip
205 $ hg -q tip
206 4:539e4b31b6dc
206 4:539e4b31b6dc
207
207
208 preupdate hook can prevent update
208 preupdate hook can prevent update
209
209
210 $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc
210 $ echo "preupdate = printenv.py preupdate" >> .hg/hgrc
211 $ hg update 1
211 $ hg update 1
212 preupdate hook: HG_PARENT1=ab228980c14d
212 preupdate hook: HG_PARENT1=ab228980c14d
213 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
213 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
214
214
215 update hook
215 update hook
216
216
217 $ echo "update = printenv.py update" >> .hg/hgrc
217 $ echo "update = printenv.py update" >> .hg/hgrc
218 $ hg update
218 $ hg update
219 preupdate hook: HG_PARENT1=539e4b31b6dc
219 preupdate hook: HG_PARENT1=539e4b31b6dc
220 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
220 update hook: HG_ERROR=0 HG_PARENT1=539e4b31b6dc
221 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
221 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
222
222
223 pushkey hook
223 pushkey hook
224
224
225 $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc
225 $ echo "pushkey = printenv.py pushkey" >> .hg/hgrc
226 $ cd ../b
226 $ cd ../b
227 $ hg bookmark -r null foo
227 $ hg bookmark -r null foo
228 $ hg push -B foo ../a
228 $ hg push -B foo ../a
229 pushing to ../a
229 pushing to ../a
230 searching for changes
230 searching for changes
231 no changes found
231 no changes found
232 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
232 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
233 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=file:$TESTTMP/a (glob)
233 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_PENDING=$TESTTMP/a HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=file:$TESTTMP/a (glob)
234 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
234 pushkey hook: HG_KEY=foo HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_RET=1
235 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=file:$TESTTMP/a (glob)
235 txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=file:$TESTTMP/a (glob)
236 exporting bookmark foo
236 exporting bookmark foo
237 [1]
237 [1]
238 $ cd ../a
238 $ cd ../a
239
239
240 listkeys hook
240 listkeys hook
241
241
242 $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc
242 $ echo "listkeys = printenv.py listkeys" >> .hg/hgrc
243 $ hg bookmark -r null bar
243 $ hg bookmark -r null bar
244 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
244 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
245 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
245 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
246 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
246 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
247 $ cd ../b
247 $ cd ../b
248 $ hg pull -B bar ../a
248 $ hg pull -B bar ../a
249 pulling from ../a
249 pulling from ../a
250 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
250 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
251 no changes found
251 no changes found
252 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
252 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
253 adding remote bookmark bar
253 adding remote bookmark bar
254 $ cd ../a
254 $ cd ../a
255
255
256 test that prepushkey can prevent incoming keys
256 test that prepushkey can prevent incoming keys
257
257
258 $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc
258 $ echo "prepushkey = printenv.py prepushkey.forbid 1" >> .hg/hgrc
259 $ cd ../b
259 $ cd ../b
260 $ hg bookmark -r null baz
260 $ hg bookmark -r null baz
261 $ hg push -B baz ../a
261 $ hg push -B baz ../a
262 pushing to ../a
262 pushing to ../a
263 searching for changes
263 searching for changes
264 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
264 listkeys hook: HG_NAMESPACE=phases HG_VALUES={'cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b': '1', 'publishing': 'True'}
265 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
265 listkeys hook: HG_NAMESPACE=bookmarks HG_VALUES={'bar': '0000000000000000000000000000000000000000', 'foo': '0000000000000000000000000000000000000000'}
266 no changes found
266 no changes found
267 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
267 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=push (glob)
268 prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
268 prepushkey.forbid hook: HG_BUNDLE2=1 HG_KEY=baz HG_NAMESPACE=bookmarks HG_NEW=0000000000000000000000000000000000000000 HG_SOURCE=push HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
269 pushkey-abort: prepushkey hook exited with status 1
269 pushkey-abort: prepushkey hook exited with status 1
270 abort: exporting bookmark baz failed!
270 abort: exporting bookmark baz failed!
271 [255]
271 [255]
272 $ cd ../a
272 $ cd ../a
273
273
274 test that prelistkeys can prevent listing keys
274 test that prelistkeys can prevent listing keys
275
275
276 $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc
276 $ echo "prelistkeys = printenv.py prelistkeys.forbid 1" >> .hg/hgrc
277 $ hg bookmark -r null quux
277 $ hg bookmark -r null quux
278 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
278 pretxnopen hook: HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
279 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
279 pretxnclose hook: HG_BOOKMARK_MOVED=1 HG_PENDING=$TESTTMP/a HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
280 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
280 txnclose hook: HG_BOOKMARK_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=bookmark (glob)
281 $ cd ../b
281 $ cd ../b
282 $ hg pull -B quux ../a
282 $ hg pull -B quux ../a
283 pulling from ../a
283 pulling from ../a
284 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
284 prelistkeys.forbid hook: HG_NAMESPACE=bookmarks
285 abort: prelistkeys hook exited with status 1
285 abort: prelistkeys hook exited with status 1
286 [255]
286 [255]
287 $ cd ../a
287 $ cd ../a
288 $ rm .hg/hgrc
288 $ rm .hg/hgrc
289
289
290 prechangegroup hook can prevent incoming changes
290 prechangegroup hook can prevent incoming changes
291
291
292 $ cd ../b
292 $ cd ../b
293 $ hg -q tip
293 $ hg -q tip
294 3:07f3376c1e65
294 3:07f3376c1e65
295 $ cat > .hg/hgrc <<EOF
295 $ cat > .hg/hgrc <<EOF
296 > [hooks]
296 > [hooks]
297 > prechangegroup.forbid = printenv.py prechangegroup.forbid 1
297 > prechangegroup.forbid = printenv.py prechangegroup.forbid 1
298 > EOF
298 > EOF
299 $ hg pull ../a
299 $ hg pull ../a
300 pulling from ../a
300 pulling from ../a
301 searching for changes
301 searching for changes
302 prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
302 prechangegroup.forbid hook: HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
303 abort: prechangegroup.forbid hook exited with status 1
303 abort: prechangegroup.forbid hook exited with status 1
304 [255]
304 [255]
305
305
306 pretxnchangegroup hook can see incoming changes, can roll back txn,
306 pretxnchangegroup hook can see incoming changes, can roll back txn,
307 incoming changes no longer there after
307 incoming changes no longer there after
308
308
309 $ cat > .hg/hgrc <<EOF
309 $ cat > .hg/hgrc <<EOF
310 > [hooks]
310 > [hooks]
311 > pretxnchangegroup.forbid0 = hg tip -q
311 > pretxnchangegroup.forbid0 = hg tip -q
312 > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1
312 > pretxnchangegroup.forbid1 = printenv.py pretxnchangegroup.forbid 1
313 > EOF
313 > EOF
314 $ hg pull ../a
314 $ hg pull ../a
315 pulling from ../a
315 pulling from ../a
316 searching for changes
316 searching for changes
317 adding changesets
317 adding changesets
318 adding manifests
318 adding manifests
319 adding file changes
319 adding file changes
320 added 1 changesets with 1 changes to 1 files
320 added 1 changesets with 1 changes to 1 files
321 4:539e4b31b6dc
321 4:539e4b31b6dc
322 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
322 pretxnchangegroup.forbid hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_NODE_LAST=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/b HG_SOURCE=pull HG_TXNID=TXN:* HG_URL=file:$TESTTMP/a (glob)
323 transaction abort!
323 transaction abort!
324 rollback completed
324 rollback completed
325 abort: pretxnchangegroup.forbid1 hook exited with status 1
325 abort: pretxnchangegroup.forbid1 hook exited with status 1
326 [255]
326 [255]
327 $ hg -q tip
327 $ hg -q tip
328 3:07f3376c1e65
328 3:07f3376c1e65
329
329
330 outgoing hooks can see env vars
330 outgoing hooks can see env vars
331
331
332 $ rm .hg/hgrc
332 $ rm .hg/hgrc
333 $ cat > ../a/.hg/hgrc <<EOF
333 $ cat > ../a/.hg/hgrc <<EOF
334 > [hooks]
334 > [hooks]
335 > preoutgoing = printenv.py preoutgoing
335 > preoutgoing = printenv.py preoutgoing
336 > outgoing = printenv.py outgoing
336 > outgoing = printenv.py outgoing
337 > EOF
337 > EOF
338 $ hg pull ../a
338 $ hg pull ../a
339 pulling from ../a
339 pulling from ../a
340 searching for changes
340 searching for changes
341 preoutgoing hook: HG_SOURCE=pull
341 preoutgoing hook: HG_SOURCE=pull
342 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
342 outgoing hook: HG_NODE=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_SOURCE=pull
343 adding changesets
343 adding changesets
344 adding manifests
344 adding manifests
345 adding file changes
345 adding file changes
346 added 1 changesets with 1 changes to 1 files
346 added 1 changesets with 1 changes to 1 files
347 adding remote bookmark quux
347 adding remote bookmark quux
348 (run 'hg update' to get a working copy)
348 (run 'hg update' to get a working copy)
349 $ hg rollback
349 $ hg rollback
350 repository tip rolled back to revision 3 (undo pull)
350 repository tip rolled back to revision 3 (undo pull)
351
351
352 preoutgoing hook can prevent outgoing changes
352 preoutgoing hook can prevent outgoing changes
353
353
354 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc
354 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> ../a/.hg/hgrc
355 $ hg pull ../a
355 $ hg pull ../a
356 pulling from ../a
356 pulling from ../a
357 searching for changes
357 searching for changes
358 preoutgoing hook: HG_SOURCE=pull
358 preoutgoing hook: HG_SOURCE=pull
359 preoutgoing.forbid hook: HG_SOURCE=pull
359 preoutgoing.forbid hook: HG_SOURCE=pull
360 abort: preoutgoing.forbid hook exited with status 1
360 abort: preoutgoing.forbid hook exited with status 1
361 [255]
361 [255]
362
362
363 outgoing hooks work for local clones
363 outgoing hooks work for local clones
364
364
365 $ cd ..
365 $ cd ..
366 $ cat > a/.hg/hgrc <<EOF
366 $ cat > a/.hg/hgrc <<EOF
367 > [hooks]
367 > [hooks]
368 > preoutgoing = printenv.py preoutgoing
368 > preoutgoing = printenv.py preoutgoing
369 > outgoing = printenv.py outgoing
369 > outgoing = printenv.py outgoing
370 > EOF
370 > EOF
371 $ hg clone a c
371 $ hg clone a c
372 preoutgoing hook: HG_SOURCE=clone
372 preoutgoing hook: HG_SOURCE=clone
373 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
373 outgoing hook: HG_NODE=0000000000000000000000000000000000000000 HG_SOURCE=clone
374 updating to branch default
374 updating to branch default
375 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
375 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
376 $ rm -rf c
376 $ rm -rf c
377
377
378 preoutgoing hook can prevent outgoing changes for local clones
378 preoutgoing hook can prevent outgoing changes for local clones
379
379
380 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc
380 $ echo "preoutgoing.forbid = printenv.py preoutgoing.forbid 1" >> a/.hg/hgrc
381 $ hg clone a zzz
381 $ hg clone a zzz
382 preoutgoing hook: HG_SOURCE=clone
382 preoutgoing hook: HG_SOURCE=clone
383 preoutgoing.forbid hook: HG_SOURCE=clone
383 preoutgoing.forbid hook: HG_SOURCE=clone
384 abort: preoutgoing.forbid hook exited with status 1
384 abort: preoutgoing.forbid hook exited with status 1
385 [255]
385 [255]
386
386
387 $ cd "$TESTTMP/b"
387 $ cd "$TESTTMP/b"
388
388
389 $ cat > hooktests.py <<EOF
389 $ cat > hooktests.py <<EOF
390 > from mercurial import error
390 > from mercurial import error
391 >
391 >
392 > uncallable = 0
392 > uncallable = 0
393 >
393 >
394 > def printargs(args):
394 > def printargs(args):
395 > args.pop('ui', None)
395 > args.pop('ui', None)
396 > args.pop('repo', None)
396 > args.pop('repo', None)
397 > a = list(args.items())
397 > a = list(args.items())
398 > a.sort()
398 > a.sort()
399 > print 'hook args:'
399 > print 'hook args:'
400 > for k, v in a:
400 > for k, v in a:
401 > print ' ', k, v
401 > print ' ', k, v
402 >
402 >
403 > def passhook(**args):
403 > def passhook(**args):
404 > printargs(args)
404 > printargs(args)
405 >
405 >
406 > def failhook(**args):
406 > def failhook(**args):
407 > printargs(args)
407 > printargs(args)
408 > return True
408 > return True
409 >
409 >
410 > class LocalException(Exception):
410 > class LocalException(Exception):
411 > pass
411 > pass
412 >
412 >
413 > def raisehook(**args):
413 > def raisehook(**args):
414 > raise LocalException('exception from hook')
414 > raise LocalException('exception from hook')
415 >
415 >
416 > def aborthook(**args):
416 > def aborthook(**args):
417 > raise error.Abort('raise abort from hook')
417 > raise error.Abort('raise abort from hook')
418 >
418 >
419 > def brokenhook(**args):
419 > def brokenhook(**args):
420 > return 1 + {}
420 > return 1 + {}
421 >
421 >
422 > def verbosehook(ui, **args):
422 > def verbosehook(ui, **args):
423 > ui.note('verbose output from hook\n')
423 > ui.note('verbose output from hook\n')
424 >
424 >
425 > def printtags(ui, repo, **args):
425 > def printtags(ui, repo, **args):
426 > print sorted(repo.tags())
426 > print sorted(repo.tags())
427 >
427 >
428 > class container:
428 > class container:
429 > unreachable = 1
429 > unreachable = 1
430 > EOF
430 > EOF
431
431
432 $ cat > syntaxerror.py << EOF
432 $ cat > syntaxerror.py << EOF
433 > (foo
433 > (foo
434 > EOF
434 > EOF
435
435
436 test python hooks
436 test python hooks
437
437
438 #if windows
438 #if windows
439 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
439 $ PYTHONPATH="$TESTTMP/b;$PYTHONPATH"
440 #else
440 #else
441 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
441 $ PYTHONPATH="$TESTTMP/b:$PYTHONPATH"
442 #endif
442 #endif
443 $ export PYTHONPATH
443 $ export PYTHONPATH
444
444
445 $ echo '[hooks]' > ../a/.hg/hgrc
445 $ echo '[hooks]' > ../a/.hg/hgrc
446 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
446 $ echo 'preoutgoing.broken = python:hooktests.brokenhook' >> ../a/.hg/hgrc
447 $ hg pull ../a 2>&1 | grep 'raised an exception'
447 $ hg pull ../a 2>&1 | grep 'raised an exception'
448 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
448 error: preoutgoing.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
449
449
450 $ echo '[hooks]' > ../a/.hg/hgrc
450 $ echo '[hooks]' > ../a/.hg/hgrc
451 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
451 $ echo 'preoutgoing.raise = python:hooktests.raisehook' >> ../a/.hg/hgrc
452 $ hg pull ../a 2>&1 | grep 'raised an exception'
452 $ hg pull ../a 2>&1 | grep 'raised an exception'
453 error: preoutgoing.raise hook raised an exception: exception from hook
453 error: preoutgoing.raise hook raised an exception: exception from hook
454
454
455 $ echo '[hooks]' > ../a/.hg/hgrc
455 $ echo '[hooks]' > ../a/.hg/hgrc
456 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
456 $ echo 'preoutgoing.abort = python:hooktests.aborthook' >> ../a/.hg/hgrc
457 $ hg pull ../a
457 $ hg pull ../a
458 pulling from ../a
458 pulling from ../a
459 searching for changes
459 searching for changes
460 error: preoutgoing.abort hook failed: raise abort from hook
460 error: preoutgoing.abort hook failed: raise abort from hook
461 abort: raise abort from hook
461 abort: raise abort from hook
462 [255]
462 [255]
463
463
464 $ echo '[hooks]' > ../a/.hg/hgrc
464 $ echo '[hooks]' > ../a/.hg/hgrc
465 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
465 $ echo 'preoutgoing.fail = python:hooktests.failhook' >> ../a/.hg/hgrc
466 $ hg pull ../a
466 $ hg pull ../a
467 pulling from ../a
467 pulling from ../a
468 searching for changes
468 searching for changes
469 hook args:
469 hook args:
470 hooktype preoutgoing
470 hooktype preoutgoing
471 source pull
471 source pull
472 abort: preoutgoing.fail hook failed
472 abort: preoutgoing.fail hook failed
473 [255]
473 [255]
474
474
475 $ echo '[hooks]' > ../a/.hg/hgrc
475 $ echo '[hooks]' > ../a/.hg/hgrc
476 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
476 $ echo 'preoutgoing.uncallable = python:hooktests.uncallable' >> ../a/.hg/hgrc
477 $ hg pull ../a
477 $ hg pull ../a
478 pulling from ../a
478 pulling from ../a
479 searching for changes
479 searching for changes
480 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
480 abort: preoutgoing.uncallable hook is invalid: "hooktests.uncallable" is not callable
481 [255]
481 [255]
482
482
483 $ echo '[hooks]' > ../a/.hg/hgrc
483 $ echo '[hooks]' > ../a/.hg/hgrc
484 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
484 $ echo 'preoutgoing.nohook = python:hooktests.nohook' >> ../a/.hg/hgrc
485 $ hg pull ../a
485 $ hg pull ../a
486 pulling from ../a
486 pulling from ../a
487 searching for changes
487 searching for changes
488 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
488 abort: preoutgoing.nohook hook is invalid: "hooktests.nohook" is not defined
489 [255]
489 [255]
490
490
491 $ echo '[hooks]' > ../a/.hg/hgrc
491 $ echo '[hooks]' > ../a/.hg/hgrc
492 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
492 $ echo 'preoutgoing.nomodule = python:nomodule' >> ../a/.hg/hgrc
493 $ hg pull ../a
493 $ hg pull ../a
494 pulling from ../a
494 pulling from ../a
495 searching for changes
495 searching for changes
496 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
496 abort: preoutgoing.nomodule hook is invalid: "nomodule" not in a module
497 [255]
497 [255]
498
498
499 $ echo '[hooks]' > ../a/.hg/hgrc
499 $ echo '[hooks]' > ../a/.hg/hgrc
500 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
500 $ echo 'preoutgoing.badmodule = python:nomodule.nowhere' >> ../a/.hg/hgrc
501 $ hg pull ../a
501 $ hg pull ../a
502 pulling from ../a
502 pulling from ../a
503 searching for changes
503 searching for changes
504 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
504 abort: preoutgoing.badmodule hook is invalid: import of "nomodule" failed
505 (run with --traceback for stack trace)
505 (run with --traceback for stack trace)
506 [255]
506 [255]
507
507
508 $ echo '[hooks]' > ../a/.hg/hgrc
508 $ echo '[hooks]' > ../a/.hg/hgrc
509 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
509 $ echo 'preoutgoing.unreachable = python:hooktests.container.unreachable' >> ../a/.hg/hgrc
510 $ hg pull ../a
510 $ hg pull ../a
511 pulling from ../a
511 pulling from ../a
512 searching for changes
512 searching for changes
513 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
513 abort: preoutgoing.unreachable hook is invalid: import of "hooktests.container" failed
514 (run with --traceback for stack trace)
514 (run with --traceback for stack trace)
515 [255]
515 [255]
516
516
517 $ echo '[hooks]' > ../a/.hg/hgrc
517 $ echo '[hooks]' > ../a/.hg/hgrc
518 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
518 $ echo 'preoutgoing.syntaxerror = python:syntaxerror.syntaxerror' >> ../a/.hg/hgrc
519 $ hg pull ../a
519 $ hg pull ../a
520 pulling from ../a
520 pulling from ../a
521 searching for changes
521 searching for changes
522 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
522 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
523 (run with --traceback for stack trace)
523 (run with --traceback for stack trace)
524 [255]
524 [255]
525
525
526 The second egrep is to filter out lines like ' ^', which are slightly
526 The second egrep is to filter out lines like ' ^', which are slightly
527 different between Python 2.6 and Python 2.7.
527 different between Python 2.6 and Python 2.7.
528 $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
528 $ hg pull ../a --traceback 2>&1 | egrep -v '^( +File| [_a-zA-Z*(])' | egrep -v '^( )+(\^)?$'
529 pulling from ../a
529 pulling from ../a
530 searching for changes
530 searching for changes
531 exception from first failed import attempt:
531 exception from first failed import attempt:
532 Traceback (most recent call last):
532 Traceback (most recent call last):
533 SyntaxError: * (glob)
533 SyntaxError: * (glob)
534 exception from second failed import attempt:
534 exception from second failed import attempt:
535 Traceback (most recent call last):
535 Traceback (most recent call last):
536 ImportError: No module named hgext_syntaxerror
536 ImportError: No module named hgext_syntaxerror
537 Traceback (most recent call last):
537 Traceback (most recent call last):
538 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
538 HookLoadError: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
539 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
539 abort: preoutgoing.syntaxerror hook is invalid: import of "syntaxerror" failed
540
540
541 $ echo '[hooks]' > ../a/.hg/hgrc
541 $ echo '[hooks]' > ../a/.hg/hgrc
542 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
542 $ echo 'preoutgoing.pass = python:hooktests.passhook' >> ../a/.hg/hgrc
543 $ hg pull ../a
543 $ hg pull ../a
544 pulling from ../a
544 pulling from ../a
545 searching for changes
545 searching for changes
546 hook args:
546 hook args:
547 hooktype preoutgoing
547 hooktype preoutgoing
548 source pull
548 source pull
549 adding changesets
549 adding changesets
550 adding manifests
550 adding manifests
551 adding file changes
551 adding file changes
552 added 1 changesets with 1 changes to 1 files
552 added 1 changesets with 1 changes to 1 files
553 adding remote bookmark quux
553 adding remote bookmark quux
554 (run 'hg update' to get a working copy)
554 (run 'hg update' to get a working copy)
555
555
556 post- python hooks that fail to *run* don't cause an abort
556 post- python hooks that fail to *run* don't cause an abort
557 $ rm ../a/.hg/hgrc
557 $ rm ../a/.hg/hgrc
558 $ echo '[hooks]' > .hg/hgrc
558 $ echo '[hooks]' > .hg/hgrc
559 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
559 $ echo 'post-pull.broken = python:hooktests.brokenhook' >> .hg/hgrc
560 $ hg pull ../a
560 $ hg pull ../a
561 pulling from ../a
561 pulling from ../a
562 searching for changes
562 searching for changes
563 no changes found
563 no changes found
564 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
564 error: post-pull.broken hook raised an exception: unsupported operand type(s) for +: 'int' and 'dict'
565 (run with --traceback for stack trace)
565 (run with --traceback for stack trace)
566
566
567 but post- python hooks that fail to *load* do
567 but post- python hooks that fail to *load* do
568 $ echo '[hooks]' > .hg/hgrc
568 $ echo '[hooks]' > .hg/hgrc
569 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
569 $ echo 'post-pull.nomodule = python:nomodule' >> .hg/hgrc
570 $ hg pull ../a
570 $ hg pull ../a
571 pulling from ../a
571 pulling from ../a
572 searching for changes
572 searching for changes
573 no changes found
573 no changes found
574 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
574 abort: post-pull.nomodule hook is invalid: "nomodule" not in a module
575 [255]
575 [255]
576
576
577 $ echo '[hooks]' > .hg/hgrc
577 $ echo '[hooks]' > .hg/hgrc
578 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
578 $ echo 'post-pull.badmodule = python:nomodule.nowhere' >> .hg/hgrc
579 $ hg pull ../a
579 $ hg pull ../a
580 pulling from ../a
580 pulling from ../a
581 searching for changes
581 searching for changes
582 no changes found
582 no changes found
583 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
583 abort: post-pull.badmodule hook is invalid: import of "nomodule" failed
584 (run with --traceback for stack trace)
584 (run with --traceback for stack trace)
585 [255]
585 [255]
586
586
587 $ echo '[hooks]' > .hg/hgrc
587 $ echo '[hooks]' > .hg/hgrc
588 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
588 $ echo 'post-pull.nohook = python:hooktests.nohook' >> .hg/hgrc
589 $ hg pull ../a
589 $ hg pull ../a
590 pulling from ../a
590 pulling from ../a
591 searching for changes
591 searching for changes
592 no changes found
592 no changes found
593 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
593 abort: post-pull.nohook hook is invalid: "hooktests.nohook" is not defined
594 [255]
594 [255]
595
595
596 make sure --traceback works
596 make sure --traceback works
597
597
598 $ echo '[hooks]' > .hg/hgrc
598 $ echo '[hooks]' > .hg/hgrc
599 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
599 $ echo 'commit.abort = python:hooktests.aborthook' >> .hg/hgrc
600
600
601 $ echo aa > a
601 $ echo aa > a
602 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
602 $ hg --traceback commit -d '0 0' -ma 2>&1 | grep '^Traceback'
603 Traceback (most recent call last):
603 Traceback (most recent call last):
604
604
605 $ cd ..
605 $ cd ..
606 $ hg init c
606 $ hg init c
607 $ cd c
607 $ cd c
608
608
609 $ cat > hookext.py <<EOF
609 $ cat > hookext.py <<EOF
610 > def autohook(**args):
610 > def autohook(**args):
611 > print "Automatically installed hook"
611 > print "Automatically installed hook"
612 >
612 >
613 > def reposetup(ui, repo):
613 > def reposetup(ui, repo):
614 > repo.ui.setconfig("hooks", "commit.auto", autohook)
614 > repo.ui.setconfig("hooks", "commit.auto", autohook)
615 > EOF
615 > EOF
616 $ echo '[extensions]' >> .hg/hgrc
616 $ echo '[extensions]' >> .hg/hgrc
617 $ echo 'hookext = hookext.py' >> .hg/hgrc
617 $ echo 'hookext = hookext.py' >> .hg/hgrc
618
618
619 $ touch foo
619 $ touch foo
620 $ hg add foo
620 $ hg add foo
621 $ hg ci -d '0 0' -m 'add foo'
621 $ hg ci -d '0 0' -m 'add foo'
622 Automatically installed hook
622 Automatically installed hook
623 $ echo >> foo
623 $ echo >> foo
624 $ hg ci --debug -d '0 0' -m 'change foo'
624 $ hg ci --debug -d '0 0' -m 'change foo'
625 committing files:
625 committing files:
626 foo
626 foo
627 committing manifest
627 committing manifest
628 committing changelog
628 committing changelog
629 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
629 committed changeset 1:52998019f6252a2b893452765fcb0a47351a5708
630 calling hook commit.auto: hgext_hookext.autohook
630 calling hook commit.auto: hgext_hookext.autohook
631 Automatically installed hook
631 Automatically installed hook
632
632
633 $ hg showconfig hooks
633 $ hg showconfig hooks
634 hooks.commit.auto=<function autohook at *> (glob)
634 hooks.commit.auto=<function autohook at *> (glob)
635
635
636 test python hook configured with python:[file]:[hook] syntax
636 test python hook configured with python:[file]:[hook] syntax
637
637
638 $ cd ..
638 $ cd ..
639 $ mkdir d
639 $ mkdir d
640 $ cd d
640 $ cd d
641 $ hg init repo
641 $ hg init repo
642 $ mkdir hooks
642 $ mkdir hooks
643
643
644 $ cd hooks
644 $ cd hooks
645 $ cat > testhooks.py <<EOF
645 $ cat > testhooks.py <<EOF
646 > def testhook(**args):
646 > def testhook(**args):
647 > print 'hook works'
647 > print 'hook works'
648 > EOF
648 > EOF
649 $ echo '[hooks]' > ../repo/.hg/hgrc
649 $ echo '[hooks]' > ../repo/.hg/hgrc
650 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
650 $ echo "pre-commit.test = python:`pwd`/testhooks.py:testhook" >> ../repo/.hg/hgrc
651
651
652 $ cd ../repo
652 $ cd ../repo
653 $ hg commit -d '0 0'
653 $ hg commit -d '0 0'
654 hook works
654 hook works
655 nothing changed
655 nothing changed
656 [1]
656 [1]
657
657
658 $ echo '[hooks]' > .hg/hgrc
658 $ echo '[hooks]' > .hg/hgrc
659 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
659 $ echo "update.ne = python:`pwd`/nonexistent.py:testhook" >> .hg/hgrc
660 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
660 $ echo "pre-identify.npmd = python:`pwd`/:no_python_module_dir" >> .hg/hgrc
661
661
662 $ hg up null
662 $ hg up null
663 loading update.ne hook failed:
663 loading update.ne hook failed:
664 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
664 abort: No such file or directory: $TESTTMP/d/repo/nonexistent.py
665 [255]
665 [255]
666
666
667 $ hg id
667 $ hg id
668 loading pre-identify.npmd hook failed:
668 loading pre-identify.npmd hook failed:
669 abort: No module named repo!
669 abort: No module named repo!
670 [255]
670 [255]
671
671
672 $ cd ../../b
672 $ cd ../../b
673
673
674 make sure --traceback works on hook import failure
674 make sure --traceback works on hook import failure
675
675
676 $ cat > importfail.py <<EOF
676 $ cat > importfail.py <<EOF
677 > import somebogusmodule
677 > import somebogusmodule
678 > # dereference something in the module to force demandimport to load it
678 > # dereference something in the module to force demandimport to load it
679 > somebogusmodule.whatever
679 > somebogusmodule.whatever
680 > EOF
680 > EOF
681
681
682 $ echo '[hooks]' > .hg/hgrc
682 $ echo '[hooks]' > .hg/hgrc
683 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
683 $ echo 'precommit.importfail = python:importfail.whatever' >> .hg/hgrc
684
684
685 $ echo a >> a
685 $ echo a >> a
686 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
686 $ hg --traceback commit -ma 2>&1 | egrep -v '^( +File| [a-zA-Z(])'
687 exception from first failed import attempt:
687 exception from first failed import attempt:
688 Traceback (most recent call last):
688 Traceback (most recent call last):
689 ImportError: No module named somebogusmodule
689 ImportError: No module named somebogusmodule
690 exception from second failed import attempt:
690 exception from second failed import attempt:
691 Traceback (most recent call last):
691 Traceback (most recent call last):
692 ImportError: No module named hgext_importfail
692 ImportError: No module named hgext_importfail
693 Traceback (most recent call last):
693 Traceback (most recent call last):
694 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
694 HookLoadError: precommit.importfail hook is invalid: import of "importfail" failed
695 abort: precommit.importfail hook is invalid: import of "importfail" failed
695 abort: precommit.importfail hook is invalid: import of "importfail" failed
696
696
697 Issue1827: Hooks Update & Commit not completely post operation
697 Issue1827: Hooks Update & Commit not completely post operation
698
698
699 commit and update hooks should run after command completion. The largefiles
699 commit and update hooks should run after command completion. The largefiles
700 use demonstrates a recursive wlock, showing the hook doesn't run until the
700 use demonstrates a recursive wlock, showing the hook doesn't run until the
701 final release (and dirstate flush).
701 final release (and dirstate flush).
702
702
703 $ echo '[hooks]' > .hg/hgrc
703 $ echo '[hooks]' > .hg/hgrc
704 $ echo 'commit = hg id' >> .hg/hgrc
704 $ echo 'commit = hg id' >> .hg/hgrc
705 $ echo 'update = hg id' >> .hg/hgrc
705 $ echo 'update = hg id' >> .hg/hgrc
706 $ echo bb > a
706 $ echo bb > a
707 $ hg ci -ma
707 $ hg ci -ma
708 223eafe2750c tip
708 223eafe2750c tip
709 $ hg up 0 --config extensions.largefiles=
709 $ hg up 0 --config extensions.largefiles=
710 cb9a9f314b8b
710 cb9a9f314b8b
711 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
711 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
712
712
713 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
713 make sure --verbose (and --quiet/--debug etc.) are propagated to the local ui
714 that is passed to pre/post hooks
714 that is passed to pre/post hooks
715
715
716 $ echo '[hooks]' > .hg/hgrc
716 $ echo '[hooks]' > .hg/hgrc
717 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
717 $ echo 'pre-identify = python:hooktests.verbosehook' >> .hg/hgrc
718 $ hg id
718 $ hg id
719 cb9a9f314b8b
719 cb9a9f314b8b
720 $ hg id --verbose
720 $ hg id --verbose
721 calling hook pre-identify: hooktests.verbosehook
721 calling hook pre-identify: hooktests.verbosehook
722 verbose output from hook
722 verbose output from hook
723 cb9a9f314b8b
723 cb9a9f314b8b
724
724
725 Ensure hooks can be prioritized
725 Ensure hooks can be prioritized
726
726
727 $ echo '[hooks]' > .hg/hgrc
727 $ echo '[hooks]' > .hg/hgrc
728 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
728 $ echo 'pre-identify.a = python:hooktests.verbosehook' >> .hg/hgrc
729 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
729 $ echo 'pre-identify.b = python:hooktests.verbosehook' >> .hg/hgrc
730 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
730 $ echo 'priority.pre-identify.b = 1' >> .hg/hgrc
731 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
731 $ echo 'pre-identify.c = python:hooktests.verbosehook' >> .hg/hgrc
732 $ hg id --verbose
732 $ hg id --verbose
733 calling hook pre-identify.b: hooktests.verbosehook
733 calling hook pre-identify.b: hooktests.verbosehook
734 verbose output from hook
734 verbose output from hook
735 calling hook pre-identify.a: hooktests.verbosehook
735 calling hook pre-identify.a: hooktests.verbosehook
736 verbose output from hook
736 verbose output from hook
737 calling hook pre-identify.c: hooktests.verbosehook
737 calling hook pre-identify.c: hooktests.verbosehook
738 verbose output from hook
738 verbose output from hook
739 cb9a9f314b8b
739 cb9a9f314b8b
740
740
741 new tags must be visible in pretxncommit (issue3210)
741 new tags must be visible in pretxncommit (issue3210)
742
742
743 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
743 $ echo 'pretxncommit.printtags = python:hooktests.printtags' >> .hg/hgrc
744 $ hg tag -f foo
744 $ hg tag -f foo
745 ['a', 'foo', 'tip']
745 ['a', 'foo', 'tip']
746
746
747 post-init hooks must not crash (issue4983)
747 post-init hooks must not crash (issue4983)
748 This also creates the `to` repo for the next test block.
748 This also creates the `to` repo for the next test block.
749
749
750 $ cd ..
750 $ cd ..
751 $ cat << EOF >> hgrc-with-post-init-hook
751 $ cat << EOF >> hgrc-with-post-init-hook
752 > [hooks]
752 > [hooks]
753 > post-init = printenv.py post-init
753 > post-init = printenv.py post-init
754 > EOF
754 > EOF
755 $ HGRCPATH=hgrc-with-post-init-hook hg init to
755 $ HGRCPATH=hgrc-with-post-init-hook hg init to
756 post-init hook: HG_ARGS=init to HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0
756 post-init hook: HG_ARGS=init to HG_OPTS={'insecure': None, 'remotecmd': '', 'ssh': ''} HG_PATS=['to'] HG_RESULT=0
757
757
758 new commits must be visible in pretxnchangegroup (issue3428)
758 new commits must be visible in pretxnchangegroup (issue3428)
759
759
760 $ echo '[hooks]' >> to/.hg/hgrc
760 $ echo '[hooks]' >> to/.hg/hgrc
761 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
761 $ echo 'prechangegroup = hg --traceback tip' >> to/.hg/hgrc
762 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
762 $ echo 'pretxnchangegroup = hg --traceback tip' >> to/.hg/hgrc
763 $ echo a >> to/a
763 $ echo a >> to/a
764 $ hg --cwd to ci -Ama
764 $ hg --cwd to ci -Ama
765 adding a
765 adding a
766 $ hg clone to from
766 $ hg clone to from
767 updating to branch default
767 updating to branch default
768 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
768 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
769 $ echo aa >> from/a
769 $ echo aa >> from/a
770 $ hg --cwd from ci -mb
770 $ hg --cwd from ci -mb
771 $ hg --cwd from push
771 $ hg --cwd from push
772 pushing to $TESTTMP/to (glob)
772 pushing to $TESTTMP/to (glob)
773 searching for changes
773 searching for changes
774 changeset: 0:cb9a9f314b8b
774 changeset: 0:cb9a9f314b8b
775 tag: tip
775 tag: tip
776 user: test
776 user: test
777 date: Thu Jan 01 00:00:00 1970 +0000
777 date: Thu Jan 01 00:00:00 1970 +0000
778 summary: a
778 summary: a
779
779
780 adding changesets
780 adding changesets
781 adding manifests
781 adding manifests
782 adding file changes
782 adding file changes
783 added 1 changesets with 1 changes to 1 files
783 added 1 changesets with 1 changes to 1 files
784 changeset: 1:9836a07b9b9d
784 changeset: 1:9836a07b9b9d
785 tag: tip
785 tag: tip
786 user: test
786 user: test
787 date: Thu Jan 01 00:00:00 1970 +0000
787 date: Thu Jan 01 00:00:00 1970 +0000
788 summary: b
788 summary: b
789
789
790
790
791 pretxnclose hook failure should abort the transaction
791 pretxnclose hook failure should abort the transaction
792
792
793 $ hg init txnfailure
793 $ hg init txnfailure
794 $ cd txnfailure
794 $ cd txnfailure
795 $ touch a && hg commit -Aqm a
795 $ touch a && hg commit -Aqm a
796 $ cat >> .hg/hgrc <<EOF
796 $ cat >> .hg/hgrc <<EOF
797 > [hooks]
797 > [hooks]
798 > pretxnclose.error = exit 1
798 > pretxnclose.error = exit 1
799 > EOF
799 > EOF
800 $ hg strip -r 0 --config extensions.strip=
800 $ hg strip -r 0 --config extensions.strip=
801 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
801 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
802 saved backup bundle to * (glob)
802 saved backup bundle to * (glob)
803 transaction abort!
803 transaction abort!
804 rollback completed
804 rollback completed
805 strip failed, full bundle stored in * (glob)
805 strip failed, backup bundle stored in * (glob)
806 abort: pretxnclose.error hook exited with status 1
806 abort: pretxnclose.error hook exited with status 1
807 [255]
807 [255]
808 $ hg recover
808 $ hg recover
809 no interrupted transaction available
809 no interrupted transaction available
810 [1]
810 [1]
811 $ cd ..
811 $ cd ..
812
812
813 Hook from untrusted hgrc are reported as failure
813 Hook from untrusted hgrc are reported as failure
814 ================================================
814 ================================================
815
815
816 $ cat << EOF > $TESTTMP/untrusted.py
816 $ cat << EOF > $TESTTMP/untrusted.py
817 > from mercurial import scmutil, util
817 > from mercurial import scmutil, util
818 > def uisetup(ui):
818 > def uisetup(ui):
819 > class untrustedui(ui.__class__):
819 > class untrustedui(ui.__class__):
820 > def _trusted(self, fp, f):
820 > def _trusted(self, fp, f):
821 > if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'):
821 > if util.normpath(fp.name).endswith('untrusted/.hg/hgrc'):
822 > return False
822 > return False
823 > return super(untrustedui, self)._trusted(fp, f)
823 > return super(untrustedui, self)._trusted(fp, f)
824 > ui.__class__ = untrustedui
824 > ui.__class__ = untrustedui
825 > EOF
825 > EOF
826 $ cat << EOF >> $HGRCPATH
826 $ cat << EOF >> $HGRCPATH
827 > [extensions]
827 > [extensions]
828 > untrusted=$TESTTMP/untrusted.py
828 > untrusted=$TESTTMP/untrusted.py
829 > EOF
829 > EOF
830 $ hg init untrusted
830 $ hg init untrusted
831 $ cd untrusted
831 $ cd untrusted
832
832
833 Non-blocking hook
833 Non-blocking hook
834 -----------------
834 -----------------
835
835
836 $ cat << EOF >> .hg/hgrc
836 $ cat << EOF >> .hg/hgrc
837 > [hooks]
837 > [hooks]
838 > txnclose.testing=echo txnclose hook called
838 > txnclose.testing=echo txnclose hook called
839 > EOF
839 > EOF
840 $ touch a && hg commit -Aqm a
840 $ touch a && hg commit -Aqm a
841 warning: untrusted hook txnclose not executed
841 warning: untrusted hook txnclose not executed
842 $ hg log
842 $ hg log
843 changeset: 0:3903775176ed
843 changeset: 0:3903775176ed
844 tag: tip
844 tag: tip
845 user: test
845 user: test
846 date: Thu Jan 01 00:00:00 1970 +0000
846 date: Thu Jan 01 00:00:00 1970 +0000
847 summary: a
847 summary: a
848
848
849
849
850 Non-blocking hook
850 Non-blocking hook
851 -----------------
851 -----------------
852
852
853 $ cat << EOF >> .hg/hgrc
853 $ cat << EOF >> .hg/hgrc
854 > [hooks]
854 > [hooks]
855 > pretxnclose.testing=echo pre-txnclose hook called
855 > pretxnclose.testing=echo pre-txnclose hook called
856 > EOF
856 > EOF
857 $ touch b && hg commit -Aqm a
857 $ touch b && hg commit -Aqm a
858 transaction abort!
858 transaction abort!
859 rollback completed
859 rollback completed
860 abort: untrusted hook pretxnclose not executed
860 abort: untrusted hook pretxnclose not executed
861 (see 'hg help config.trusted')
861 (see 'hg help config.trusted')
862 [255]
862 [255]
863 $ hg log
863 $ hg log
864 changeset: 0:3903775176ed
864 changeset: 0:3903775176ed
865 tag: tip
865 tag: tip
866 user: test
866 user: test
867 date: Thu Jan 01 00:00:00 1970 +0000
867 date: Thu Jan 01 00:00:00 1970 +0000
868 summary: a
868 summary: a
869
869
@@ -1,139 +1,139 b''
1 #require unix-permissions no-root
1 #require unix-permissions no-root
2
2
3 $ cat > $TESTTMP/dumpjournal.py <<EOF
3 $ cat > $TESTTMP/dumpjournal.py <<EOF
4 > import sys
4 > import sys
5 > for entry in sys.stdin.read().split('\n'):
5 > for entry in sys.stdin.read().split('\n'):
6 > if entry:
6 > if entry:
7 > print entry.split('\x00')[0]
7 > print entry.split('\x00')[0]
8 > EOF
8 > EOF
9
9
10 $ echo "[extensions]" >> $HGRCPATH
10 $ echo "[extensions]" >> $HGRCPATH
11 $ echo "mq=">> $HGRCPATH
11 $ echo "mq=">> $HGRCPATH
12
12
13 $ teststrip() {
13 $ teststrip() {
14 > hg -q up -C $1
14 > hg -q up -C $1
15 > echo % before update $1, strip $2
15 > echo % before update $1, strip $2
16 > hg parents
16 > hg parents
17 > chmod -$3 $4
17 > chmod -$3 $4
18 > hg strip $2 2>&1 | sed 's/\(bundle\).*/\1/' | sed 's/Permission denied.*\.hg\/store\/\(.*\)/Permission denied \.hg\/store\/\1/'
18 > hg strip $2 2>&1 | sed 's/\(bundle\).*/\1/' | sed 's/Permission denied.*\.hg\/store\/\(.*\)/Permission denied \.hg\/store\/\1/'
19 > echo % after update $1, strip $2
19 > echo % after update $1, strip $2
20 > chmod +$3 $4
20 > chmod +$3 $4
21 > hg verify
21 > hg verify
22 > echo % journal contents
22 > echo % journal contents
23 > if [ -f .hg/store/journal ]; then
23 > if [ -f .hg/store/journal ]; then
24 > cat .hg/store/journal | python $TESTTMP/dumpjournal.py
24 > cat .hg/store/journal | python $TESTTMP/dumpjournal.py
25 > else
25 > else
26 > echo "(no journal)"
26 > echo "(no journal)"
27 > fi
27 > fi
28 > ls .hg/store/journal >/dev/null 2>&1 && hg recover
28 > ls .hg/store/journal >/dev/null 2>&1 && hg recover
29 > ls .hg/strip-backup/* >/dev/null 2>&1 && hg unbundle -q .hg/strip-backup/*
29 > ls .hg/strip-backup/* >/dev/null 2>&1 && hg unbundle -q .hg/strip-backup/*
30 > rm -rf .hg/strip-backup
30 > rm -rf .hg/strip-backup
31 > }
31 > }
32
32
33 $ hg init test
33 $ hg init test
34 $ cd test
34 $ cd test
35 $ echo a > a
35 $ echo a > a
36 $ hg -q ci -m "a" -A
36 $ hg -q ci -m "a" -A
37 $ echo b > b
37 $ echo b > b
38 $ hg -q ci -m "b" -A
38 $ hg -q ci -m "b" -A
39 $ echo b2 >> b
39 $ echo b2 >> b
40 $ hg -q ci -m "b2" -A
40 $ hg -q ci -m "b2" -A
41 $ echo c > c
41 $ echo c > c
42 $ hg -q ci -m "c" -A
42 $ hg -q ci -m "c" -A
43 $ teststrip 0 2 w .hg/store/data/b.i
43 $ teststrip 0 2 w .hg/store/data/b.i
44 % before update 0, strip 2
44 % before update 0, strip 2
45 changeset: 0:cb9a9f314b8b
45 changeset: 0:cb9a9f314b8b
46 user: test
46 user: test
47 date: Thu Jan 01 00:00:00 1970 +0000
47 date: Thu Jan 01 00:00:00 1970 +0000
48 summary: a
48 summary: a
49
49
50 saved backup bundle
50 saved backup bundle
51 transaction abort!
51 transaction abort!
52 failed to truncate data/b.i
52 failed to truncate data/b.i
53 rollback failed - please run hg recover
53 rollback failed - please run hg recover
54 strip failed, full bundle
54 strip failed, backup bundle
55 abort: Permission denied .hg/store/data/b.i
55 abort: Permission denied .hg/store/data/b.i
56 % after update 0, strip 2
56 % after update 0, strip 2
57 abandoned transaction found - run hg recover
57 abandoned transaction found - run hg recover
58 checking changesets
58 checking changesets
59 checking manifests
59 checking manifests
60 crosschecking files in changesets and manifests
60 crosschecking files in changesets and manifests
61 checking files
61 checking files
62 b@?: rev 1 points to nonexistent changeset 2
62 b@?: rev 1 points to nonexistent changeset 2
63 (expected 1)
63 (expected 1)
64 b@?: 736c29771fba not in manifests
64 b@?: 736c29771fba not in manifests
65 warning: orphan revlog 'data/c.i'
65 warning: orphan revlog 'data/c.i'
66 2 files, 2 changesets, 3 total revisions
66 2 files, 2 changesets, 3 total revisions
67 2 warnings encountered!
67 2 warnings encountered!
68 2 integrity errors encountered!
68 2 integrity errors encountered!
69 % journal contents
69 % journal contents
70 00changelog.i
70 00changelog.i
71 00manifest.i
71 00manifest.i
72 data/b.i
72 data/b.i
73 data/c.i
73 data/c.i
74 rolling back interrupted transaction
74 rolling back interrupted transaction
75 checking changesets
75 checking changesets
76 checking manifests
76 checking manifests
77 crosschecking files in changesets and manifests
77 crosschecking files in changesets and manifests
78 checking files
78 checking files
79 2 files, 2 changesets, 2 total revisions
79 2 files, 2 changesets, 2 total revisions
80 $ teststrip 0 2 r .hg/store/data/b.i
80 $ teststrip 0 2 r .hg/store/data/b.i
81 % before update 0, strip 2
81 % before update 0, strip 2
82 changeset: 0:cb9a9f314b8b
82 changeset: 0:cb9a9f314b8b
83 user: test
83 user: test
84 date: Thu Jan 01 00:00:00 1970 +0000
84 date: Thu Jan 01 00:00:00 1970 +0000
85 summary: a
85 summary: a
86
86
87 abort: Permission denied .hg/store/data/b.i
87 abort: Permission denied .hg/store/data/b.i
88 % after update 0, strip 2
88 % after update 0, strip 2
89 checking changesets
89 checking changesets
90 checking manifests
90 checking manifests
91 crosschecking files in changesets and manifests
91 crosschecking files in changesets and manifests
92 checking files
92 checking files
93 3 files, 4 changesets, 4 total revisions
93 3 files, 4 changesets, 4 total revisions
94 % journal contents
94 % journal contents
95 (no journal)
95 (no journal)
96 $ teststrip 0 2 w .hg/store/00manifest.i
96 $ teststrip 0 2 w .hg/store/00manifest.i
97 % before update 0, strip 2
97 % before update 0, strip 2
98 changeset: 0:cb9a9f314b8b
98 changeset: 0:cb9a9f314b8b
99 user: test
99 user: test
100 date: Thu Jan 01 00:00:00 1970 +0000
100 date: Thu Jan 01 00:00:00 1970 +0000
101 summary: a
101 summary: a
102
102
103 saved backup bundle
103 saved backup bundle
104 transaction abort!
104 transaction abort!
105 failed to truncate 00manifest.i
105 failed to truncate 00manifest.i
106 rollback failed - please run hg recover
106 rollback failed - please run hg recover
107 strip failed, full bundle
107 strip failed, backup bundle
108 abort: Permission denied .hg/store/00manifest.i
108 abort: Permission denied .hg/store/00manifest.i
109 % after update 0, strip 2
109 % after update 0, strip 2
110 abandoned transaction found - run hg recover
110 abandoned transaction found - run hg recover
111 checking changesets
111 checking changesets
112 checking manifests
112 checking manifests
113 manifest@?: rev 2 points to nonexistent changeset 2
113 manifest@?: rev 2 points to nonexistent changeset 2
114 manifest@?: 3362547cdf64 not in changesets
114 manifest@?: 3362547cdf64 not in changesets
115 manifest@?: rev 3 points to nonexistent changeset 3
115 manifest@?: rev 3 points to nonexistent changeset 3
116 manifest@?: 265a85892ecb not in changesets
116 manifest@?: 265a85892ecb not in changesets
117 crosschecking files in changesets and manifests
117 crosschecking files in changesets and manifests
118 c@3: in manifest but not in changeset
118 c@3: in manifest but not in changeset
119 checking files
119 checking files
120 b@?: rev 1 points to nonexistent changeset 2
120 b@?: rev 1 points to nonexistent changeset 2
121 (expected 1)
121 (expected 1)
122 c@?: rev 0 points to nonexistent changeset 3
122 c@?: rev 0 points to nonexistent changeset 3
123 3 files, 2 changesets, 4 total revisions
123 3 files, 2 changesets, 4 total revisions
124 1 warnings encountered!
124 1 warnings encountered!
125 7 integrity errors encountered!
125 7 integrity errors encountered!
126 (first damaged changeset appears to be 3)
126 (first damaged changeset appears to be 3)
127 % journal contents
127 % journal contents
128 00changelog.i
128 00changelog.i
129 00manifest.i
129 00manifest.i
130 data/b.i
130 data/b.i
131 data/c.i
131 data/c.i
132 rolling back interrupted transaction
132 rolling back interrupted transaction
133 checking changesets
133 checking changesets
134 checking manifests
134 checking manifests
135 crosschecking files in changesets and manifests
135 crosschecking files in changesets and manifests
136 checking files
136 checking files
137 2 files, 2 changesets, 2 total revisions
137 2 files, 2 changesets, 2 total revisions
138
138
139 $ cd ..
139 $ cd ..
@@ -1,938 +1,938 b''
1 $ echo "[format]" >> $HGRCPATH
1 $ echo "[format]" >> $HGRCPATH
2 $ echo "usegeneraldelta=yes" >> $HGRCPATH
2 $ echo "usegeneraldelta=yes" >> $HGRCPATH
3 $ echo "[extensions]" >> $HGRCPATH
3 $ echo "[extensions]" >> $HGRCPATH
4 $ echo "strip=" >> $HGRCPATH
4 $ echo "strip=" >> $HGRCPATH
5
5
6 $ restore() {
6 $ restore() {
7 > hg unbundle -q .hg/strip-backup/*
7 > hg unbundle -q .hg/strip-backup/*
8 > rm .hg/strip-backup/*
8 > rm .hg/strip-backup/*
9 > }
9 > }
10 $ teststrip() {
10 $ teststrip() {
11 > hg up -C $1
11 > hg up -C $1
12 > echo % before update $1, strip $2
12 > echo % before update $1, strip $2
13 > hg parents
13 > hg parents
14 > hg --traceback strip $2
14 > hg --traceback strip $2
15 > echo % after update $1, strip $2
15 > echo % after update $1, strip $2
16 > hg parents
16 > hg parents
17 > restore
17 > restore
18 > }
18 > }
19
19
20 $ hg init test
20 $ hg init test
21 $ cd test
21 $ cd test
22
22
23 $ echo foo > bar
23 $ echo foo > bar
24 $ hg ci -Ama
24 $ hg ci -Ama
25 adding bar
25 adding bar
26
26
27 $ echo more >> bar
27 $ echo more >> bar
28 $ hg ci -Amb
28 $ hg ci -Amb
29
29
30 $ echo blah >> bar
30 $ echo blah >> bar
31 $ hg ci -Amc
31 $ hg ci -Amc
32
32
33 $ hg up 1
33 $ hg up 1
34 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
34 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
35 $ echo blah >> bar
35 $ echo blah >> bar
36 $ hg ci -Amd
36 $ hg ci -Amd
37 created new head
37 created new head
38
38
39 $ echo final >> bar
39 $ echo final >> bar
40 $ hg ci -Ame
40 $ hg ci -Ame
41
41
42 $ hg log
42 $ hg log
43 changeset: 4:443431ffac4f
43 changeset: 4:443431ffac4f
44 tag: tip
44 tag: tip
45 user: test
45 user: test
46 date: Thu Jan 01 00:00:00 1970 +0000
46 date: Thu Jan 01 00:00:00 1970 +0000
47 summary: e
47 summary: e
48
48
49 changeset: 3:65bd5f99a4a3
49 changeset: 3:65bd5f99a4a3
50 parent: 1:ef3a871183d7
50 parent: 1:ef3a871183d7
51 user: test
51 user: test
52 date: Thu Jan 01 00:00:00 1970 +0000
52 date: Thu Jan 01 00:00:00 1970 +0000
53 summary: d
53 summary: d
54
54
55 changeset: 2:264128213d29
55 changeset: 2:264128213d29
56 user: test
56 user: test
57 date: Thu Jan 01 00:00:00 1970 +0000
57 date: Thu Jan 01 00:00:00 1970 +0000
58 summary: c
58 summary: c
59
59
60 changeset: 1:ef3a871183d7
60 changeset: 1:ef3a871183d7
61 user: test
61 user: test
62 date: Thu Jan 01 00:00:00 1970 +0000
62 date: Thu Jan 01 00:00:00 1970 +0000
63 summary: b
63 summary: b
64
64
65 changeset: 0:9ab35a2d17cb
65 changeset: 0:9ab35a2d17cb
66 user: test
66 user: test
67 date: Thu Jan 01 00:00:00 1970 +0000
67 date: Thu Jan 01 00:00:00 1970 +0000
68 summary: a
68 summary: a
69
69
70
70
71 $ teststrip 4 4
71 $ teststrip 4 4
72 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
72 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
73 % before update 4, strip 4
73 % before update 4, strip 4
74 changeset: 4:443431ffac4f
74 changeset: 4:443431ffac4f
75 tag: tip
75 tag: tip
76 user: test
76 user: test
77 date: Thu Jan 01 00:00:00 1970 +0000
77 date: Thu Jan 01 00:00:00 1970 +0000
78 summary: e
78 summary: e
79
79
80 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
80 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
81 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
81 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
82 % after update 4, strip 4
82 % after update 4, strip 4
83 changeset: 3:65bd5f99a4a3
83 changeset: 3:65bd5f99a4a3
84 tag: tip
84 tag: tip
85 parent: 1:ef3a871183d7
85 parent: 1:ef3a871183d7
86 user: test
86 user: test
87 date: Thu Jan 01 00:00:00 1970 +0000
87 date: Thu Jan 01 00:00:00 1970 +0000
88 summary: d
88 summary: d
89
89
90 $ teststrip 4 3
90 $ teststrip 4 3
91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
91 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
92 % before update 4, strip 3
92 % before update 4, strip 3
93 changeset: 4:443431ffac4f
93 changeset: 4:443431ffac4f
94 tag: tip
94 tag: tip
95 user: test
95 user: test
96 date: Thu Jan 01 00:00:00 1970 +0000
96 date: Thu Jan 01 00:00:00 1970 +0000
97 summary: e
97 summary: e
98
98
99 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
100 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
101 % after update 4, strip 3
101 % after update 4, strip 3
102 changeset: 1:ef3a871183d7
102 changeset: 1:ef3a871183d7
103 user: test
103 user: test
104 date: Thu Jan 01 00:00:00 1970 +0000
104 date: Thu Jan 01 00:00:00 1970 +0000
105 summary: b
105 summary: b
106
106
107 $ teststrip 1 4
107 $ teststrip 1 4
108 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
108 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 % before update 1, strip 4
109 % before update 1, strip 4
110 changeset: 1:ef3a871183d7
110 changeset: 1:ef3a871183d7
111 user: test
111 user: test
112 date: Thu Jan 01 00:00:00 1970 +0000
112 date: Thu Jan 01 00:00:00 1970 +0000
113 summary: b
113 summary: b
114
114
115 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
115 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
116 % after update 1, strip 4
116 % after update 1, strip 4
117 changeset: 1:ef3a871183d7
117 changeset: 1:ef3a871183d7
118 user: test
118 user: test
119 date: Thu Jan 01 00:00:00 1970 +0000
119 date: Thu Jan 01 00:00:00 1970 +0000
120 summary: b
120 summary: b
121
121
122 $ teststrip 4 2
122 $ teststrip 4 2
123 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
123 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
124 % before update 4, strip 2
124 % before update 4, strip 2
125 changeset: 4:443431ffac4f
125 changeset: 4:443431ffac4f
126 tag: tip
126 tag: tip
127 user: test
127 user: test
128 date: Thu Jan 01 00:00:00 1970 +0000
128 date: Thu Jan 01 00:00:00 1970 +0000
129 summary: e
129 summary: e
130
130
131 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
131 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
132 % after update 4, strip 2
132 % after update 4, strip 2
133 changeset: 3:443431ffac4f
133 changeset: 3:443431ffac4f
134 tag: tip
134 tag: tip
135 user: test
135 user: test
136 date: Thu Jan 01 00:00:00 1970 +0000
136 date: Thu Jan 01 00:00:00 1970 +0000
137 summary: e
137 summary: e
138
138
139 $ teststrip 4 1
139 $ teststrip 4 1
140 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
140 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
141 % before update 4, strip 1
141 % before update 4, strip 1
142 changeset: 4:264128213d29
142 changeset: 4:264128213d29
143 tag: tip
143 tag: tip
144 parent: 1:ef3a871183d7
144 parent: 1:ef3a871183d7
145 user: test
145 user: test
146 date: Thu Jan 01 00:00:00 1970 +0000
146 date: Thu Jan 01 00:00:00 1970 +0000
147 summary: c
147 summary: c
148
148
149 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
149 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
150 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
150 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
151 % after update 4, strip 1
151 % after update 4, strip 1
152 changeset: 0:9ab35a2d17cb
152 changeset: 0:9ab35a2d17cb
153 tag: tip
153 tag: tip
154 user: test
154 user: test
155 date: Thu Jan 01 00:00:00 1970 +0000
155 date: Thu Jan 01 00:00:00 1970 +0000
156 summary: a
156 summary: a
157
157
158 $ teststrip null 4
158 $ teststrip null 4
159 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
159 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
160 % before update null, strip 4
160 % before update null, strip 4
161 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
161 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
162 % after update null, strip 4
162 % after update null, strip 4
163
163
164 $ hg log
164 $ hg log
165 changeset: 4:264128213d29
165 changeset: 4:264128213d29
166 tag: tip
166 tag: tip
167 parent: 1:ef3a871183d7
167 parent: 1:ef3a871183d7
168 user: test
168 user: test
169 date: Thu Jan 01 00:00:00 1970 +0000
169 date: Thu Jan 01 00:00:00 1970 +0000
170 summary: c
170 summary: c
171
171
172 changeset: 3:443431ffac4f
172 changeset: 3:443431ffac4f
173 user: test
173 user: test
174 date: Thu Jan 01 00:00:00 1970 +0000
174 date: Thu Jan 01 00:00:00 1970 +0000
175 summary: e
175 summary: e
176
176
177 changeset: 2:65bd5f99a4a3
177 changeset: 2:65bd5f99a4a3
178 user: test
178 user: test
179 date: Thu Jan 01 00:00:00 1970 +0000
179 date: Thu Jan 01 00:00:00 1970 +0000
180 summary: d
180 summary: d
181
181
182 changeset: 1:ef3a871183d7
182 changeset: 1:ef3a871183d7
183 user: test
183 user: test
184 date: Thu Jan 01 00:00:00 1970 +0000
184 date: Thu Jan 01 00:00:00 1970 +0000
185 summary: b
185 summary: b
186
186
187 changeset: 0:9ab35a2d17cb
187 changeset: 0:9ab35a2d17cb
188 user: test
188 user: test
189 date: Thu Jan 01 00:00:00 1970 +0000
189 date: Thu Jan 01 00:00:00 1970 +0000
190 summary: a
190 summary: a
191
191
192 $ hg up -C 4
192 $ hg up -C 4
193 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
193 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
194 $ hg parents
194 $ hg parents
195 changeset: 4:264128213d29
195 changeset: 4:264128213d29
196 tag: tip
196 tag: tip
197 parent: 1:ef3a871183d7
197 parent: 1:ef3a871183d7
198 user: test
198 user: test
199 date: Thu Jan 01 00:00:00 1970 +0000
199 date: Thu Jan 01 00:00:00 1970 +0000
200 summary: c
200 summary: c
201
201
202
202
203 $ hg --traceback strip 4
203 $ hg --traceback strip 4
204 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
204 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
205 saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob)
205 saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob)
206 $ hg parents
206 $ hg parents
207 changeset: 1:ef3a871183d7
207 changeset: 1:ef3a871183d7
208 user: test
208 user: test
209 date: Thu Jan 01 00:00:00 1970 +0000
209 date: Thu Jan 01 00:00:00 1970 +0000
210 summary: b
210 summary: b
211
211
212 $ hg debugbundle .hg/strip-backup/*
212 $ hg debugbundle .hg/strip-backup/*
213 Stream params: sortdict([('Compression', 'BZ')])
213 Stream params: sortdict([('Compression', 'BZ')])
214 changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])"
214 changegroup -- "sortdict([('version', '02'), ('nbchanges', '1')])"
215 264128213d290d868c54642d13aeaa3675551a78
215 264128213d290d868c54642d13aeaa3675551a78
216 $ hg pull .hg/strip-backup/*
216 $ hg pull .hg/strip-backup/*
217 pulling from .hg/strip-backup/264128213d29-0b39d6bf-backup.hg
217 pulling from .hg/strip-backup/264128213d29-0b39d6bf-backup.hg
218 searching for changes
218 searching for changes
219 adding changesets
219 adding changesets
220 adding manifests
220 adding manifests
221 adding file changes
221 adding file changes
222 added 1 changesets with 0 changes to 0 files (+1 heads)
222 added 1 changesets with 0 changes to 0 files (+1 heads)
223 (run 'hg heads' to see heads, 'hg merge' to merge)
223 (run 'hg heads' to see heads, 'hg merge' to merge)
224 $ rm .hg/strip-backup/*
224 $ rm .hg/strip-backup/*
225 $ hg log --graph
225 $ hg log --graph
226 o changeset: 4:264128213d29
226 o changeset: 4:264128213d29
227 | tag: tip
227 | tag: tip
228 | parent: 1:ef3a871183d7
228 | parent: 1:ef3a871183d7
229 | user: test
229 | user: test
230 | date: Thu Jan 01 00:00:00 1970 +0000
230 | date: Thu Jan 01 00:00:00 1970 +0000
231 | summary: c
231 | summary: c
232 |
232 |
233 | o changeset: 3:443431ffac4f
233 | o changeset: 3:443431ffac4f
234 | | user: test
234 | | user: test
235 | | date: Thu Jan 01 00:00:00 1970 +0000
235 | | date: Thu Jan 01 00:00:00 1970 +0000
236 | | summary: e
236 | | summary: e
237 | |
237 | |
238 | o changeset: 2:65bd5f99a4a3
238 | o changeset: 2:65bd5f99a4a3
239 |/ user: test
239 |/ user: test
240 | date: Thu Jan 01 00:00:00 1970 +0000
240 | date: Thu Jan 01 00:00:00 1970 +0000
241 | summary: d
241 | summary: d
242 |
242 |
243 @ changeset: 1:ef3a871183d7
243 @ changeset: 1:ef3a871183d7
244 | user: test
244 | user: test
245 | date: Thu Jan 01 00:00:00 1970 +0000
245 | date: Thu Jan 01 00:00:00 1970 +0000
246 | summary: b
246 | summary: b
247 |
247 |
248 o changeset: 0:9ab35a2d17cb
248 o changeset: 0:9ab35a2d17cb
249 user: test
249 user: test
250 date: Thu Jan 01 00:00:00 1970 +0000
250 date: Thu Jan 01 00:00:00 1970 +0000
251 summary: a
251 summary: a
252
252
253 $ hg up -C 2
253 $ hg up -C 2
254 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
254 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
255 $ hg merge 4
255 $ hg merge 4
256 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
256 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
257 (branch merge, don't forget to commit)
257 (branch merge, don't forget to commit)
258
258
259 before strip of merge parent
259 before strip of merge parent
260
260
261 $ hg parents
261 $ hg parents
262 changeset: 2:65bd5f99a4a3
262 changeset: 2:65bd5f99a4a3
263 user: test
263 user: test
264 date: Thu Jan 01 00:00:00 1970 +0000
264 date: Thu Jan 01 00:00:00 1970 +0000
265 summary: d
265 summary: d
266
266
267 changeset: 4:264128213d29
267 changeset: 4:264128213d29
268 tag: tip
268 tag: tip
269 parent: 1:ef3a871183d7
269 parent: 1:ef3a871183d7
270 user: test
270 user: test
271 date: Thu Jan 01 00:00:00 1970 +0000
271 date: Thu Jan 01 00:00:00 1970 +0000
272 summary: c
272 summary: c
273
273
274 $ hg strip 4
274 $ hg strip 4
275 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
275 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
276 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
276 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
277
277
278 after strip of merge parent
278 after strip of merge parent
279
279
280 $ hg parents
280 $ hg parents
281 changeset: 1:ef3a871183d7
281 changeset: 1:ef3a871183d7
282 user: test
282 user: test
283 date: Thu Jan 01 00:00:00 1970 +0000
283 date: Thu Jan 01 00:00:00 1970 +0000
284 summary: b
284 summary: b
285
285
286 $ restore
286 $ restore
287
287
288 $ hg up
288 $ hg up
289 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
289 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
290 1 other heads for branch "default"
290 1 other heads for branch "default"
291 $ hg log -G
291 $ hg log -G
292 @ changeset: 4:264128213d29
292 @ changeset: 4:264128213d29
293 | tag: tip
293 | tag: tip
294 | parent: 1:ef3a871183d7
294 | parent: 1:ef3a871183d7
295 | user: test
295 | user: test
296 | date: Thu Jan 01 00:00:00 1970 +0000
296 | date: Thu Jan 01 00:00:00 1970 +0000
297 | summary: c
297 | summary: c
298 |
298 |
299 | o changeset: 3:443431ffac4f
299 | o changeset: 3:443431ffac4f
300 | | user: test
300 | | user: test
301 | | date: Thu Jan 01 00:00:00 1970 +0000
301 | | date: Thu Jan 01 00:00:00 1970 +0000
302 | | summary: e
302 | | summary: e
303 | |
303 | |
304 | o changeset: 2:65bd5f99a4a3
304 | o changeset: 2:65bd5f99a4a3
305 |/ user: test
305 |/ user: test
306 | date: Thu Jan 01 00:00:00 1970 +0000
306 | date: Thu Jan 01 00:00:00 1970 +0000
307 | summary: d
307 | summary: d
308 |
308 |
309 o changeset: 1:ef3a871183d7
309 o changeset: 1:ef3a871183d7
310 | user: test
310 | user: test
311 | date: Thu Jan 01 00:00:00 1970 +0000
311 | date: Thu Jan 01 00:00:00 1970 +0000
312 | summary: b
312 | summary: b
313 |
313 |
314 o changeset: 0:9ab35a2d17cb
314 o changeset: 0:9ab35a2d17cb
315 user: test
315 user: test
316 date: Thu Jan 01 00:00:00 1970 +0000
316 date: Thu Jan 01 00:00:00 1970 +0000
317 summary: a
317 summary: a
318
318
319
319
320 2 is parent of 3, only one strip should happen
320 2 is parent of 3, only one strip should happen
321
321
322 $ hg strip "roots(2)" 3
322 $ hg strip "roots(2)" 3
323 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
323 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
324 $ hg log -G
324 $ hg log -G
325 @ changeset: 2:264128213d29
325 @ changeset: 2:264128213d29
326 | tag: tip
326 | tag: tip
327 | user: test
327 | user: test
328 | date: Thu Jan 01 00:00:00 1970 +0000
328 | date: Thu Jan 01 00:00:00 1970 +0000
329 | summary: c
329 | summary: c
330 |
330 |
331 o changeset: 1:ef3a871183d7
331 o changeset: 1:ef3a871183d7
332 | user: test
332 | user: test
333 | date: Thu Jan 01 00:00:00 1970 +0000
333 | date: Thu Jan 01 00:00:00 1970 +0000
334 | summary: b
334 | summary: b
335 |
335 |
336 o changeset: 0:9ab35a2d17cb
336 o changeset: 0:9ab35a2d17cb
337 user: test
337 user: test
338 date: Thu Jan 01 00:00:00 1970 +0000
338 date: Thu Jan 01 00:00:00 1970 +0000
339 summary: a
339 summary: a
340
340
341 $ restore
341 $ restore
342 $ hg log -G
342 $ hg log -G
343 o changeset: 4:443431ffac4f
343 o changeset: 4:443431ffac4f
344 | tag: tip
344 | tag: tip
345 | user: test
345 | user: test
346 | date: Thu Jan 01 00:00:00 1970 +0000
346 | date: Thu Jan 01 00:00:00 1970 +0000
347 | summary: e
347 | summary: e
348 |
348 |
349 o changeset: 3:65bd5f99a4a3
349 o changeset: 3:65bd5f99a4a3
350 | parent: 1:ef3a871183d7
350 | parent: 1:ef3a871183d7
351 | user: test
351 | user: test
352 | date: Thu Jan 01 00:00:00 1970 +0000
352 | date: Thu Jan 01 00:00:00 1970 +0000
353 | summary: d
353 | summary: d
354 |
354 |
355 | @ changeset: 2:264128213d29
355 | @ changeset: 2:264128213d29
356 |/ user: test
356 |/ user: test
357 | date: Thu Jan 01 00:00:00 1970 +0000
357 | date: Thu Jan 01 00:00:00 1970 +0000
358 | summary: c
358 | summary: c
359 |
359 |
360 o changeset: 1:ef3a871183d7
360 o changeset: 1:ef3a871183d7
361 | user: test
361 | user: test
362 | date: Thu Jan 01 00:00:00 1970 +0000
362 | date: Thu Jan 01 00:00:00 1970 +0000
363 | summary: b
363 | summary: b
364 |
364 |
365 o changeset: 0:9ab35a2d17cb
365 o changeset: 0:9ab35a2d17cb
366 user: test
366 user: test
367 date: Thu Jan 01 00:00:00 1970 +0000
367 date: Thu Jan 01 00:00:00 1970 +0000
368 summary: a
368 summary: a
369
369
370 Failed hook while applying "saveheads" bundle.
370 Failed hook while applying "saveheads" bundle.
371
371
372 $ hg strip 2 --config hooks.pretxnchangegroup.bad=false
372 $ hg strip 2 --config hooks.pretxnchangegroup.bad=false
373 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
373 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
374 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
374 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
375 transaction abort!
375 transaction abort!
376 rollback completed
376 rollback completed
377 strip failed, full bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob)
377 strip failed, backup bundle stored in '$TESTTMP/test/.hg/strip-backup/*-backup.hg' (glob)
378 strip failed, unrecovered changes stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob)
378 strip failed, unrecovered changes stored in '$TESTTMP/test/.hg/strip-backup/*-temp.hg' (glob)
379 (fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/test/.hg/strip-backup/*-temp.hg'") (glob)
379 (fix the problem, then recover the changesets with "hg unbundle '$TESTTMP/test/.hg/strip-backup/*-temp.hg'") (glob)
380 abort: pretxnchangegroup.bad hook exited with status 1
380 abort: pretxnchangegroup.bad hook exited with status 1
381 [255]
381 [255]
382 $ restore
382 $ restore
383 $ hg log -G
383 $ hg log -G
384 o changeset: 4:443431ffac4f
384 o changeset: 4:443431ffac4f
385 | tag: tip
385 | tag: tip
386 | user: test
386 | user: test
387 | date: Thu Jan 01 00:00:00 1970 +0000
387 | date: Thu Jan 01 00:00:00 1970 +0000
388 | summary: e
388 | summary: e
389 |
389 |
390 o changeset: 3:65bd5f99a4a3
390 o changeset: 3:65bd5f99a4a3
391 | parent: 1:ef3a871183d7
391 | parent: 1:ef3a871183d7
392 | user: test
392 | user: test
393 | date: Thu Jan 01 00:00:00 1970 +0000
393 | date: Thu Jan 01 00:00:00 1970 +0000
394 | summary: d
394 | summary: d
395 |
395 |
396 | o changeset: 2:264128213d29
396 | o changeset: 2:264128213d29
397 |/ user: test
397 |/ user: test
398 | date: Thu Jan 01 00:00:00 1970 +0000
398 | date: Thu Jan 01 00:00:00 1970 +0000
399 | summary: c
399 | summary: c
400 |
400 |
401 @ changeset: 1:ef3a871183d7
401 @ changeset: 1:ef3a871183d7
402 | user: test
402 | user: test
403 | date: Thu Jan 01 00:00:00 1970 +0000
403 | date: Thu Jan 01 00:00:00 1970 +0000
404 | summary: b
404 | summary: b
405 |
405 |
406 o changeset: 0:9ab35a2d17cb
406 o changeset: 0:9ab35a2d17cb
407 user: test
407 user: test
408 date: Thu Jan 01 00:00:00 1970 +0000
408 date: Thu Jan 01 00:00:00 1970 +0000
409 summary: a
409 summary: a
410
410
411
411
412 2 different branches: 2 strips
412 2 different branches: 2 strips
413
413
414 $ hg strip 2 4
414 $ hg strip 2 4
415 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
415 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
416 $ hg log -G
416 $ hg log -G
417 o changeset: 2:65bd5f99a4a3
417 o changeset: 2:65bd5f99a4a3
418 | tag: tip
418 | tag: tip
419 | user: test
419 | user: test
420 | date: Thu Jan 01 00:00:00 1970 +0000
420 | date: Thu Jan 01 00:00:00 1970 +0000
421 | summary: d
421 | summary: d
422 |
422 |
423 @ changeset: 1:ef3a871183d7
423 @ changeset: 1:ef3a871183d7
424 | user: test
424 | user: test
425 | date: Thu Jan 01 00:00:00 1970 +0000
425 | date: Thu Jan 01 00:00:00 1970 +0000
426 | summary: b
426 | summary: b
427 |
427 |
428 o changeset: 0:9ab35a2d17cb
428 o changeset: 0:9ab35a2d17cb
429 user: test
429 user: test
430 date: Thu Jan 01 00:00:00 1970 +0000
430 date: Thu Jan 01 00:00:00 1970 +0000
431 summary: a
431 summary: a
432
432
433 $ restore
433 $ restore
434
434
435 2 different branches and a common ancestor: 1 strip
435 2 different branches and a common ancestor: 1 strip
436
436
437 $ hg strip 1 "2|4"
437 $ hg strip 1 "2|4"
438 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
438 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
439 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
439 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
440 $ restore
440 $ restore
441
441
442 verify fncache is kept up-to-date
442 verify fncache is kept up-to-date
443
443
444 $ touch a
444 $ touch a
445 $ hg ci -qAm a
445 $ hg ci -qAm a
446 $ cat .hg/store/fncache | sort
446 $ cat .hg/store/fncache | sort
447 data/a.i
447 data/a.i
448 data/bar.i
448 data/bar.i
449 $ hg strip tip
449 $ hg strip tip
450 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
450 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
451 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
451 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
452 $ cat .hg/store/fncache
452 $ cat .hg/store/fncache
453 data/bar.i
453 data/bar.i
454
454
455 stripping an empty revset
455 stripping an empty revset
456
456
457 $ hg strip "1 and not 1"
457 $ hg strip "1 and not 1"
458 abort: empty revision set
458 abort: empty revision set
459 [255]
459 [255]
460
460
461 remove branchy history for qimport tests
461 remove branchy history for qimport tests
462
462
463 $ hg strip 3
463 $ hg strip 3
464 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
464 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
465
465
466
466
467 strip of applied mq should cleanup status file
467 strip of applied mq should cleanup status file
468
468
469 $ echo "mq=" >> $HGRCPATH
469 $ echo "mq=" >> $HGRCPATH
470 $ hg up -C 3
470 $ hg up -C 3
471 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
471 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
472 $ echo fooagain >> bar
472 $ echo fooagain >> bar
473 $ hg ci -mf
473 $ hg ci -mf
474 $ hg qimport -r tip:2
474 $ hg qimport -r tip:2
475
475
476 applied patches before strip
476 applied patches before strip
477
477
478 $ hg qapplied
478 $ hg qapplied
479 d
479 d
480 e
480 e
481 f
481 f
482
482
483 stripping revision in queue
483 stripping revision in queue
484
484
485 $ hg strip 3
485 $ hg strip 3
486 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
486 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
487 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
487 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
488
488
489 applied patches after stripping rev in queue
489 applied patches after stripping rev in queue
490
490
491 $ hg qapplied
491 $ hg qapplied
492 d
492 d
493
493
494 stripping ancestor of queue
494 stripping ancestor of queue
495
495
496 $ hg strip 1
496 $ hg strip 1
497 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
497 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
498 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
498 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
499
499
500 applied patches after stripping ancestor of queue
500 applied patches after stripping ancestor of queue
501
501
502 $ hg qapplied
502 $ hg qapplied
503
503
504 Verify strip protects against stripping wc parent when there are uncommitted mods
504 Verify strip protects against stripping wc parent when there are uncommitted mods
505
505
506 $ echo b > b
506 $ echo b > b
507 $ echo bb > bar
507 $ echo bb > bar
508 $ hg add b
508 $ hg add b
509 $ hg ci -m 'b'
509 $ hg ci -m 'b'
510 $ hg log --graph
510 $ hg log --graph
511 @ changeset: 1:76dcf9fab855
511 @ changeset: 1:76dcf9fab855
512 | tag: tip
512 | tag: tip
513 | user: test
513 | user: test
514 | date: Thu Jan 01 00:00:00 1970 +0000
514 | date: Thu Jan 01 00:00:00 1970 +0000
515 | summary: b
515 | summary: b
516 |
516 |
517 o changeset: 0:9ab35a2d17cb
517 o changeset: 0:9ab35a2d17cb
518 user: test
518 user: test
519 date: Thu Jan 01 00:00:00 1970 +0000
519 date: Thu Jan 01 00:00:00 1970 +0000
520 summary: a
520 summary: a
521
521
522 $ hg up 0
522 $ hg up 0
523 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
523 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
524 $ echo c > bar
524 $ echo c > bar
525 $ hg up -t false
525 $ hg up -t false
526 merging bar
526 merging bar
527 merging bar failed!
527 merging bar failed!
528 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
528 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
529 use 'hg resolve' to retry unresolved file merges
529 use 'hg resolve' to retry unresolved file merges
530 [1]
530 [1]
531 $ hg sum
531 $ hg sum
532 parent: 1:76dcf9fab855 tip
532 parent: 1:76dcf9fab855 tip
533 b
533 b
534 branch: default
534 branch: default
535 commit: 1 modified, 1 unknown, 1 unresolved
535 commit: 1 modified, 1 unknown, 1 unresolved
536 update: (current)
536 update: (current)
537 phases: 2 draft
537 phases: 2 draft
538 mq: 3 unapplied
538 mq: 3 unapplied
539
539
540 $ echo c > b
540 $ echo c > b
541 $ hg strip tip
541 $ hg strip tip
542 abort: local changes found
542 abort: local changes found
543 [255]
543 [255]
544 $ hg strip tip --keep
544 $ hg strip tip --keep
545 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
545 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
546 $ hg log --graph
546 $ hg log --graph
547 @ changeset: 0:9ab35a2d17cb
547 @ changeset: 0:9ab35a2d17cb
548 tag: tip
548 tag: tip
549 user: test
549 user: test
550 date: Thu Jan 01 00:00:00 1970 +0000
550 date: Thu Jan 01 00:00:00 1970 +0000
551 summary: a
551 summary: a
552
552
553 $ hg status
553 $ hg status
554 M bar
554 M bar
555 ? b
555 ? b
556 ? bar.orig
556 ? bar.orig
557
557
558 $ rm bar.orig
558 $ rm bar.orig
559 $ hg sum
559 $ hg sum
560 parent: 0:9ab35a2d17cb tip
560 parent: 0:9ab35a2d17cb tip
561 a
561 a
562 branch: default
562 branch: default
563 commit: 1 modified, 1 unknown
563 commit: 1 modified, 1 unknown
564 update: (current)
564 update: (current)
565 phases: 1 draft
565 phases: 1 draft
566 mq: 3 unapplied
566 mq: 3 unapplied
567
567
568 Strip adds, removes, modifies with --keep
568 Strip adds, removes, modifies with --keep
569
569
570 $ touch b
570 $ touch b
571 $ hg add b
571 $ hg add b
572 $ hg commit -mb
572 $ hg commit -mb
573 $ touch c
573 $ touch c
574
574
575 ... with a clean working dir
575 ... with a clean working dir
576
576
577 $ hg add c
577 $ hg add c
578 $ hg rm bar
578 $ hg rm bar
579 $ hg commit -mc
579 $ hg commit -mc
580 $ hg status
580 $ hg status
581 $ hg strip --keep tip
581 $ hg strip --keep tip
582 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
582 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
583 $ hg status
583 $ hg status
584 ! bar
584 ! bar
585 ? c
585 ? c
586
586
587 ... with a dirty working dir
587 ... with a dirty working dir
588
588
589 $ hg add c
589 $ hg add c
590 $ hg rm bar
590 $ hg rm bar
591 $ hg commit -mc
591 $ hg commit -mc
592 $ hg status
592 $ hg status
593 $ echo b > b
593 $ echo b > b
594 $ echo d > d
594 $ echo d > d
595 $ hg strip --keep tip
595 $ hg strip --keep tip
596 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
596 saved backup bundle to $TESTTMP/test/.hg/strip-backup/*-backup.hg (glob)
597 $ hg status
597 $ hg status
598 M b
598 M b
599 ! bar
599 ! bar
600 ? c
600 ? c
601 ? d
601 ? d
602
602
603 ... after updating the dirstate
603 ... after updating the dirstate
604 $ hg add c
604 $ hg add c
605 $ hg commit -mc
605 $ hg commit -mc
606 $ hg rm c
606 $ hg rm c
607 $ hg commit -mc
607 $ hg commit -mc
608 $ hg strip --keep '.^' -q
608 $ hg strip --keep '.^' -q
609 $ cd ..
609 $ cd ..
610
610
611 stripping many nodes on a complex graph (issue3299)
611 stripping many nodes on a complex graph (issue3299)
612
612
613 $ hg init issue3299
613 $ hg init issue3299
614 $ cd issue3299
614 $ cd issue3299
615 $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
615 $ hg debugbuilddag '@a.:a@b.:b.:x<a@a.:a<b@b.:b<a@a.:a'
616 $ hg strip 'not ancestors(x)'
616 $ hg strip 'not ancestors(x)'
617 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
617 saved backup bundle to $TESTTMP/issue3299/.hg/strip-backup/*-backup.hg (glob)
618
618
619 test hg strip -B bookmark
619 test hg strip -B bookmark
620
620
621 $ cd ..
621 $ cd ..
622 $ hg init bookmarks
622 $ hg init bookmarks
623 $ cd bookmarks
623 $ cd bookmarks
624 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b<m+2:d<2.:e<m+1:f'
624 $ hg debugbuilddag '..<2.*1/2:m<2+3:c<m+3:a<2.:b<m+2:d<2.:e<m+1:f'
625 $ hg bookmark -r 'a' 'todelete'
625 $ hg bookmark -r 'a' 'todelete'
626 $ hg bookmark -r 'b' 'B'
626 $ hg bookmark -r 'b' 'B'
627 $ hg bookmark -r 'b' 'nostrip'
627 $ hg bookmark -r 'b' 'nostrip'
628 $ hg bookmark -r 'c' 'delete'
628 $ hg bookmark -r 'c' 'delete'
629 $ hg bookmark -r 'd' 'multipledelete1'
629 $ hg bookmark -r 'd' 'multipledelete1'
630 $ hg bookmark -r 'e' 'multipledelete2'
630 $ hg bookmark -r 'e' 'multipledelete2'
631 $ hg bookmark -r 'f' 'singlenode1'
631 $ hg bookmark -r 'f' 'singlenode1'
632 $ hg bookmark -r 'f' 'singlenode2'
632 $ hg bookmark -r 'f' 'singlenode2'
633 $ hg up -C todelete
633 $ hg up -C todelete
634 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
634 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
635 (activating bookmark todelete)
635 (activating bookmark todelete)
636 $ hg strip -B nostrip
636 $ hg strip -B nostrip
637 bookmark 'nostrip' deleted
637 bookmark 'nostrip' deleted
638 abort: empty revision set
638 abort: empty revision set
639 [255]
639 [255]
640 $ hg strip -B todelete
640 $ hg strip -B todelete
641 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
641 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
642 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
642 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
643 bookmark 'todelete' deleted
643 bookmark 'todelete' deleted
644 $ hg id -ir dcbb326fdec2
644 $ hg id -ir dcbb326fdec2
645 abort: unknown revision 'dcbb326fdec2'!
645 abort: unknown revision 'dcbb326fdec2'!
646 [255]
646 [255]
647 $ hg id -ir d62d843c9a01
647 $ hg id -ir d62d843c9a01
648 d62d843c9a01
648 d62d843c9a01
649 $ hg bookmarks
649 $ hg bookmarks
650 B 9:ff43616e5d0f
650 B 9:ff43616e5d0f
651 delete 6:2702dd0c91e7
651 delete 6:2702dd0c91e7
652 multipledelete1 11:e46a4836065c
652 multipledelete1 11:e46a4836065c
653 multipledelete2 12:b4594d867745
653 multipledelete2 12:b4594d867745
654 singlenode1 13:43227190fef8
654 singlenode1 13:43227190fef8
655 singlenode2 13:43227190fef8
655 singlenode2 13:43227190fef8
656 $ hg strip -B multipledelete1 -B multipledelete2
656 $ hg strip -B multipledelete1 -B multipledelete2
657 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/e46a4836065c-89ec65c2-backup.hg (glob)
657 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/e46a4836065c-89ec65c2-backup.hg (glob)
658 bookmark 'multipledelete1' deleted
658 bookmark 'multipledelete1' deleted
659 bookmark 'multipledelete2' deleted
659 bookmark 'multipledelete2' deleted
660 $ hg id -ir e46a4836065c
660 $ hg id -ir e46a4836065c
661 abort: unknown revision 'e46a4836065c'!
661 abort: unknown revision 'e46a4836065c'!
662 [255]
662 [255]
663 $ hg id -ir b4594d867745
663 $ hg id -ir b4594d867745
664 abort: unknown revision 'b4594d867745'!
664 abort: unknown revision 'b4594d867745'!
665 [255]
665 [255]
666 $ hg strip -B singlenode1 -B singlenode2
666 $ hg strip -B singlenode1 -B singlenode2
667 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg (glob)
667 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/43227190fef8-8da858f2-backup.hg (glob)
668 bookmark 'singlenode1' deleted
668 bookmark 'singlenode1' deleted
669 bookmark 'singlenode2' deleted
669 bookmark 'singlenode2' deleted
670 $ hg id -ir 43227190fef8
670 $ hg id -ir 43227190fef8
671 abort: unknown revision '43227190fef8'!
671 abort: unknown revision '43227190fef8'!
672 [255]
672 [255]
673 $ hg strip -B unknownbookmark
673 $ hg strip -B unknownbookmark
674 abort: bookmark 'unknownbookmark' not found
674 abort: bookmark 'unknownbookmark' not found
675 [255]
675 [255]
676 $ hg strip -B unknownbookmark1 -B unknownbookmark2
676 $ hg strip -B unknownbookmark1 -B unknownbookmark2
677 abort: bookmark 'unknownbookmark1,unknownbookmark2' not found
677 abort: bookmark 'unknownbookmark1,unknownbookmark2' not found
678 [255]
678 [255]
679 $ hg strip -B delete -B unknownbookmark
679 $ hg strip -B delete -B unknownbookmark
680 abort: bookmark 'unknownbookmark' not found
680 abort: bookmark 'unknownbookmark' not found
681 [255]
681 [255]
682 $ hg strip -B delete
682 $ hg strip -B delete
683 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
683 saved backup bundle to $TESTTMP/bookmarks/.hg/strip-backup/*-backup.hg (glob)
684 bookmark 'delete' deleted
684 bookmark 'delete' deleted
685 $ hg id -ir 6:2702dd0c91e7
685 $ hg id -ir 6:2702dd0c91e7
686 abort: unknown revision '2702dd0c91e7'!
686 abort: unknown revision '2702dd0c91e7'!
687 [255]
687 [255]
688 $ hg update B
688 $ hg update B
689 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
689 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
690 (activating bookmark B)
690 (activating bookmark B)
691 $ echo a > a
691 $ echo a > a
692 $ hg add a
692 $ hg add a
693 $ hg strip -B B
693 $ hg strip -B B
694 abort: local changes found
694 abort: local changes found
695 [255]
695 [255]
696 $ hg bookmarks
696 $ hg bookmarks
697 * B 6:ff43616e5d0f
697 * B 6:ff43616e5d0f
698
698
699 Make sure no one adds back a -b option:
699 Make sure no one adds back a -b option:
700
700
701 $ hg strip -b tip
701 $ hg strip -b tip
702 hg strip: option -b not recognized
702 hg strip: option -b not recognized
703 hg strip [-k] [-f] [-B bookmark] [-r] REV...
703 hg strip [-k] [-f] [-B bookmark] [-r] REV...
704
704
705 strip changesets and all their descendants from the repository
705 strip changesets and all their descendants from the repository
706
706
707 (use "hg help -e strip" to show help for the strip extension)
707 (use "hg help -e strip" to show help for the strip extension)
708
708
709 options ([+] can be repeated):
709 options ([+] can be repeated):
710
710
711 -r --rev REV [+] strip specified revision (optional, can specify
711 -r --rev REV [+] strip specified revision (optional, can specify
712 revisions without this option)
712 revisions without this option)
713 -f --force force removal of changesets, discard uncommitted
713 -f --force force removal of changesets, discard uncommitted
714 changes (no backup)
714 changes (no backup)
715 --no-backup no backups
715 --no-backup no backups
716 -k --keep do not modify working directory during strip
716 -k --keep do not modify working directory during strip
717 -B --bookmark VALUE [+] remove revs only reachable from given bookmark
717 -B --bookmark VALUE [+] remove revs only reachable from given bookmark
718 --mq operate on patch repository
718 --mq operate on patch repository
719
719
720 (use "hg strip -h" to show more help)
720 (use "hg strip -h" to show more help)
721 [255]
721 [255]
722
722
723 $ cd ..
723 $ cd ..
724
724
725 Verify bundles don't get overwritten:
725 Verify bundles don't get overwritten:
726
726
727 $ hg init doublebundle
727 $ hg init doublebundle
728 $ cd doublebundle
728 $ cd doublebundle
729 $ touch a
729 $ touch a
730 $ hg commit -Aqm a
730 $ hg commit -Aqm a
731 $ touch b
731 $ touch b
732 $ hg commit -Aqm b
732 $ hg commit -Aqm b
733 $ hg strip -r 0
733 $ hg strip -r 0
734 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
734 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
735 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-e68910bd-backup.hg (glob)
735 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-e68910bd-backup.hg (glob)
736 $ ls .hg/strip-backup
736 $ ls .hg/strip-backup
737 3903775176ed-e68910bd-backup.hg
737 3903775176ed-e68910bd-backup.hg
738 $ hg pull -q -r 3903775176ed .hg/strip-backup/3903775176ed-e68910bd-backup.hg
738 $ hg pull -q -r 3903775176ed .hg/strip-backup/3903775176ed-e68910bd-backup.hg
739 $ hg strip -r 0
739 $ hg strip -r 0
740 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg (glob)
740 saved backup bundle to $TESTTMP/doublebundle/.hg/strip-backup/3903775176ed-54390173-backup.hg (glob)
741 $ ls .hg/strip-backup
741 $ ls .hg/strip-backup
742 3903775176ed-54390173-backup.hg
742 3903775176ed-54390173-backup.hg
743 3903775176ed-e68910bd-backup.hg
743 3903775176ed-e68910bd-backup.hg
744 $ cd ..
744 $ cd ..
745
745
746 Test that we only bundle the stripped changesets (issue4736)
746 Test that we only bundle the stripped changesets (issue4736)
747 ------------------------------------------------------------
747 ------------------------------------------------------------
748
748
749 initialization (previous repo is empty anyway)
749 initialization (previous repo is empty anyway)
750
750
751 $ hg init issue4736
751 $ hg init issue4736
752 $ cd issue4736
752 $ cd issue4736
753 $ echo a > a
753 $ echo a > a
754 $ hg add a
754 $ hg add a
755 $ hg commit -m commitA
755 $ hg commit -m commitA
756 $ echo b > b
756 $ echo b > b
757 $ hg add b
757 $ hg add b
758 $ hg commit -m commitB
758 $ hg commit -m commitB
759 $ echo c > c
759 $ echo c > c
760 $ hg add c
760 $ hg add c
761 $ hg commit -m commitC
761 $ hg commit -m commitC
762 $ hg up 'desc(commitB)'
762 $ hg up 'desc(commitB)'
763 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
763 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
764 $ echo d > d
764 $ echo d > d
765 $ hg add d
765 $ hg add d
766 $ hg commit -m commitD
766 $ hg commit -m commitD
767 created new head
767 created new head
768 $ hg up 'desc(commitC)'
768 $ hg up 'desc(commitC)'
769 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
769 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
770 $ hg merge 'desc(commitD)'
770 $ hg merge 'desc(commitD)'
771 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
771 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
772 (branch merge, don't forget to commit)
772 (branch merge, don't forget to commit)
773 $ hg ci -m 'mergeCD'
773 $ hg ci -m 'mergeCD'
774 $ hg log -G
774 $ hg log -G
775 @ changeset: 4:d8db9d137221
775 @ changeset: 4:d8db9d137221
776 |\ tag: tip
776 |\ tag: tip
777 | | parent: 2:5c51d8d6557d
777 | | parent: 2:5c51d8d6557d
778 | | parent: 3:6625a5168474
778 | | parent: 3:6625a5168474
779 | | user: test
779 | | user: test
780 | | date: Thu Jan 01 00:00:00 1970 +0000
780 | | date: Thu Jan 01 00:00:00 1970 +0000
781 | | summary: mergeCD
781 | | summary: mergeCD
782 | |
782 | |
783 | o changeset: 3:6625a5168474
783 | o changeset: 3:6625a5168474
784 | | parent: 1:eca11cf91c71
784 | | parent: 1:eca11cf91c71
785 | | user: test
785 | | user: test
786 | | date: Thu Jan 01 00:00:00 1970 +0000
786 | | date: Thu Jan 01 00:00:00 1970 +0000
787 | | summary: commitD
787 | | summary: commitD
788 | |
788 | |
789 o | changeset: 2:5c51d8d6557d
789 o | changeset: 2:5c51d8d6557d
790 |/ user: test
790 |/ user: test
791 | date: Thu Jan 01 00:00:00 1970 +0000
791 | date: Thu Jan 01 00:00:00 1970 +0000
792 | summary: commitC
792 | summary: commitC
793 |
793 |
794 o changeset: 1:eca11cf91c71
794 o changeset: 1:eca11cf91c71
795 | user: test
795 | user: test
796 | date: Thu Jan 01 00:00:00 1970 +0000
796 | date: Thu Jan 01 00:00:00 1970 +0000
797 | summary: commitB
797 | summary: commitB
798 |
798 |
799 o changeset: 0:105141ef12d0
799 o changeset: 0:105141ef12d0
800 user: test
800 user: test
801 date: Thu Jan 01 00:00:00 1970 +0000
801 date: Thu Jan 01 00:00:00 1970 +0000
802 summary: commitA
802 summary: commitA
803
803
804
804
805 Check bundle behavior:
805 Check bundle behavior:
806
806
807 $ hg bundle -r 'desc(mergeCD)' --base 'desc(commitC)' ../issue4736.hg
807 $ hg bundle -r 'desc(mergeCD)' --base 'desc(commitC)' ../issue4736.hg
808 2 changesets found
808 2 changesets found
809 $ hg log -r 'bundle()' -R ../issue4736.hg
809 $ hg log -r 'bundle()' -R ../issue4736.hg
810 changeset: 3:6625a5168474
810 changeset: 3:6625a5168474
811 parent: 1:eca11cf91c71
811 parent: 1:eca11cf91c71
812 user: test
812 user: test
813 date: Thu Jan 01 00:00:00 1970 +0000
813 date: Thu Jan 01 00:00:00 1970 +0000
814 summary: commitD
814 summary: commitD
815
815
816 changeset: 4:d8db9d137221
816 changeset: 4:d8db9d137221
817 tag: tip
817 tag: tip
818 parent: 2:5c51d8d6557d
818 parent: 2:5c51d8d6557d
819 parent: 3:6625a5168474
819 parent: 3:6625a5168474
820 user: test
820 user: test
821 date: Thu Jan 01 00:00:00 1970 +0000
821 date: Thu Jan 01 00:00:00 1970 +0000
822 summary: mergeCD
822 summary: mergeCD
823
823
824
824
825 check strip behavior
825 check strip behavior
826
826
827 $ hg --config extensions.strip= strip 'desc(commitD)' --debug
827 $ hg --config extensions.strip= strip 'desc(commitD)' --debug
828 resolving manifests
828 resolving manifests
829 branchmerge: False, force: True, partial: False
829 branchmerge: False, force: True, partial: False
830 ancestor: d8db9d137221+, local: d8db9d137221+, remote: eca11cf91c71
830 ancestor: d8db9d137221+, local: d8db9d137221+, remote: eca11cf91c71
831 c: other deleted -> r
831 c: other deleted -> r
832 removing c
832 removing c
833 d: other deleted -> r
833 d: other deleted -> r
834 removing d
834 removing d
835 starting 4 threads for background file closing (?)
835 starting 4 threads for background file closing (?)
836 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
836 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
837 2 changesets found
837 2 changesets found
838 list of changesets:
838 list of changesets:
839 6625a516847449b6f0fa3737b9ba56e9f0f3032c
839 6625a516847449b6f0fa3737b9ba56e9f0f3032c
840 d8db9d1372214336d2b5570f20ee468d2c72fa8b
840 d8db9d1372214336d2b5570f20ee468d2c72fa8b
841 bundle2-output-bundle: "HG20", (1 params) 1 parts total
841 bundle2-output-bundle: "HG20", (1 params) 1 parts total
842 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
842 bundle2-output-part: "changegroup" (params: 1 mandatory 1 advisory) streamed payload
843 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg (glob)
843 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/6625a5168474-345bb43d-backup.hg (glob)
844 invalid branchheads cache (served): tip differs
844 invalid branchheads cache (served): tip differs
845 truncating cache/rbc-revs-v1 to 24
845 truncating cache/rbc-revs-v1 to 24
846 $ hg log -G
846 $ hg log -G
847 o changeset: 2:5c51d8d6557d
847 o changeset: 2:5c51d8d6557d
848 | tag: tip
848 | tag: tip
849 | user: test
849 | user: test
850 | date: Thu Jan 01 00:00:00 1970 +0000
850 | date: Thu Jan 01 00:00:00 1970 +0000
851 | summary: commitC
851 | summary: commitC
852 |
852 |
853 @ changeset: 1:eca11cf91c71
853 @ changeset: 1:eca11cf91c71
854 | user: test
854 | user: test
855 | date: Thu Jan 01 00:00:00 1970 +0000
855 | date: Thu Jan 01 00:00:00 1970 +0000
856 | summary: commitB
856 | summary: commitB
857 |
857 |
858 o changeset: 0:105141ef12d0
858 o changeset: 0:105141ef12d0
859 user: test
859 user: test
860 date: Thu Jan 01 00:00:00 1970 +0000
860 date: Thu Jan 01 00:00:00 1970 +0000
861 summary: commitA
861 summary: commitA
862
862
863
863
864 strip backup content
864 strip backup content
865
865
866 $ hg log -r 'bundle()' -R .hg/strip-backup/6625a5168474-*-backup.hg
866 $ hg log -r 'bundle()' -R .hg/strip-backup/6625a5168474-*-backup.hg
867 changeset: 3:6625a5168474
867 changeset: 3:6625a5168474
868 parent: 1:eca11cf91c71
868 parent: 1:eca11cf91c71
869 user: test
869 user: test
870 date: Thu Jan 01 00:00:00 1970 +0000
870 date: Thu Jan 01 00:00:00 1970 +0000
871 summary: commitD
871 summary: commitD
872
872
873 changeset: 4:d8db9d137221
873 changeset: 4:d8db9d137221
874 tag: tip
874 tag: tip
875 parent: 2:5c51d8d6557d
875 parent: 2:5c51d8d6557d
876 parent: 3:6625a5168474
876 parent: 3:6625a5168474
877 user: test
877 user: test
878 date: Thu Jan 01 00:00:00 1970 +0000
878 date: Thu Jan 01 00:00:00 1970 +0000
879 summary: mergeCD
879 summary: mergeCD
880
880
881 Check that the phase cache is properly invalidated after a strip with bookmark.
881 Check that the phase cache is properly invalidated after a strip with bookmark.
882
882
883 $ cat > ../stripstalephasecache.py << EOF
883 $ cat > ../stripstalephasecache.py << EOF
884 > from mercurial import extensions, localrepo
884 > from mercurial import extensions, localrepo
885 > def transactioncallback(orig, repo, desc, *args, **kwargs):
885 > def transactioncallback(orig, repo, desc, *args, **kwargs):
886 > def test(transaction):
886 > def test(transaction):
887 > # observe cache inconsistency
887 > # observe cache inconsistency
888 > try:
888 > try:
889 > [repo.changelog.node(r) for r in repo.revs("not public()")]
889 > [repo.changelog.node(r) for r in repo.revs("not public()")]
890 > except IndexError:
890 > except IndexError:
891 > repo.ui.status("Index error!\n")
891 > repo.ui.status("Index error!\n")
892 > transaction = orig(repo, desc, *args, **kwargs)
892 > transaction = orig(repo, desc, *args, **kwargs)
893 > # warm up the phase cache
893 > # warm up the phase cache
894 > list(repo.revs("not public()"))
894 > list(repo.revs("not public()"))
895 > if desc != 'strip':
895 > if desc != 'strip':
896 > transaction.addpostclose("phase invalidation test", test)
896 > transaction.addpostclose("phase invalidation test", test)
897 > return transaction
897 > return transaction
898 > def extsetup(ui):
898 > def extsetup(ui):
899 > extensions.wrapfunction(localrepo.localrepository, "transaction",
899 > extensions.wrapfunction(localrepo.localrepository, "transaction",
900 > transactioncallback)
900 > transactioncallback)
901 > EOF
901 > EOF
902 $ hg up -C 2
902 $ hg up -C 2
903 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
903 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
904 $ echo k > k
904 $ echo k > k
905 $ hg add k
905 $ hg add k
906 $ hg commit -m commitK
906 $ hg commit -m commitK
907 $ echo l > l
907 $ echo l > l
908 $ hg add l
908 $ hg add l
909 $ hg commit -m commitL
909 $ hg commit -m commitL
910 $ hg book -r tip blah
910 $ hg book -r tip blah
911 $ hg strip ".^" --config extensions.crash=$TESTTMP/stripstalephasecache.py
911 $ hg strip ".^" --config extensions.crash=$TESTTMP/stripstalephasecache.py
912 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
912 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
913 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/8f0b4384875c-4fa10deb-backup.hg (glob)
913 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/8f0b4384875c-4fa10deb-backup.hg (glob)
914 $ hg up -C 1
914 $ hg up -C 1
915 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
915 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
916
916
917 Error during post-close callback of the strip transaction
917 Error during post-close callback of the strip transaction
918 (They should be gracefully handled and reported)
918 (They should be gracefully handled and reported)
919
919
920 $ cat > ../crashstrip.py << EOF
920 $ cat > ../crashstrip.py << EOF
921 > from mercurial import error
921 > from mercurial import error
922 > def reposetup(ui, repo):
922 > def reposetup(ui, repo):
923 > class crashstriprepo(repo.__class__):
923 > class crashstriprepo(repo.__class__):
924 > def transaction(self, desc, *args, **kwargs):
924 > def transaction(self, desc, *args, **kwargs):
925 > tr = super(crashstriprepo, self).transaction(self, desc, *args, **kwargs)
925 > tr = super(crashstriprepo, self).transaction(self, desc, *args, **kwargs)
926 > if desc == 'strip':
926 > if desc == 'strip':
927 > def crash(tra): raise error.Abort('boom')
927 > def crash(tra): raise error.Abort('boom')
928 > tr.addpostclose('crash', crash)
928 > tr.addpostclose('crash', crash)
929 > return tr
929 > return tr
930 > repo.__class__ = crashstriprepo
930 > repo.__class__ = crashstriprepo
931 > EOF
931 > EOF
932 $ hg strip tip --config extensions.crash=$TESTTMP/crashstrip.py
932 $ hg strip tip --config extensions.crash=$TESTTMP/crashstrip.py
933 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg (glob)
933 saved backup bundle to $TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg (glob)
934 strip failed, full bundle stored in '$TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg' (glob)
934 strip failed, backup bundle stored in '$TESTTMP/issue4736/.hg/strip-backup/5c51d8d6557d-70daef06-backup.hg' (glob)
935 abort: boom
935 abort: boom
936 [255]
936 [255]
937
937
938
938
General Comments 0
You need to be logged in to leave comments. Login now