##// END OF EJS Templates
pullreport: rev duplicated and extinct into account...
Boris Feld -
r39936:a89dd6d0 default
parent child Browse files
Show More
@@ -1,1802 +1,1804 b''
1 # scmutil.py - Mercurial core utility functions
1 # scmutil.py - Mercurial core utility functions
2 #
2 #
3 # Copyright Matt Mackall <mpm@selenic.com>
3 # Copyright Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 import errno
10 import errno
11 import glob
11 import glob
12 import hashlib
12 import hashlib
13 import os
13 import os
14 import re
14 import re
15 import socket
15 import socket
16 import subprocess
16 import subprocess
17 import weakref
17 import weakref
18
18
19 from .i18n import _
19 from .i18n import _
20 from .node import (
20 from .node import (
21 bin,
21 bin,
22 hex,
22 hex,
23 nullid,
23 nullid,
24 nullrev,
24 nullrev,
25 short,
25 short,
26 wdirid,
26 wdirid,
27 wdirrev,
27 wdirrev,
28 )
28 )
29
29
30 from . import (
30 from . import (
31 encoding,
31 encoding,
32 error,
32 error,
33 match as matchmod,
33 match as matchmod,
34 obsolete,
34 obsolete,
35 obsutil,
35 obsutil,
36 pathutil,
36 pathutil,
37 phases,
37 phases,
38 policy,
38 policy,
39 pycompat,
39 pycompat,
40 revsetlang,
40 revsetlang,
41 similar,
41 similar,
42 smartset,
42 smartset,
43 url,
43 url,
44 util,
44 util,
45 vfs,
45 vfs,
46 )
46 )
47
47
48 from .utils import (
48 from .utils import (
49 procutil,
49 procutil,
50 stringutil,
50 stringutil,
51 )
51 )
52
52
53 if pycompat.iswindows:
53 if pycompat.iswindows:
54 from . import scmwindows as scmplatform
54 from . import scmwindows as scmplatform
55 else:
55 else:
56 from . import scmposix as scmplatform
56 from . import scmposix as scmplatform
57
57
58 parsers = policy.importmod(r'parsers')
58 parsers = policy.importmod(r'parsers')
59
59
60 termsize = scmplatform.termsize
60 termsize = scmplatform.termsize
61
61
62 class status(tuple):
62 class status(tuple):
63 '''Named tuple with a list of files per status. The 'deleted', 'unknown'
63 '''Named tuple with a list of files per status. The 'deleted', 'unknown'
64 and 'ignored' properties are only relevant to the working copy.
64 and 'ignored' properties are only relevant to the working copy.
65 '''
65 '''
66
66
67 __slots__ = ()
67 __slots__ = ()
68
68
69 def __new__(cls, modified, added, removed, deleted, unknown, ignored,
69 def __new__(cls, modified, added, removed, deleted, unknown, ignored,
70 clean):
70 clean):
71 return tuple.__new__(cls, (modified, added, removed, deleted, unknown,
71 return tuple.__new__(cls, (modified, added, removed, deleted, unknown,
72 ignored, clean))
72 ignored, clean))
73
73
74 @property
74 @property
75 def modified(self):
75 def modified(self):
76 '''files that have been modified'''
76 '''files that have been modified'''
77 return self[0]
77 return self[0]
78
78
79 @property
79 @property
80 def added(self):
80 def added(self):
81 '''files that have been added'''
81 '''files that have been added'''
82 return self[1]
82 return self[1]
83
83
84 @property
84 @property
85 def removed(self):
85 def removed(self):
86 '''files that have been removed'''
86 '''files that have been removed'''
87 return self[2]
87 return self[2]
88
88
89 @property
89 @property
90 def deleted(self):
90 def deleted(self):
91 '''files that are in the dirstate, but have been deleted from the
91 '''files that are in the dirstate, but have been deleted from the
92 working copy (aka "missing")
92 working copy (aka "missing")
93 '''
93 '''
94 return self[3]
94 return self[3]
95
95
96 @property
96 @property
97 def unknown(self):
97 def unknown(self):
98 '''files not in the dirstate that are not ignored'''
98 '''files not in the dirstate that are not ignored'''
99 return self[4]
99 return self[4]
100
100
101 @property
101 @property
102 def ignored(self):
102 def ignored(self):
103 '''files not in the dirstate that are ignored (by _dirignore())'''
103 '''files not in the dirstate that are ignored (by _dirignore())'''
104 return self[5]
104 return self[5]
105
105
106 @property
106 @property
107 def clean(self):
107 def clean(self):
108 '''files that have not been modified'''
108 '''files that have not been modified'''
109 return self[6]
109 return self[6]
110
110
111 def __repr__(self, *args, **kwargs):
111 def __repr__(self, *args, **kwargs):
112 return ((r'<status modified=%s, added=%s, removed=%s, deleted=%s, '
112 return ((r'<status modified=%s, added=%s, removed=%s, deleted=%s, '
113 r'unknown=%s, ignored=%s, clean=%s>') %
113 r'unknown=%s, ignored=%s, clean=%s>') %
114 tuple(pycompat.sysstr(stringutil.pprint(v)) for v in self))
114 tuple(pycompat.sysstr(stringutil.pprint(v)) for v in self))
115
115
116 def itersubrepos(ctx1, ctx2):
116 def itersubrepos(ctx1, ctx2):
117 """find subrepos in ctx1 or ctx2"""
117 """find subrepos in ctx1 or ctx2"""
118 # Create a (subpath, ctx) mapping where we prefer subpaths from
118 # Create a (subpath, ctx) mapping where we prefer subpaths from
119 # ctx1. The subpaths from ctx2 are important when the .hgsub file
119 # ctx1. The subpaths from ctx2 are important when the .hgsub file
120 # has been modified (in ctx2) but not yet committed (in ctx1).
120 # has been modified (in ctx2) but not yet committed (in ctx1).
121 subpaths = dict.fromkeys(ctx2.substate, ctx2)
121 subpaths = dict.fromkeys(ctx2.substate, ctx2)
122 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
122 subpaths.update(dict.fromkeys(ctx1.substate, ctx1))
123
123
124 missing = set()
124 missing = set()
125
125
126 for subpath in ctx2.substate:
126 for subpath in ctx2.substate:
127 if subpath not in ctx1.substate:
127 if subpath not in ctx1.substate:
128 del subpaths[subpath]
128 del subpaths[subpath]
129 missing.add(subpath)
129 missing.add(subpath)
130
130
131 for subpath, ctx in sorted(subpaths.iteritems()):
131 for subpath, ctx in sorted(subpaths.iteritems()):
132 yield subpath, ctx.sub(subpath)
132 yield subpath, ctx.sub(subpath)
133
133
134 # Yield an empty subrepo based on ctx1 for anything only in ctx2. That way,
134 # Yield an empty subrepo based on ctx1 for anything only in ctx2. That way,
135 # status and diff will have an accurate result when it does
135 # status and diff will have an accurate result when it does
136 # 'sub.{status|diff}(rev2)'. Otherwise, the ctx2 subrepo is compared
136 # 'sub.{status|diff}(rev2)'. Otherwise, the ctx2 subrepo is compared
137 # against itself.
137 # against itself.
138 for subpath in missing:
138 for subpath in missing:
139 yield subpath, ctx2.nullsub(subpath, ctx1)
139 yield subpath, ctx2.nullsub(subpath, ctx1)
140
140
141 def nochangesfound(ui, repo, excluded=None):
141 def nochangesfound(ui, repo, excluded=None):
142 '''Report no changes for push/pull, excluded is None or a list of
142 '''Report no changes for push/pull, excluded is None or a list of
143 nodes excluded from the push/pull.
143 nodes excluded from the push/pull.
144 '''
144 '''
145 secretlist = []
145 secretlist = []
146 if excluded:
146 if excluded:
147 for n in excluded:
147 for n in excluded:
148 ctx = repo[n]
148 ctx = repo[n]
149 if ctx.phase() >= phases.secret and not ctx.extinct():
149 if ctx.phase() >= phases.secret and not ctx.extinct():
150 secretlist.append(n)
150 secretlist.append(n)
151
151
152 if secretlist:
152 if secretlist:
153 ui.status(_("no changes found (ignored %d secret changesets)\n")
153 ui.status(_("no changes found (ignored %d secret changesets)\n")
154 % len(secretlist))
154 % len(secretlist))
155 else:
155 else:
156 ui.status(_("no changes found\n"))
156 ui.status(_("no changes found\n"))
157
157
158 def callcatch(ui, func):
158 def callcatch(ui, func):
159 """call func() with global exception handling
159 """call func() with global exception handling
160
160
161 return func() if no exception happens. otherwise do some error handling
161 return func() if no exception happens. otherwise do some error handling
162 and return an exit code accordingly. does not handle all exceptions.
162 and return an exit code accordingly. does not handle all exceptions.
163 """
163 """
164 try:
164 try:
165 try:
165 try:
166 return func()
166 return func()
167 except: # re-raises
167 except: # re-raises
168 ui.traceback()
168 ui.traceback()
169 raise
169 raise
170 # Global exception handling, alphabetically
170 # Global exception handling, alphabetically
171 # Mercurial-specific first, followed by built-in and library exceptions
171 # Mercurial-specific first, followed by built-in and library exceptions
172 except error.LockHeld as inst:
172 except error.LockHeld as inst:
173 if inst.errno == errno.ETIMEDOUT:
173 if inst.errno == errno.ETIMEDOUT:
174 reason = _('timed out waiting for lock held by %r') % inst.locker
174 reason = _('timed out waiting for lock held by %r') % inst.locker
175 else:
175 else:
176 reason = _('lock held by %r') % inst.locker
176 reason = _('lock held by %r') % inst.locker
177 ui.error(_("abort: %s: %s\n") % (
177 ui.error(_("abort: %s: %s\n") % (
178 inst.desc or stringutil.forcebytestr(inst.filename), reason))
178 inst.desc or stringutil.forcebytestr(inst.filename), reason))
179 if not inst.locker:
179 if not inst.locker:
180 ui.error(_("(lock might be very busy)\n"))
180 ui.error(_("(lock might be very busy)\n"))
181 except error.LockUnavailable as inst:
181 except error.LockUnavailable as inst:
182 ui.error(_("abort: could not lock %s: %s\n") %
182 ui.error(_("abort: could not lock %s: %s\n") %
183 (inst.desc or stringutil.forcebytestr(inst.filename),
183 (inst.desc or stringutil.forcebytestr(inst.filename),
184 encoding.strtolocal(inst.strerror)))
184 encoding.strtolocal(inst.strerror)))
185 except error.OutOfBandError as inst:
185 except error.OutOfBandError as inst:
186 if inst.args:
186 if inst.args:
187 msg = _("abort: remote error:\n")
187 msg = _("abort: remote error:\n")
188 else:
188 else:
189 msg = _("abort: remote error\n")
189 msg = _("abort: remote error\n")
190 ui.error(msg)
190 ui.error(msg)
191 if inst.args:
191 if inst.args:
192 ui.error(''.join(inst.args))
192 ui.error(''.join(inst.args))
193 if inst.hint:
193 if inst.hint:
194 ui.error('(%s)\n' % inst.hint)
194 ui.error('(%s)\n' % inst.hint)
195 except error.RepoError as inst:
195 except error.RepoError as inst:
196 ui.error(_("abort: %s!\n") % inst)
196 ui.error(_("abort: %s!\n") % inst)
197 if inst.hint:
197 if inst.hint:
198 ui.error(_("(%s)\n") % inst.hint)
198 ui.error(_("(%s)\n") % inst.hint)
199 except error.ResponseError as inst:
199 except error.ResponseError as inst:
200 ui.error(_("abort: %s") % inst.args[0])
200 ui.error(_("abort: %s") % inst.args[0])
201 msg = inst.args[1]
201 msg = inst.args[1]
202 if isinstance(msg, type(u'')):
202 if isinstance(msg, type(u'')):
203 msg = pycompat.sysbytes(msg)
203 msg = pycompat.sysbytes(msg)
204 if not isinstance(msg, bytes):
204 if not isinstance(msg, bytes):
205 ui.error(" %r\n" % (msg,))
205 ui.error(" %r\n" % (msg,))
206 elif not msg:
206 elif not msg:
207 ui.error(_(" empty string\n"))
207 ui.error(_(" empty string\n"))
208 else:
208 else:
209 ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
209 ui.error("\n%r\n" % pycompat.bytestr(stringutil.ellipsis(msg)))
210 except error.CensoredNodeError as inst:
210 except error.CensoredNodeError as inst:
211 ui.error(_("abort: file censored %s!\n") % inst)
211 ui.error(_("abort: file censored %s!\n") % inst)
212 except error.StorageError as inst:
212 except error.StorageError as inst:
213 ui.error(_("abort: %s!\n") % inst)
213 ui.error(_("abort: %s!\n") % inst)
214 except error.InterventionRequired as inst:
214 except error.InterventionRequired as inst:
215 ui.error("%s\n" % inst)
215 ui.error("%s\n" % inst)
216 if inst.hint:
216 if inst.hint:
217 ui.error(_("(%s)\n") % inst.hint)
217 ui.error(_("(%s)\n") % inst.hint)
218 return 1
218 return 1
219 except error.WdirUnsupported:
219 except error.WdirUnsupported:
220 ui.error(_("abort: working directory revision cannot be specified\n"))
220 ui.error(_("abort: working directory revision cannot be specified\n"))
221 except error.Abort as inst:
221 except error.Abort as inst:
222 ui.error(_("abort: %s\n") % inst)
222 ui.error(_("abort: %s\n") % inst)
223 if inst.hint:
223 if inst.hint:
224 ui.error(_("(%s)\n") % inst.hint)
224 ui.error(_("(%s)\n") % inst.hint)
225 except ImportError as inst:
225 except ImportError as inst:
226 ui.error(_("abort: %s!\n") % stringutil.forcebytestr(inst))
226 ui.error(_("abort: %s!\n") % stringutil.forcebytestr(inst))
227 m = stringutil.forcebytestr(inst).split()[-1]
227 m = stringutil.forcebytestr(inst).split()[-1]
228 if m in "mpatch bdiff".split():
228 if m in "mpatch bdiff".split():
229 ui.error(_("(did you forget to compile extensions?)\n"))
229 ui.error(_("(did you forget to compile extensions?)\n"))
230 elif m in "zlib".split():
230 elif m in "zlib".split():
231 ui.error(_("(is your Python install correct?)\n"))
231 ui.error(_("(is your Python install correct?)\n"))
232 except IOError as inst:
232 except IOError as inst:
233 if util.safehasattr(inst, "code"):
233 if util.safehasattr(inst, "code"):
234 ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst))
234 ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst))
235 elif util.safehasattr(inst, "reason"):
235 elif util.safehasattr(inst, "reason"):
236 try: # usually it is in the form (errno, strerror)
236 try: # usually it is in the form (errno, strerror)
237 reason = inst.reason.args[1]
237 reason = inst.reason.args[1]
238 except (AttributeError, IndexError):
238 except (AttributeError, IndexError):
239 # it might be anything, for example a string
239 # it might be anything, for example a string
240 reason = inst.reason
240 reason = inst.reason
241 if isinstance(reason, pycompat.unicode):
241 if isinstance(reason, pycompat.unicode):
242 # SSLError of Python 2.7.9 contains a unicode
242 # SSLError of Python 2.7.9 contains a unicode
243 reason = encoding.unitolocal(reason)
243 reason = encoding.unitolocal(reason)
244 ui.error(_("abort: error: %s\n") % reason)
244 ui.error(_("abort: error: %s\n") % reason)
245 elif (util.safehasattr(inst, "args")
245 elif (util.safehasattr(inst, "args")
246 and inst.args and inst.args[0] == errno.EPIPE):
246 and inst.args and inst.args[0] == errno.EPIPE):
247 pass
247 pass
248 elif getattr(inst, "strerror", None):
248 elif getattr(inst, "strerror", None):
249 if getattr(inst, "filename", None):
249 if getattr(inst, "filename", None):
250 ui.error(_("abort: %s: %s\n") % (
250 ui.error(_("abort: %s: %s\n") % (
251 encoding.strtolocal(inst.strerror),
251 encoding.strtolocal(inst.strerror),
252 stringutil.forcebytestr(inst.filename)))
252 stringutil.forcebytestr(inst.filename)))
253 else:
253 else:
254 ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
254 ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
255 else:
255 else:
256 raise
256 raise
257 except OSError as inst:
257 except OSError as inst:
258 if getattr(inst, "filename", None) is not None:
258 if getattr(inst, "filename", None) is not None:
259 ui.error(_("abort: %s: '%s'\n") % (
259 ui.error(_("abort: %s: '%s'\n") % (
260 encoding.strtolocal(inst.strerror),
260 encoding.strtolocal(inst.strerror),
261 stringutil.forcebytestr(inst.filename)))
261 stringutil.forcebytestr(inst.filename)))
262 else:
262 else:
263 ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
263 ui.error(_("abort: %s\n") % encoding.strtolocal(inst.strerror))
264 except MemoryError:
264 except MemoryError:
265 ui.error(_("abort: out of memory\n"))
265 ui.error(_("abort: out of memory\n"))
266 except SystemExit as inst:
266 except SystemExit as inst:
267 # Commands shouldn't sys.exit directly, but give a return code.
267 # Commands shouldn't sys.exit directly, but give a return code.
268 # Just in case catch this and and pass exit code to caller.
268 # Just in case catch this and and pass exit code to caller.
269 return inst.code
269 return inst.code
270 except socket.error as inst:
270 except socket.error as inst:
271 ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst.args[-1]))
271 ui.error(_("abort: %s\n") % stringutil.forcebytestr(inst.args[-1]))
272
272
273 return -1
273 return -1
274
274
275 def checknewlabel(repo, lbl, kind):
275 def checknewlabel(repo, lbl, kind):
276 # Do not use the "kind" parameter in ui output.
276 # Do not use the "kind" parameter in ui output.
277 # It makes strings difficult to translate.
277 # It makes strings difficult to translate.
278 if lbl in ['tip', '.', 'null']:
278 if lbl in ['tip', '.', 'null']:
279 raise error.Abort(_("the name '%s' is reserved") % lbl)
279 raise error.Abort(_("the name '%s' is reserved") % lbl)
280 for c in (':', '\0', '\n', '\r'):
280 for c in (':', '\0', '\n', '\r'):
281 if c in lbl:
281 if c in lbl:
282 raise error.Abort(
282 raise error.Abort(
283 _("%r cannot be used in a name") % pycompat.bytestr(c))
283 _("%r cannot be used in a name") % pycompat.bytestr(c))
284 try:
284 try:
285 int(lbl)
285 int(lbl)
286 raise error.Abort(_("cannot use an integer as a name"))
286 raise error.Abort(_("cannot use an integer as a name"))
287 except ValueError:
287 except ValueError:
288 pass
288 pass
289 if lbl.strip() != lbl:
289 if lbl.strip() != lbl:
290 raise error.Abort(_("leading or trailing whitespace in name %r") % lbl)
290 raise error.Abort(_("leading or trailing whitespace in name %r") % lbl)
291
291
292 def checkfilename(f):
292 def checkfilename(f):
293 '''Check that the filename f is an acceptable filename for a tracked file'''
293 '''Check that the filename f is an acceptable filename for a tracked file'''
294 if '\r' in f or '\n' in f:
294 if '\r' in f or '\n' in f:
295 raise error.Abort(_("'\\n' and '\\r' disallowed in filenames: %r")
295 raise error.Abort(_("'\\n' and '\\r' disallowed in filenames: %r")
296 % pycompat.bytestr(f))
296 % pycompat.bytestr(f))
297
297
298 def checkportable(ui, f):
298 def checkportable(ui, f):
299 '''Check if filename f is portable and warn or abort depending on config'''
299 '''Check if filename f is portable and warn or abort depending on config'''
300 checkfilename(f)
300 checkfilename(f)
301 abort, warn = checkportabilityalert(ui)
301 abort, warn = checkportabilityalert(ui)
302 if abort or warn:
302 if abort or warn:
303 msg = util.checkwinfilename(f)
303 msg = util.checkwinfilename(f)
304 if msg:
304 if msg:
305 msg = "%s: %s" % (msg, procutil.shellquote(f))
305 msg = "%s: %s" % (msg, procutil.shellquote(f))
306 if abort:
306 if abort:
307 raise error.Abort(msg)
307 raise error.Abort(msg)
308 ui.warn(_("warning: %s\n") % msg)
308 ui.warn(_("warning: %s\n") % msg)
309
309
310 def checkportabilityalert(ui):
310 def checkportabilityalert(ui):
311 '''check if the user's config requests nothing, a warning, or abort for
311 '''check if the user's config requests nothing, a warning, or abort for
312 non-portable filenames'''
312 non-portable filenames'''
313 val = ui.config('ui', 'portablefilenames')
313 val = ui.config('ui', 'portablefilenames')
314 lval = val.lower()
314 lval = val.lower()
315 bval = stringutil.parsebool(val)
315 bval = stringutil.parsebool(val)
316 abort = pycompat.iswindows or lval == 'abort'
316 abort = pycompat.iswindows or lval == 'abort'
317 warn = bval or lval == 'warn'
317 warn = bval or lval == 'warn'
318 if bval is None and not (warn or abort or lval == 'ignore'):
318 if bval is None and not (warn or abort or lval == 'ignore'):
319 raise error.ConfigError(
319 raise error.ConfigError(
320 _("ui.portablefilenames value is invalid ('%s')") % val)
320 _("ui.portablefilenames value is invalid ('%s')") % val)
321 return abort, warn
321 return abort, warn
322
322
323 class casecollisionauditor(object):
323 class casecollisionauditor(object):
324 def __init__(self, ui, abort, dirstate):
324 def __init__(self, ui, abort, dirstate):
325 self._ui = ui
325 self._ui = ui
326 self._abort = abort
326 self._abort = abort
327 allfiles = '\0'.join(dirstate._map)
327 allfiles = '\0'.join(dirstate._map)
328 self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
328 self._loweredfiles = set(encoding.lower(allfiles).split('\0'))
329 self._dirstate = dirstate
329 self._dirstate = dirstate
330 # The purpose of _newfiles is so that we don't complain about
330 # The purpose of _newfiles is so that we don't complain about
331 # case collisions if someone were to call this object with the
331 # case collisions if someone were to call this object with the
332 # same filename twice.
332 # same filename twice.
333 self._newfiles = set()
333 self._newfiles = set()
334
334
335 def __call__(self, f):
335 def __call__(self, f):
336 if f in self._newfiles:
336 if f in self._newfiles:
337 return
337 return
338 fl = encoding.lower(f)
338 fl = encoding.lower(f)
339 if fl in self._loweredfiles and f not in self._dirstate:
339 if fl in self._loweredfiles and f not in self._dirstate:
340 msg = _('possible case-folding collision for %s') % f
340 msg = _('possible case-folding collision for %s') % f
341 if self._abort:
341 if self._abort:
342 raise error.Abort(msg)
342 raise error.Abort(msg)
343 self._ui.warn(_("warning: %s\n") % msg)
343 self._ui.warn(_("warning: %s\n") % msg)
344 self._loweredfiles.add(fl)
344 self._loweredfiles.add(fl)
345 self._newfiles.add(f)
345 self._newfiles.add(f)
346
346
347 def filteredhash(repo, maxrev):
347 def filteredhash(repo, maxrev):
348 """build hash of filtered revisions in the current repoview.
348 """build hash of filtered revisions in the current repoview.
349
349
350 Multiple caches perform up-to-date validation by checking that the
350 Multiple caches perform up-to-date validation by checking that the
351 tiprev and tipnode stored in the cache file match the current repository.
351 tiprev and tipnode stored in the cache file match the current repository.
352 However, this is not sufficient for validating repoviews because the set
352 However, this is not sufficient for validating repoviews because the set
353 of revisions in the view may change without the repository tiprev and
353 of revisions in the view may change without the repository tiprev and
354 tipnode changing.
354 tipnode changing.
355
355
356 This function hashes all the revs filtered from the view and returns
356 This function hashes all the revs filtered from the view and returns
357 that SHA-1 digest.
357 that SHA-1 digest.
358 """
358 """
359 cl = repo.changelog
359 cl = repo.changelog
360 if not cl.filteredrevs:
360 if not cl.filteredrevs:
361 return None
361 return None
362 key = None
362 key = None
363 revs = sorted(r for r in cl.filteredrevs if r <= maxrev)
363 revs = sorted(r for r in cl.filteredrevs if r <= maxrev)
364 if revs:
364 if revs:
365 s = hashlib.sha1()
365 s = hashlib.sha1()
366 for rev in revs:
366 for rev in revs:
367 s.update('%d;' % rev)
367 s.update('%d;' % rev)
368 key = s.digest()
368 key = s.digest()
369 return key
369 return key
370
370
371 def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
371 def walkrepos(path, followsym=False, seen_dirs=None, recurse=False):
372 '''yield every hg repository under path, always recursively.
372 '''yield every hg repository under path, always recursively.
373 The recurse flag will only control recursion into repo working dirs'''
373 The recurse flag will only control recursion into repo working dirs'''
374 def errhandler(err):
374 def errhandler(err):
375 if err.filename == path:
375 if err.filename == path:
376 raise err
376 raise err
377 samestat = getattr(os.path, 'samestat', None)
377 samestat = getattr(os.path, 'samestat', None)
378 if followsym and samestat is not None:
378 if followsym and samestat is not None:
379 def adddir(dirlst, dirname):
379 def adddir(dirlst, dirname):
380 dirstat = os.stat(dirname)
380 dirstat = os.stat(dirname)
381 match = any(samestat(dirstat, lstdirstat) for lstdirstat in dirlst)
381 match = any(samestat(dirstat, lstdirstat) for lstdirstat in dirlst)
382 if not match:
382 if not match:
383 dirlst.append(dirstat)
383 dirlst.append(dirstat)
384 return not match
384 return not match
385 else:
385 else:
386 followsym = False
386 followsym = False
387
387
388 if (seen_dirs is None) and followsym:
388 if (seen_dirs is None) and followsym:
389 seen_dirs = []
389 seen_dirs = []
390 adddir(seen_dirs, path)
390 adddir(seen_dirs, path)
391 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
391 for root, dirs, files in os.walk(path, topdown=True, onerror=errhandler):
392 dirs.sort()
392 dirs.sort()
393 if '.hg' in dirs:
393 if '.hg' in dirs:
394 yield root # found a repository
394 yield root # found a repository
395 qroot = os.path.join(root, '.hg', 'patches')
395 qroot = os.path.join(root, '.hg', 'patches')
396 if os.path.isdir(os.path.join(qroot, '.hg')):
396 if os.path.isdir(os.path.join(qroot, '.hg')):
397 yield qroot # we have a patch queue repo here
397 yield qroot # we have a patch queue repo here
398 if recurse:
398 if recurse:
399 # avoid recursing inside the .hg directory
399 # avoid recursing inside the .hg directory
400 dirs.remove('.hg')
400 dirs.remove('.hg')
401 else:
401 else:
402 dirs[:] = [] # don't descend further
402 dirs[:] = [] # don't descend further
403 elif followsym:
403 elif followsym:
404 newdirs = []
404 newdirs = []
405 for d in dirs:
405 for d in dirs:
406 fname = os.path.join(root, d)
406 fname = os.path.join(root, d)
407 if adddir(seen_dirs, fname):
407 if adddir(seen_dirs, fname):
408 if os.path.islink(fname):
408 if os.path.islink(fname):
409 for hgname in walkrepos(fname, True, seen_dirs):
409 for hgname in walkrepos(fname, True, seen_dirs):
410 yield hgname
410 yield hgname
411 else:
411 else:
412 newdirs.append(d)
412 newdirs.append(d)
413 dirs[:] = newdirs
413 dirs[:] = newdirs
414
414
415 def binnode(ctx):
415 def binnode(ctx):
416 """Return binary node id for a given basectx"""
416 """Return binary node id for a given basectx"""
417 node = ctx.node()
417 node = ctx.node()
418 if node is None:
418 if node is None:
419 return wdirid
419 return wdirid
420 return node
420 return node
421
421
422 def intrev(ctx):
422 def intrev(ctx):
423 """Return integer for a given basectx that can be used in comparison or
423 """Return integer for a given basectx that can be used in comparison or
424 arithmetic operation"""
424 arithmetic operation"""
425 rev = ctx.rev()
425 rev = ctx.rev()
426 if rev is None:
426 if rev is None:
427 return wdirrev
427 return wdirrev
428 return rev
428 return rev
429
429
430 def formatchangeid(ctx):
430 def formatchangeid(ctx):
431 """Format changectx as '{rev}:{node|formatnode}', which is the default
431 """Format changectx as '{rev}:{node|formatnode}', which is the default
432 template provided by logcmdutil.changesettemplater"""
432 template provided by logcmdutil.changesettemplater"""
433 repo = ctx.repo()
433 repo = ctx.repo()
434 return formatrevnode(repo.ui, intrev(ctx), binnode(ctx))
434 return formatrevnode(repo.ui, intrev(ctx), binnode(ctx))
435
435
436 def formatrevnode(ui, rev, node):
436 def formatrevnode(ui, rev, node):
437 """Format given revision and node depending on the current verbosity"""
437 """Format given revision and node depending on the current verbosity"""
438 if ui.debugflag:
438 if ui.debugflag:
439 hexfunc = hex
439 hexfunc = hex
440 else:
440 else:
441 hexfunc = short
441 hexfunc = short
442 return '%d:%s' % (rev, hexfunc(node))
442 return '%d:%s' % (rev, hexfunc(node))
443
443
444 def resolvehexnodeidprefix(repo, prefix):
444 def resolvehexnodeidprefix(repo, prefix):
445 if (prefix.startswith('x') and
445 if (prefix.startswith('x') and
446 repo.ui.configbool('experimental', 'revisions.prefixhexnode')):
446 repo.ui.configbool('experimental', 'revisions.prefixhexnode')):
447 prefix = prefix[1:]
447 prefix = prefix[1:]
448 try:
448 try:
449 # Uses unfiltered repo because it's faster when prefix is ambiguous/
449 # Uses unfiltered repo because it's faster when prefix is ambiguous/
450 # This matches the shortesthexnodeidprefix() function below.
450 # This matches the shortesthexnodeidprefix() function below.
451 node = repo.unfiltered().changelog._partialmatch(prefix)
451 node = repo.unfiltered().changelog._partialmatch(prefix)
452 except error.AmbiguousPrefixLookupError:
452 except error.AmbiguousPrefixLookupError:
453 revset = repo.ui.config('experimental', 'revisions.disambiguatewithin')
453 revset = repo.ui.config('experimental', 'revisions.disambiguatewithin')
454 if revset:
454 if revset:
455 # Clear config to avoid infinite recursion
455 # Clear config to avoid infinite recursion
456 configoverrides = {('experimental',
456 configoverrides = {('experimental',
457 'revisions.disambiguatewithin'): None}
457 'revisions.disambiguatewithin'): None}
458 with repo.ui.configoverride(configoverrides):
458 with repo.ui.configoverride(configoverrides):
459 revs = repo.anyrevs([revset], user=True)
459 revs = repo.anyrevs([revset], user=True)
460 matches = []
460 matches = []
461 for rev in revs:
461 for rev in revs:
462 node = repo.changelog.node(rev)
462 node = repo.changelog.node(rev)
463 if hex(node).startswith(prefix):
463 if hex(node).startswith(prefix):
464 matches.append(node)
464 matches.append(node)
465 if len(matches) == 1:
465 if len(matches) == 1:
466 return matches[0]
466 return matches[0]
467 raise
467 raise
468 if node is None:
468 if node is None:
469 return
469 return
470 repo.changelog.rev(node) # make sure node isn't filtered
470 repo.changelog.rev(node) # make sure node isn't filtered
471 return node
471 return node
472
472
473 def mayberevnum(repo, prefix):
473 def mayberevnum(repo, prefix):
474 """Checks if the given prefix may be mistaken for a revision number"""
474 """Checks if the given prefix may be mistaken for a revision number"""
475 try:
475 try:
476 i = int(prefix)
476 i = int(prefix)
477 # if we are a pure int, then starting with zero will not be
477 # if we are a pure int, then starting with zero will not be
478 # confused as a rev; or, obviously, if the int is larger
478 # confused as a rev; or, obviously, if the int is larger
479 # than the value of the tip rev
479 # than the value of the tip rev
480 if prefix[0:1] == b'0' or i >= len(repo):
480 if prefix[0:1] == b'0' or i >= len(repo):
481 return False
481 return False
482 return True
482 return True
483 except ValueError:
483 except ValueError:
484 return False
484 return False
485
485
486 def shortesthexnodeidprefix(repo, node, minlength=1, cache=None):
486 def shortesthexnodeidprefix(repo, node, minlength=1, cache=None):
487 """Find the shortest unambiguous prefix that matches hexnode.
487 """Find the shortest unambiguous prefix that matches hexnode.
488
488
489 If "cache" is not None, it must be a dictionary that can be used for
489 If "cache" is not None, it must be a dictionary that can be used for
490 caching between calls to this method.
490 caching between calls to this method.
491 """
491 """
492 # _partialmatch() of filtered changelog could take O(len(repo)) time,
492 # _partialmatch() of filtered changelog could take O(len(repo)) time,
493 # which would be unacceptably slow. so we look for hash collision in
493 # which would be unacceptably slow. so we look for hash collision in
494 # unfiltered space, which means some hashes may be slightly longer.
494 # unfiltered space, which means some hashes may be slightly longer.
495
495
496 def disambiguate(prefix):
496 def disambiguate(prefix):
497 """Disambiguate against revnums."""
497 """Disambiguate against revnums."""
498 if repo.ui.configbool('experimental', 'revisions.prefixhexnode'):
498 if repo.ui.configbool('experimental', 'revisions.prefixhexnode'):
499 if mayberevnum(repo, prefix):
499 if mayberevnum(repo, prefix):
500 return 'x' + prefix
500 return 'x' + prefix
501 else:
501 else:
502 return prefix
502 return prefix
503
503
504 hexnode = hex(node)
504 hexnode = hex(node)
505 for length in range(len(prefix), len(hexnode) + 1):
505 for length in range(len(prefix), len(hexnode) + 1):
506 prefix = hexnode[:length]
506 prefix = hexnode[:length]
507 if not mayberevnum(repo, prefix):
507 if not mayberevnum(repo, prefix):
508 return prefix
508 return prefix
509
509
510 cl = repo.unfiltered().changelog
510 cl = repo.unfiltered().changelog
511 revset = repo.ui.config('experimental', 'revisions.disambiguatewithin')
511 revset = repo.ui.config('experimental', 'revisions.disambiguatewithin')
512 if revset:
512 if revset:
513 revs = None
513 revs = None
514 if cache is not None:
514 if cache is not None:
515 revs = cache.get('disambiguationrevset')
515 revs = cache.get('disambiguationrevset')
516 if revs is None:
516 if revs is None:
517 revs = repo.anyrevs([revset], user=True)
517 revs = repo.anyrevs([revset], user=True)
518 if cache is not None:
518 if cache is not None:
519 cache['disambiguationrevset'] = revs
519 cache['disambiguationrevset'] = revs
520 if cl.rev(node) in revs:
520 if cl.rev(node) in revs:
521 hexnode = hex(node)
521 hexnode = hex(node)
522 nodetree = None
522 nodetree = None
523 if cache is not None:
523 if cache is not None:
524 nodetree = cache.get('disambiguationnodetree')
524 nodetree = cache.get('disambiguationnodetree')
525 if not nodetree:
525 if not nodetree:
526 try:
526 try:
527 nodetree = parsers.nodetree(cl.index, len(revs))
527 nodetree = parsers.nodetree(cl.index, len(revs))
528 except AttributeError:
528 except AttributeError:
529 # no native nodetree
529 # no native nodetree
530 pass
530 pass
531 else:
531 else:
532 for r in revs:
532 for r in revs:
533 nodetree.insert(r)
533 nodetree.insert(r)
534 if cache is not None:
534 if cache is not None:
535 cache['disambiguationnodetree'] = nodetree
535 cache['disambiguationnodetree'] = nodetree
536 if nodetree is not None:
536 if nodetree is not None:
537 length = max(nodetree.shortest(node), minlength)
537 length = max(nodetree.shortest(node), minlength)
538 prefix = hexnode[:length]
538 prefix = hexnode[:length]
539 return disambiguate(prefix)
539 return disambiguate(prefix)
540 for length in range(minlength, len(hexnode) + 1):
540 for length in range(minlength, len(hexnode) + 1):
541 matches = []
541 matches = []
542 prefix = hexnode[:length]
542 prefix = hexnode[:length]
543 for rev in revs:
543 for rev in revs:
544 otherhexnode = repo[rev].hex()
544 otherhexnode = repo[rev].hex()
545 if prefix == otherhexnode[:length]:
545 if prefix == otherhexnode[:length]:
546 matches.append(otherhexnode)
546 matches.append(otherhexnode)
547 if len(matches) == 1:
547 if len(matches) == 1:
548 return disambiguate(prefix)
548 return disambiguate(prefix)
549
549
550 try:
550 try:
551 return disambiguate(cl.shortest(node, minlength))
551 return disambiguate(cl.shortest(node, minlength))
552 except error.LookupError:
552 except error.LookupError:
553 raise error.RepoLookupError()
553 raise error.RepoLookupError()
554
554
555 def isrevsymbol(repo, symbol):
555 def isrevsymbol(repo, symbol):
556 """Checks if a symbol exists in the repo.
556 """Checks if a symbol exists in the repo.
557
557
558 See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the
558 See revsymbol() for details. Raises error.AmbiguousPrefixLookupError if the
559 symbol is an ambiguous nodeid prefix.
559 symbol is an ambiguous nodeid prefix.
560 """
560 """
561 try:
561 try:
562 revsymbol(repo, symbol)
562 revsymbol(repo, symbol)
563 return True
563 return True
564 except error.RepoLookupError:
564 except error.RepoLookupError:
565 return False
565 return False
566
566
567 def revsymbol(repo, symbol):
567 def revsymbol(repo, symbol):
568 """Returns a context given a single revision symbol (as string).
568 """Returns a context given a single revision symbol (as string).
569
569
570 This is similar to revsingle(), but accepts only a single revision symbol,
570 This is similar to revsingle(), but accepts only a single revision symbol,
571 i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but
571 i.e. things like ".", "tip", "1234", "deadbeef", "my-bookmark" work, but
572 not "max(public())".
572 not "max(public())".
573 """
573 """
574 if not isinstance(symbol, bytes):
574 if not isinstance(symbol, bytes):
575 msg = ("symbol (%s of type %s) was not a string, did you mean "
575 msg = ("symbol (%s of type %s) was not a string, did you mean "
576 "repo[symbol]?" % (symbol, type(symbol)))
576 "repo[symbol]?" % (symbol, type(symbol)))
577 raise error.ProgrammingError(msg)
577 raise error.ProgrammingError(msg)
578 try:
578 try:
579 if symbol in ('.', 'tip', 'null'):
579 if symbol in ('.', 'tip', 'null'):
580 return repo[symbol]
580 return repo[symbol]
581
581
582 try:
582 try:
583 r = int(symbol)
583 r = int(symbol)
584 if '%d' % r != symbol:
584 if '%d' % r != symbol:
585 raise ValueError
585 raise ValueError
586 l = len(repo.changelog)
586 l = len(repo.changelog)
587 if r < 0:
587 if r < 0:
588 r += l
588 r += l
589 if r < 0 or r >= l and r != wdirrev:
589 if r < 0 or r >= l and r != wdirrev:
590 raise ValueError
590 raise ValueError
591 return repo[r]
591 return repo[r]
592 except error.FilteredIndexError:
592 except error.FilteredIndexError:
593 raise
593 raise
594 except (ValueError, OverflowError, IndexError):
594 except (ValueError, OverflowError, IndexError):
595 pass
595 pass
596
596
597 if len(symbol) == 40:
597 if len(symbol) == 40:
598 try:
598 try:
599 node = bin(symbol)
599 node = bin(symbol)
600 rev = repo.changelog.rev(node)
600 rev = repo.changelog.rev(node)
601 return repo[rev]
601 return repo[rev]
602 except error.FilteredLookupError:
602 except error.FilteredLookupError:
603 raise
603 raise
604 except (TypeError, LookupError):
604 except (TypeError, LookupError):
605 pass
605 pass
606
606
607 # look up bookmarks through the name interface
607 # look up bookmarks through the name interface
608 try:
608 try:
609 node = repo.names.singlenode(repo, symbol)
609 node = repo.names.singlenode(repo, symbol)
610 rev = repo.changelog.rev(node)
610 rev = repo.changelog.rev(node)
611 return repo[rev]
611 return repo[rev]
612 except KeyError:
612 except KeyError:
613 pass
613 pass
614
614
615 node = resolvehexnodeidprefix(repo, symbol)
615 node = resolvehexnodeidprefix(repo, symbol)
616 if node is not None:
616 if node is not None:
617 rev = repo.changelog.rev(node)
617 rev = repo.changelog.rev(node)
618 return repo[rev]
618 return repo[rev]
619
619
620 raise error.RepoLookupError(_("unknown revision '%s'") % symbol)
620 raise error.RepoLookupError(_("unknown revision '%s'") % symbol)
621
621
622 except error.WdirUnsupported:
622 except error.WdirUnsupported:
623 return repo[None]
623 return repo[None]
624 except (error.FilteredIndexError, error.FilteredLookupError,
624 except (error.FilteredIndexError, error.FilteredLookupError,
625 error.FilteredRepoLookupError):
625 error.FilteredRepoLookupError):
626 raise _filterederror(repo, symbol)
626 raise _filterederror(repo, symbol)
627
627
628 def _filterederror(repo, changeid):
628 def _filterederror(repo, changeid):
629 """build an exception to be raised about a filtered changeid
629 """build an exception to be raised about a filtered changeid
630
630
631 This is extracted in a function to help extensions (eg: evolve) to
631 This is extracted in a function to help extensions (eg: evolve) to
632 experiment with various message variants."""
632 experiment with various message variants."""
633 if repo.filtername.startswith('visible'):
633 if repo.filtername.startswith('visible'):
634
634
635 # Check if the changeset is obsolete
635 # Check if the changeset is obsolete
636 unfilteredrepo = repo.unfiltered()
636 unfilteredrepo = repo.unfiltered()
637 ctx = revsymbol(unfilteredrepo, changeid)
637 ctx = revsymbol(unfilteredrepo, changeid)
638
638
639 # If the changeset is obsolete, enrich the message with the reason
639 # If the changeset is obsolete, enrich the message with the reason
640 # that made this changeset not visible
640 # that made this changeset not visible
641 if ctx.obsolete():
641 if ctx.obsolete():
642 msg = obsutil._getfilteredreason(repo, changeid, ctx)
642 msg = obsutil._getfilteredreason(repo, changeid, ctx)
643 else:
643 else:
644 msg = _("hidden revision '%s'") % changeid
644 msg = _("hidden revision '%s'") % changeid
645
645
646 hint = _('use --hidden to access hidden revisions')
646 hint = _('use --hidden to access hidden revisions')
647
647
648 return error.FilteredRepoLookupError(msg, hint=hint)
648 return error.FilteredRepoLookupError(msg, hint=hint)
649 msg = _("filtered revision '%s' (not in '%s' subset)")
649 msg = _("filtered revision '%s' (not in '%s' subset)")
650 msg %= (changeid, repo.filtername)
650 msg %= (changeid, repo.filtername)
651 return error.FilteredRepoLookupError(msg)
651 return error.FilteredRepoLookupError(msg)
652
652
653 def revsingle(repo, revspec, default='.', localalias=None):
653 def revsingle(repo, revspec, default='.', localalias=None):
654 if not revspec and revspec != 0:
654 if not revspec and revspec != 0:
655 return repo[default]
655 return repo[default]
656
656
657 l = revrange(repo, [revspec], localalias=localalias)
657 l = revrange(repo, [revspec], localalias=localalias)
658 if not l:
658 if not l:
659 raise error.Abort(_('empty revision set'))
659 raise error.Abort(_('empty revision set'))
660 return repo[l.last()]
660 return repo[l.last()]
661
661
662 def _pairspec(revspec):
662 def _pairspec(revspec):
663 tree = revsetlang.parse(revspec)
663 tree = revsetlang.parse(revspec)
664 return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall')
664 return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall')
665
665
666 def revpair(repo, revs):
666 def revpair(repo, revs):
667 if not revs:
667 if not revs:
668 return repo['.'], repo[None]
668 return repo['.'], repo[None]
669
669
670 l = revrange(repo, revs)
670 l = revrange(repo, revs)
671
671
672 if not l:
672 if not l:
673 first = second = None
673 first = second = None
674 elif l.isascending():
674 elif l.isascending():
675 first = l.min()
675 first = l.min()
676 second = l.max()
676 second = l.max()
677 elif l.isdescending():
677 elif l.isdescending():
678 first = l.max()
678 first = l.max()
679 second = l.min()
679 second = l.min()
680 else:
680 else:
681 first = l.first()
681 first = l.first()
682 second = l.last()
682 second = l.last()
683
683
684 if first is None:
684 if first is None:
685 raise error.Abort(_('empty revision range'))
685 raise error.Abort(_('empty revision range'))
686 if (first == second and len(revs) >= 2
686 if (first == second and len(revs) >= 2
687 and not all(revrange(repo, [r]) for r in revs)):
687 and not all(revrange(repo, [r]) for r in revs)):
688 raise error.Abort(_('empty revision on one side of range'))
688 raise error.Abort(_('empty revision on one side of range'))
689
689
690 # if top-level is range expression, the result must always be a pair
690 # if top-level is range expression, the result must always be a pair
691 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
691 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
692 return repo[first], repo[None]
692 return repo[first], repo[None]
693
693
694 return repo[first], repo[second]
694 return repo[first], repo[second]
695
695
696 def revrange(repo, specs, localalias=None):
696 def revrange(repo, specs, localalias=None):
697 """Execute 1 to many revsets and return the union.
697 """Execute 1 to many revsets and return the union.
698
698
699 This is the preferred mechanism for executing revsets using user-specified
699 This is the preferred mechanism for executing revsets using user-specified
700 config options, such as revset aliases.
700 config options, such as revset aliases.
701
701
702 The revsets specified by ``specs`` will be executed via a chained ``OR``
702 The revsets specified by ``specs`` will be executed via a chained ``OR``
703 expression. If ``specs`` is empty, an empty result is returned.
703 expression. If ``specs`` is empty, an empty result is returned.
704
704
705 ``specs`` can contain integers, in which case they are assumed to be
705 ``specs`` can contain integers, in which case they are assumed to be
706 revision numbers.
706 revision numbers.
707
707
708 It is assumed the revsets are already formatted. If you have arguments
708 It is assumed the revsets are already formatted. If you have arguments
709 that need to be expanded in the revset, call ``revsetlang.formatspec()``
709 that need to be expanded in the revset, call ``revsetlang.formatspec()``
710 and pass the result as an element of ``specs``.
710 and pass the result as an element of ``specs``.
711
711
712 Specifying a single revset is allowed.
712 Specifying a single revset is allowed.
713
713
714 Returns a ``revset.abstractsmartset`` which is a list-like interface over
714 Returns a ``revset.abstractsmartset`` which is a list-like interface over
715 integer revisions.
715 integer revisions.
716 """
716 """
717 allspecs = []
717 allspecs = []
718 for spec in specs:
718 for spec in specs:
719 if isinstance(spec, int):
719 if isinstance(spec, int):
720 spec = revsetlang.formatspec('rev(%d)', spec)
720 spec = revsetlang.formatspec('rev(%d)', spec)
721 allspecs.append(spec)
721 allspecs.append(spec)
722 return repo.anyrevs(allspecs, user=True, localalias=localalias)
722 return repo.anyrevs(allspecs, user=True, localalias=localalias)
723
723
724 def meaningfulparents(repo, ctx):
724 def meaningfulparents(repo, ctx):
725 """Return list of meaningful (or all if debug) parentrevs for rev.
725 """Return list of meaningful (or all if debug) parentrevs for rev.
726
726
727 For merges (two non-nullrev revisions) both parents are meaningful.
727 For merges (two non-nullrev revisions) both parents are meaningful.
728 Otherwise the first parent revision is considered meaningful if it
728 Otherwise the first parent revision is considered meaningful if it
729 is not the preceding revision.
729 is not the preceding revision.
730 """
730 """
731 parents = ctx.parents()
731 parents = ctx.parents()
732 if len(parents) > 1:
732 if len(parents) > 1:
733 return parents
733 return parents
734 if repo.ui.debugflag:
734 if repo.ui.debugflag:
735 return [parents[0], repo[nullrev]]
735 return [parents[0], repo[nullrev]]
736 if parents[0].rev() >= intrev(ctx) - 1:
736 if parents[0].rev() >= intrev(ctx) - 1:
737 return []
737 return []
738 return parents
738 return parents
739
739
740 def expandpats(pats):
740 def expandpats(pats):
741 '''Expand bare globs when running on windows.
741 '''Expand bare globs when running on windows.
742 On posix we assume it already has already been done by sh.'''
742 On posix we assume it already has already been done by sh.'''
743 if not util.expandglobs:
743 if not util.expandglobs:
744 return list(pats)
744 return list(pats)
745 ret = []
745 ret = []
746 for kindpat in pats:
746 for kindpat in pats:
747 kind, pat = matchmod._patsplit(kindpat, None)
747 kind, pat = matchmod._patsplit(kindpat, None)
748 if kind is None:
748 if kind is None:
749 try:
749 try:
750 globbed = glob.glob(pat)
750 globbed = glob.glob(pat)
751 except re.error:
751 except re.error:
752 globbed = [pat]
752 globbed = [pat]
753 if globbed:
753 if globbed:
754 ret.extend(globbed)
754 ret.extend(globbed)
755 continue
755 continue
756 ret.append(kindpat)
756 ret.append(kindpat)
757 return ret
757 return ret
758
758
759 def matchandpats(ctx, pats=(), opts=None, globbed=False, default='relpath',
759 def matchandpats(ctx, pats=(), opts=None, globbed=False, default='relpath',
760 badfn=None):
760 badfn=None):
761 '''Return a matcher and the patterns that were used.
761 '''Return a matcher and the patterns that were used.
762 The matcher will warn about bad matches, unless an alternate badfn callback
762 The matcher will warn about bad matches, unless an alternate badfn callback
763 is provided.'''
763 is provided.'''
764 if pats == ("",):
764 if pats == ("",):
765 pats = []
765 pats = []
766 if opts is None:
766 if opts is None:
767 opts = {}
767 opts = {}
768 if not globbed and default == 'relpath':
768 if not globbed and default == 'relpath':
769 pats = expandpats(pats or [])
769 pats = expandpats(pats or [])
770
770
771 def bad(f, msg):
771 def bad(f, msg):
772 ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg))
772 ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg))
773
773
774 if badfn is None:
774 if badfn is None:
775 badfn = bad
775 badfn = bad
776
776
777 m = ctx.match(pats, opts.get('include'), opts.get('exclude'),
777 m = ctx.match(pats, opts.get('include'), opts.get('exclude'),
778 default, listsubrepos=opts.get('subrepos'), badfn=badfn)
778 default, listsubrepos=opts.get('subrepos'), badfn=badfn)
779
779
780 if m.always():
780 if m.always():
781 pats = []
781 pats = []
782 return m, pats
782 return m, pats
783
783
784 def match(ctx, pats=(), opts=None, globbed=False, default='relpath',
784 def match(ctx, pats=(), opts=None, globbed=False, default='relpath',
785 badfn=None):
785 badfn=None):
786 '''Return a matcher that will warn about bad matches.'''
786 '''Return a matcher that will warn about bad matches.'''
787 return matchandpats(ctx, pats, opts, globbed, default, badfn=badfn)[0]
787 return matchandpats(ctx, pats, opts, globbed, default, badfn=badfn)[0]
788
788
789 def matchall(repo):
789 def matchall(repo):
790 '''Return a matcher that will efficiently match everything.'''
790 '''Return a matcher that will efficiently match everything.'''
791 return matchmod.always(repo.root, repo.getcwd())
791 return matchmod.always(repo.root, repo.getcwd())
792
792
793 def matchfiles(repo, files, badfn=None):
793 def matchfiles(repo, files, badfn=None):
794 '''Return a matcher that will efficiently match exactly these files.'''
794 '''Return a matcher that will efficiently match exactly these files.'''
795 return matchmod.exact(repo.root, repo.getcwd(), files, badfn=badfn)
795 return matchmod.exact(repo.root, repo.getcwd(), files, badfn=badfn)
796
796
797 def parsefollowlinespattern(repo, rev, pat, msg):
797 def parsefollowlinespattern(repo, rev, pat, msg):
798 """Return a file name from `pat` pattern suitable for usage in followlines
798 """Return a file name from `pat` pattern suitable for usage in followlines
799 logic.
799 logic.
800 """
800 """
801 if not matchmod.patkind(pat):
801 if not matchmod.patkind(pat):
802 return pathutil.canonpath(repo.root, repo.getcwd(), pat)
802 return pathutil.canonpath(repo.root, repo.getcwd(), pat)
803 else:
803 else:
804 ctx = repo[rev]
804 ctx = repo[rev]
805 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=ctx)
805 m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=ctx)
806 files = [f for f in ctx if m(f)]
806 files = [f for f in ctx if m(f)]
807 if len(files) != 1:
807 if len(files) != 1:
808 raise error.ParseError(msg)
808 raise error.ParseError(msg)
809 return files[0]
809 return files[0]
810
810
811 def origpath(ui, repo, filepath):
811 def origpath(ui, repo, filepath):
812 '''customize where .orig files are created
812 '''customize where .orig files are created
813
813
814 Fetch user defined path from config file: [ui] origbackuppath = <path>
814 Fetch user defined path from config file: [ui] origbackuppath = <path>
815 Fall back to default (filepath with .orig suffix) if not specified
815 Fall back to default (filepath with .orig suffix) if not specified
816 '''
816 '''
817 origbackuppath = ui.config('ui', 'origbackuppath')
817 origbackuppath = ui.config('ui', 'origbackuppath')
818 if not origbackuppath:
818 if not origbackuppath:
819 return filepath + ".orig"
819 return filepath + ".orig"
820
820
821 # Convert filepath from an absolute path into a path inside the repo.
821 # Convert filepath from an absolute path into a path inside the repo.
822 filepathfromroot = util.normpath(os.path.relpath(filepath,
822 filepathfromroot = util.normpath(os.path.relpath(filepath,
823 start=repo.root))
823 start=repo.root))
824
824
825 origvfs = vfs.vfs(repo.wjoin(origbackuppath))
825 origvfs = vfs.vfs(repo.wjoin(origbackuppath))
826 origbackupdir = origvfs.dirname(filepathfromroot)
826 origbackupdir = origvfs.dirname(filepathfromroot)
827 if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
827 if not origvfs.isdir(origbackupdir) or origvfs.islink(origbackupdir):
828 ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
828 ui.note(_('creating directory: %s\n') % origvfs.join(origbackupdir))
829
829
830 # Remove any files that conflict with the backup file's path
830 # Remove any files that conflict with the backup file's path
831 for f in reversed(list(util.finddirs(filepathfromroot))):
831 for f in reversed(list(util.finddirs(filepathfromroot))):
832 if origvfs.isfileorlink(f):
832 if origvfs.isfileorlink(f):
833 ui.note(_('removing conflicting file: %s\n')
833 ui.note(_('removing conflicting file: %s\n')
834 % origvfs.join(f))
834 % origvfs.join(f))
835 origvfs.unlink(f)
835 origvfs.unlink(f)
836 break
836 break
837
837
838 origvfs.makedirs(origbackupdir)
838 origvfs.makedirs(origbackupdir)
839
839
840 if origvfs.isdir(filepathfromroot) and not origvfs.islink(filepathfromroot):
840 if origvfs.isdir(filepathfromroot) and not origvfs.islink(filepathfromroot):
841 ui.note(_('removing conflicting directory: %s\n')
841 ui.note(_('removing conflicting directory: %s\n')
842 % origvfs.join(filepathfromroot))
842 % origvfs.join(filepathfromroot))
843 origvfs.rmtree(filepathfromroot, forcibly=True)
843 origvfs.rmtree(filepathfromroot, forcibly=True)
844
844
845 return origvfs.join(filepathfromroot)
845 return origvfs.join(filepathfromroot)
846
846
847 class _containsnode(object):
847 class _containsnode(object):
848 """proxy __contains__(node) to container.__contains__ which accepts revs"""
848 """proxy __contains__(node) to container.__contains__ which accepts revs"""
849
849
850 def __init__(self, repo, revcontainer):
850 def __init__(self, repo, revcontainer):
851 self._torev = repo.changelog.rev
851 self._torev = repo.changelog.rev
852 self._revcontains = revcontainer.__contains__
852 self._revcontains = revcontainer.__contains__
853
853
854 def __contains__(self, node):
854 def __contains__(self, node):
855 return self._revcontains(self._torev(node))
855 return self._revcontains(self._torev(node))
856
856
857 def cleanupnodes(repo, replacements, operation, moves=None, metadata=None,
857 def cleanupnodes(repo, replacements, operation, moves=None, metadata=None,
858 fixphase=False, targetphase=None, backup=True):
858 fixphase=False, targetphase=None, backup=True):
859 """do common cleanups when old nodes are replaced by new nodes
859 """do common cleanups when old nodes are replaced by new nodes
860
860
861 That includes writing obsmarkers or stripping nodes, and moving bookmarks.
861 That includes writing obsmarkers or stripping nodes, and moving bookmarks.
862 (we might also want to move working directory parent in the future)
862 (we might also want to move working directory parent in the future)
863
863
864 By default, bookmark moves are calculated automatically from 'replacements',
864 By default, bookmark moves are calculated automatically from 'replacements',
865 but 'moves' can be used to override that. Also, 'moves' may include
865 but 'moves' can be used to override that. Also, 'moves' may include
866 additional bookmark moves that should not have associated obsmarkers.
866 additional bookmark moves that should not have associated obsmarkers.
867
867
868 replacements is {oldnode: [newnode]} or a iterable of nodes if they do not
868 replacements is {oldnode: [newnode]} or a iterable of nodes if they do not
869 have replacements. operation is a string, like "rebase".
869 have replacements. operation is a string, like "rebase".
870
870
871 metadata is dictionary containing metadata to be stored in obsmarker if
871 metadata is dictionary containing metadata to be stored in obsmarker if
872 obsolescence is enabled.
872 obsolescence is enabled.
873 """
873 """
874 assert fixphase or targetphase is None
874 assert fixphase or targetphase is None
875 if not replacements and not moves:
875 if not replacements and not moves:
876 return
876 return
877
877
878 # translate mapping's other forms
878 # translate mapping's other forms
879 if not util.safehasattr(replacements, 'items'):
879 if not util.safehasattr(replacements, 'items'):
880 replacements = {(n,): () for n in replacements}
880 replacements = {(n,): () for n in replacements}
881 else:
881 else:
882 # upgrading non tuple "source" to tuple ones for BC
882 # upgrading non tuple "source" to tuple ones for BC
883 repls = {}
883 repls = {}
884 for key, value in replacements.items():
884 for key, value in replacements.items():
885 if not isinstance(key, tuple):
885 if not isinstance(key, tuple):
886 key = (key,)
886 key = (key,)
887 repls[key] = value
887 repls[key] = value
888 replacements = repls
888 replacements = repls
889
889
890 # Calculate bookmark movements
890 # Calculate bookmark movements
891 if moves is None:
891 if moves is None:
892 moves = {}
892 moves = {}
893 # Unfiltered repo is needed since nodes in replacements might be hidden.
893 # Unfiltered repo is needed since nodes in replacements might be hidden.
894 unfi = repo.unfiltered()
894 unfi = repo.unfiltered()
895 for oldnodes, newnodes in replacements.items():
895 for oldnodes, newnodes in replacements.items():
896 for oldnode in oldnodes:
896 for oldnode in oldnodes:
897 if oldnode in moves:
897 if oldnode in moves:
898 continue
898 continue
899 if len(newnodes) > 1:
899 if len(newnodes) > 1:
900 # usually a split, take the one with biggest rev number
900 # usually a split, take the one with biggest rev number
901 newnode = next(unfi.set('max(%ln)', newnodes)).node()
901 newnode = next(unfi.set('max(%ln)', newnodes)).node()
902 elif len(newnodes) == 0:
902 elif len(newnodes) == 0:
903 # move bookmark backwards
903 # move bookmark backwards
904 allreplaced = []
904 allreplaced = []
905 for rep in replacements:
905 for rep in replacements:
906 allreplaced.extend(rep)
906 allreplaced.extend(rep)
907 roots = list(unfi.set('max((::%n) - %ln)', oldnode,
907 roots = list(unfi.set('max((::%n) - %ln)', oldnode,
908 allreplaced))
908 allreplaced))
909 if roots:
909 if roots:
910 newnode = roots[0].node()
910 newnode = roots[0].node()
911 else:
911 else:
912 newnode = nullid
912 newnode = nullid
913 else:
913 else:
914 newnode = newnodes[0]
914 newnode = newnodes[0]
915 moves[oldnode] = newnode
915 moves[oldnode] = newnode
916
916
917 allnewnodes = [n for ns in replacements.values() for n in ns]
917 allnewnodes = [n for ns in replacements.values() for n in ns]
918 toretract = {}
918 toretract = {}
919 toadvance = {}
919 toadvance = {}
920 if fixphase:
920 if fixphase:
921 precursors = {}
921 precursors = {}
922 for oldnodes, newnodes in replacements.items():
922 for oldnodes, newnodes in replacements.items():
923 for oldnode in oldnodes:
923 for oldnode in oldnodes:
924 for newnode in newnodes:
924 for newnode in newnodes:
925 precursors.setdefault(newnode, []).append(oldnode)
925 precursors.setdefault(newnode, []).append(oldnode)
926
926
927 allnewnodes.sort(key=lambda n: unfi[n].rev())
927 allnewnodes.sort(key=lambda n: unfi[n].rev())
928 newphases = {}
928 newphases = {}
929 def phase(ctx):
929 def phase(ctx):
930 return newphases.get(ctx.node(), ctx.phase())
930 return newphases.get(ctx.node(), ctx.phase())
931 for newnode in allnewnodes:
931 for newnode in allnewnodes:
932 ctx = unfi[newnode]
932 ctx = unfi[newnode]
933 parentphase = max(phase(p) for p in ctx.parents())
933 parentphase = max(phase(p) for p in ctx.parents())
934 if targetphase is None:
934 if targetphase is None:
935 oldphase = max(unfi[oldnode].phase()
935 oldphase = max(unfi[oldnode].phase()
936 for oldnode in precursors[newnode])
936 for oldnode in precursors[newnode])
937 newphase = max(oldphase, parentphase)
937 newphase = max(oldphase, parentphase)
938 else:
938 else:
939 newphase = max(targetphase, parentphase)
939 newphase = max(targetphase, parentphase)
940 newphases[newnode] = newphase
940 newphases[newnode] = newphase
941 if newphase > ctx.phase():
941 if newphase > ctx.phase():
942 toretract.setdefault(newphase, []).append(newnode)
942 toretract.setdefault(newphase, []).append(newnode)
943 elif newphase < ctx.phase():
943 elif newphase < ctx.phase():
944 toadvance.setdefault(newphase, []).append(newnode)
944 toadvance.setdefault(newphase, []).append(newnode)
945
945
946 with repo.transaction('cleanup') as tr:
946 with repo.transaction('cleanup') as tr:
947 # Move bookmarks
947 # Move bookmarks
948 bmarks = repo._bookmarks
948 bmarks = repo._bookmarks
949 bmarkchanges = []
949 bmarkchanges = []
950 for oldnode, newnode in moves.items():
950 for oldnode, newnode in moves.items():
951 oldbmarks = repo.nodebookmarks(oldnode)
951 oldbmarks = repo.nodebookmarks(oldnode)
952 if not oldbmarks:
952 if not oldbmarks:
953 continue
953 continue
954 from . import bookmarks # avoid import cycle
954 from . import bookmarks # avoid import cycle
955 repo.ui.debug('moving bookmarks %r from %s to %s\n' %
955 repo.ui.debug('moving bookmarks %r from %s to %s\n' %
956 (pycompat.rapply(pycompat.maybebytestr, oldbmarks),
956 (pycompat.rapply(pycompat.maybebytestr, oldbmarks),
957 hex(oldnode), hex(newnode)))
957 hex(oldnode), hex(newnode)))
958 # Delete divergent bookmarks being parents of related newnodes
958 # Delete divergent bookmarks being parents of related newnodes
959 deleterevs = repo.revs('parents(roots(%ln & (::%n))) - parents(%n)',
959 deleterevs = repo.revs('parents(roots(%ln & (::%n))) - parents(%n)',
960 allnewnodes, newnode, oldnode)
960 allnewnodes, newnode, oldnode)
961 deletenodes = _containsnode(repo, deleterevs)
961 deletenodes = _containsnode(repo, deleterevs)
962 for name in oldbmarks:
962 for name in oldbmarks:
963 bmarkchanges.append((name, newnode))
963 bmarkchanges.append((name, newnode))
964 for b in bookmarks.divergent2delete(repo, deletenodes, name):
964 for b in bookmarks.divergent2delete(repo, deletenodes, name):
965 bmarkchanges.append((b, None))
965 bmarkchanges.append((b, None))
966
966
967 if bmarkchanges:
967 if bmarkchanges:
968 bmarks.applychanges(repo, tr, bmarkchanges)
968 bmarks.applychanges(repo, tr, bmarkchanges)
969
969
970 for phase, nodes in toretract.items():
970 for phase, nodes in toretract.items():
971 phases.retractboundary(repo, tr, phase, nodes)
971 phases.retractboundary(repo, tr, phase, nodes)
972 for phase, nodes in toadvance.items():
972 for phase, nodes in toadvance.items():
973 phases.advanceboundary(repo, tr, phase, nodes)
973 phases.advanceboundary(repo, tr, phase, nodes)
974
974
975 # Obsolete or strip nodes
975 # Obsolete or strip nodes
976 if obsolete.isenabled(repo, obsolete.createmarkersopt):
976 if obsolete.isenabled(repo, obsolete.createmarkersopt):
977 # If a node is already obsoleted, and we want to obsolete it
977 # If a node is already obsoleted, and we want to obsolete it
978 # without a successor, skip that obssolete request since it's
978 # without a successor, skip that obssolete request since it's
979 # unnecessary. That's the "if s or not isobs(n)" check below.
979 # unnecessary. That's the "if s or not isobs(n)" check below.
980 # Also sort the node in topology order, that might be useful for
980 # Also sort the node in topology order, that might be useful for
981 # some obsstore logic.
981 # some obsstore logic.
982 # NOTE: the filtering and sorting might belong to createmarkers.
982 # NOTE: the filtering and sorting might belong to createmarkers.
983 isobs = unfi.obsstore.successors.__contains__
983 isobs = unfi.obsstore.successors.__contains__
984 torev = unfi.changelog.rev
984 torev = unfi.changelog.rev
985 sortfunc = lambda ns: torev(ns[0][0])
985 sortfunc = lambda ns: torev(ns[0][0])
986 rels = []
986 rels = []
987 for ns, s in sorted(replacements.items(), key=sortfunc):
987 for ns, s in sorted(replacements.items(), key=sortfunc):
988 for n in ns:
988 for n in ns:
989 if s or not isobs(n):
989 if s or not isobs(n):
990 rel = (unfi[n], tuple(unfi[m] for m in s))
990 rel = (unfi[n], tuple(unfi[m] for m in s))
991 rels.append(rel)
991 rels.append(rel)
992 if rels:
992 if rels:
993 obsolete.createmarkers(repo, rels, operation=operation,
993 obsolete.createmarkers(repo, rels, operation=operation,
994 metadata=metadata)
994 metadata=metadata)
995 else:
995 else:
996 from . import repair # avoid import cycle
996 from . import repair # avoid import cycle
997 tostrip = list(n for ns in replacements for n in ns)
997 tostrip = list(n for ns in replacements for n in ns)
998 if tostrip:
998 if tostrip:
999 repair.delayedstrip(repo.ui, repo, tostrip, operation,
999 repair.delayedstrip(repo.ui, repo, tostrip, operation,
1000 backup=backup)
1000 backup=backup)
1001
1001
1002 def addremove(repo, matcher, prefix, opts=None):
1002 def addremove(repo, matcher, prefix, opts=None):
1003 if opts is None:
1003 if opts is None:
1004 opts = {}
1004 opts = {}
1005 m = matcher
1005 m = matcher
1006 dry_run = opts.get('dry_run')
1006 dry_run = opts.get('dry_run')
1007 try:
1007 try:
1008 similarity = float(opts.get('similarity') or 0)
1008 similarity = float(opts.get('similarity') or 0)
1009 except ValueError:
1009 except ValueError:
1010 raise error.Abort(_('similarity must be a number'))
1010 raise error.Abort(_('similarity must be a number'))
1011 if similarity < 0 or similarity > 100:
1011 if similarity < 0 or similarity > 100:
1012 raise error.Abort(_('similarity must be between 0 and 100'))
1012 raise error.Abort(_('similarity must be between 0 and 100'))
1013 similarity /= 100.0
1013 similarity /= 100.0
1014
1014
1015 ret = 0
1015 ret = 0
1016 join = lambda f: os.path.join(prefix, f)
1016 join = lambda f: os.path.join(prefix, f)
1017
1017
1018 wctx = repo[None]
1018 wctx = repo[None]
1019 for subpath in sorted(wctx.substate):
1019 for subpath in sorted(wctx.substate):
1020 submatch = matchmod.subdirmatcher(subpath, m)
1020 submatch = matchmod.subdirmatcher(subpath, m)
1021 if opts.get('subrepos') or m.exact(subpath) or any(submatch.files()):
1021 if opts.get('subrepos') or m.exact(subpath) or any(submatch.files()):
1022 sub = wctx.sub(subpath)
1022 sub = wctx.sub(subpath)
1023 try:
1023 try:
1024 if sub.addremove(submatch, prefix, opts):
1024 if sub.addremove(submatch, prefix, opts):
1025 ret = 1
1025 ret = 1
1026 except error.LookupError:
1026 except error.LookupError:
1027 repo.ui.status(_("skipping missing subrepository: %s\n")
1027 repo.ui.status(_("skipping missing subrepository: %s\n")
1028 % join(subpath))
1028 % join(subpath))
1029
1029
1030 rejected = []
1030 rejected = []
1031 def badfn(f, msg):
1031 def badfn(f, msg):
1032 if f in m.files():
1032 if f in m.files():
1033 m.bad(f, msg)
1033 m.bad(f, msg)
1034 rejected.append(f)
1034 rejected.append(f)
1035
1035
1036 badmatch = matchmod.badmatch(m, badfn)
1036 badmatch = matchmod.badmatch(m, badfn)
1037 added, unknown, deleted, removed, forgotten = _interestingfiles(repo,
1037 added, unknown, deleted, removed, forgotten = _interestingfiles(repo,
1038 badmatch)
1038 badmatch)
1039
1039
1040 unknownset = set(unknown + forgotten)
1040 unknownset = set(unknown + forgotten)
1041 toprint = unknownset.copy()
1041 toprint = unknownset.copy()
1042 toprint.update(deleted)
1042 toprint.update(deleted)
1043 for abs in sorted(toprint):
1043 for abs in sorted(toprint):
1044 if repo.ui.verbose or not m.exact(abs):
1044 if repo.ui.verbose or not m.exact(abs):
1045 if abs in unknownset:
1045 if abs in unknownset:
1046 status = _('adding %s\n') % m.uipath(abs)
1046 status = _('adding %s\n') % m.uipath(abs)
1047 label = 'addremove.added'
1047 label = 'addremove.added'
1048 else:
1048 else:
1049 status = _('removing %s\n') % m.uipath(abs)
1049 status = _('removing %s\n') % m.uipath(abs)
1050 label = 'addremove.removed'
1050 label = 'addremove.removed'
1051 repo.ui.status(status, label=label)
1051 repo.ui.status(status, label=label)
1052
1052
1053 renames = _findrenames(repo, m, added + unknown, removed + deleted,
1053 renames = _findrenames(repo, m, added + unknown, removed + deleted,
1054 similarity)
1054 similarity)
1055
1055
1056 if not dry_run:
1056 if not dry_run:
1057 _markchanges(repo, unknown + forgotten, deleted, renames)
1057 _markchanges(repo, unknown + forgotten, deleted, renames)
1058
1058
1059 for f in rejected:
1059 for f in rejected:
1060 if f in m.files():
1060 if f in m.files():
1061 return 1
1061 return 1
1062 return ret
1062 return ret
1063
1063
1064 def marktouched(repo, files, similarity=0.0):
1064 def marktouched(repo, files, similarity=0.0):
1065 '''Assert that files have somehow been operated upon. files are relative to
1065 '''Assert that files have somehow been operated upon. files are relative to
1066 the repo root.'''
1066 the repo root.'''
1067 m = matchfiles(repo, files, badfn=lambda x, y: rejected.append(x))
1067 m = matchfiles(repo, files, badfn=lambda x, y: rejected.append(x))
1068 rejected = []
1068 rejected = []
1069
1069
1070 added, unknown, deleted, removed, forgotten = _interestingfiles(repo, m)
1070 added, unknown, deleted, removed, forgotten = _interestingfiles(repo, m)
1071
1071
1072 if repo.ui.verbose:
1072 if repo.ui.verbose:
1073 unknownset = set(unknown + forgotten)
1073 unknownset = set(unknown + forgotten)
1074 toprint = unknownset.copy()
1074 toprint = unknownset.copy()
1075 toprint.update(deleted)
1075 toprint.update(deleted)
1076 for abs in sorted(toprint):
1076 for abs in sorted(toprint):
1077 if abs in unknownset:
1077 if abs in unknownset:
1078 status = _('adding %s\n') % abs
1078 status = _('adding %s\n') % abs
1079 else:
1079 else:
1080 status = _('removing %s\n') % abs
1080 status = _('removing %s\n') % abs
1081 repo.ui.status(status)
1081 repo.ui.status(status)
1082
1082
1083 renames = _findrenames(repo, m, added + unknown, removed + deleted,
1083 renames = _findrenames(repo, m, added + unknown, removed + deleted,
1084 similarity)
1084 similarity)
1085
1085
1086 _markchanges(repo, unknown + forgotten, deleted, renames)
1086 _markchanges(repo, unknown + forgotten, deleted, renames)
1087
1087
1088 for f in rejected:
1088 for f in rejected:
1089 if f in m.files():
1089 if f in m.files():
1090 return 1
1090 return 1
1091 return 0
1091 return 0
1092
1092
1093 def _interestingfiles(repo, matcher):
1093 def _interestingfiles(repo, matcher):
1094 '''Walk dirstate with matcher, looking for files that addremove would care
1094 '''Walk dirstate with matcher, looking for files that addremove would care
1095 about.
1095 about.
1096
1096
1097 This is different from dirstate.status because it doesn't care about
1097 This is different from dirstate.status because it doesn't care about
1098 whether files are modified or clean.'''
1098 whether files are modified or clean.'''
1099 added, unknown, deleted, removed, forgotten = [], [], [], [], []
1099 added, unknown, deleted, removed, forgotten = [], [], [], [], []
1100 audit_path = pathutil.pathauditor(repo.root, cached=True)
1100 audit_path = pathutil.pathauditor(repo.root, cached=True)
1101
1101
1102 ctx = repo[None]
1102 ctx = repo[None]
1103 dirstate = repo.dirstate
1103 dirstate = repo.dirstate
1104 walkresults = dirstate.walk(matcher, subrepos=sorted(ctx.substate),
1104 walkresults = dirstate.walk(matcher, subrepos=sorted(ctx.substate),
1105 unknown=True, ignored=False, full=False)
1105 unknown=True, ignored=False, full=False)
1106 for abs, st in walkresults.iteritems():
1106 for abs, st in walkresults.iteritems():
1107 dstate = dirstate[abs]
1107 dstate = dirstate[abs]
1108 if dstate == '?' and audit_path.check(abs):
1108 if dstate == '?' and audit_path.check(abs):
1109 unknown.append(abs)
1109 unknown.append(abs)
1110 elif dstate != 'r' and not st:
1110 elif dstate != 'r' and not st:
1111 deleted.append(abs)
1111 deleted.append(abs)
1112 elif dstate == 'r' and st:
1112 elif dstate == 'r' and st:
1113 forgotten.append(abs)
1113 forgotten.append(abs)
1114 # for finding renames
1114 # for finding renames
1115 elif dstate == 'r' and not st:
1115 elif dstate == 'r' and not st:
1116 removed.append(abs)
1116 removed.append(abs)
1117 elif dstate == 'a':
1117 elif dstate == 'a':
1118 added.append(abs)
1118 added.append(abs)
1119
1119
1120 return added, unknown, deleted, removed, forgotten
1120 return added, unknown, deleted, removed, forgotten
1121
1121
1122 def _findrenames(repo, matcher, added, removed, similarity):
1122 def _findrenames(repo, matcher, added, removed, similarity):
1123 '''Find renames from removed files to added ones.'''
1123 '''Find renames from removed files to added ones.'''
1124 renames = {}
1124 renames = {}
1125 if similarity > 0:
1125 if similarity > 0:
1126 for old, new, score in similar.findrenames(repo, added, removed,
1126 for old, new, score in similar.findrenames(repo, added, removed,
1127 similarity):
1127 similarity):
1128 if (repo.ui.verbose or not matcher.exact(old)
1128 if (repo.ui.verbose or not matcher.exact(old)
1129 or not matcher.exact(new)):
1129 or not matcher.exact(new)):
1130 repo.ui.status(_('recording removal of %s as rename to %s '
1130 repo.ui.status(_('recording removal of %s as rename to %s '
1131 '(%d%% similar)\n') %
1131 '(%d%% similar)\n') %
1132 (matcher.rel(old), matcher.rel(new),
1132 (matcher.rel(old), matcher.rel(new),
1133 score * 100))
1133 score * 100))
1134 renames[new] = old
1134 renames[new] = old
1135 return renames
1135 return renames
1136
1136
1137 def _markchanges(repo, unknown, deleted, renames):
1137 def _markchanges(repo, unknown, deleted, renames):
1138 '''Marks the files in unknown as added, the files in deleted as removed,
1138 '''Marks the files in unknown as added, the files in deleted as removed,
1139 and the files in renames as copied.'''
1139 and the files in renames as copied.'''
1140 wctx = repo[None]
1140 wctx = repo[None]
1141 with repo.wlock():
1141 with repo.wlock():
1142 wctx.forget(deleted)
1142 wctx.forget(deleted)
1143 wctx.add(unknown)
1143 wctx.add(unknown)
1144 for new, old in renames.iteritems():
1144 for new, old in renames.iteritems():
1145 wctx.copy(old, new)
1145 wctx.copy(old, new)
1146
1146
1147 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None):
1147 def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None):
1148 """Update the dirstate to reflect the intent of copying src to dst. For
1148 """Update the dirstate to reflect the intent of copying src to dst. For
1149 different reasons it might not end with dst being marked as copied from src.
1149 different reasons it might not end with dst being marked as copied from src.
1150 """
1150 """
1151 origsrc = repo.dirstate.copied(src) or src
1151 origsrc = repo.dirstate.copied(src) or src
1152 if dst == origsrc: # copying back a copy?
1152 if dst == origsrc: # copying back a copy?
1153 if repo.dirstate[dst] not in 'mn' and not dryrun:
1153 if repo.dirstate[dst] not in 'mn' and not dryrun:
1154 repo.dirstate.normallookup(dst)
1154 repo.dirstate.normallookup(dst)
1155 else:
1155 else:
1156 if repo.dirstate[origsrc] == 'a' and origsrc == src:
1156 if repo.dirstate[origsrc] == 'a' and origsrc == src:
1157 if not ui.quiet:
1157 if not ui.quiet:
1158 ui.warn(_("%s has not been committed yet, so no copy "
1158 ui.warn(_("%s has not been committed yet, so no copy "
1159 "data will be stored for %s.\n")
1159 "data will be stored for %s.\n")
1160 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)))
1160 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)))
1161 if repo.dirstate[dst] in '?r' and not dryrun:
1161 if repo.dirstate[dst] in '?r' and not dryrun:
1162 wctx.add([dst])
1162 wctx.add([dst])
1163 elif not dryrun:
1163 elif not dryrun:
1164 wctx.copy(origsrc, dst)
1164 wctx.copy(origsrc, dst)
1165
1165
1166 def writerequires(opener, requirements):
1166 def writerequires(opener, requirements):
1167 with opener('requires', 'w') as fp:
1167 with opener('requires', 'w') as fp:
1168 for r in sorted(requirements):
1168 for r in sorted(requirements):
1169 fp.write("%s\n" % r)
1169 fp.write("%s\n" % r)
1170
1170
1171 class filecachesubentry(object):
1171 class filecachesubentry(object):
1172 def __init__(self, path, stat):
1172 def __init__(self, path, stat):
1173 self.path = path
1173 self.path = path
1174 self.cachestat = None
1174 self.cachestat = None
1175 self._cacheable = None
1175 self._cacheable = None
1176
1176
1177 if stat:
1177 if stat:
1178 self.cachestat = filecachesubentry.stat(self.path)
1178 self.cachestat = filecachesubentry.stat(self.path)
1179
1179
1180 if self.cachestat:
1180 if self.cachestat:
1181 self._cacheable = self.cachestat.cacheable()
1181 self._cacheable = self.cachestat.cacheable()
1182 else:
1182 else:
1183 # None means we don't know yet
1183 # None means we don't know yet
1184 self._cacheable = None
1184 self._cacheable = None
1185
1185
1186 def refresh(self):
1186 def refresh(self):
1187 if self.cacheable():
1187 if self.cacheable():
1188 self.cachestat = filecachesubentry.stat(self.path)
1188 self.cachestat = filecachesubentry.stat(self.path)
1189
1189
1190 def cacheable(self):
1190 def cacheable(self):
1191 if self._cacheable is not None:
1191 if self._cacheable is not None:
1192 return self._cacheable
1192 return self._cacheable
1193
1193
1194 # we don't know yet, assume it is for now
1194 # we don't know yet, assume it is for now
1195 return True
1195 return True
1196
1196
1197 def changed(self):
1197 def changed(self):
1198 # no point in going further if we can't cache it
1198 # no point in going further if we can't cache it
1199 if not self.cacheable():
1199 if not self.cacheable():
1200 return True
1200 return True
1201
1201
1202 newstat = filecachesubentry.stat(self.path)
1202 newstat = filecachesubentry.stat(self.path)
1203
1203
1204 # we may not know if it's cacheable yet, check again now
1204 # we may not know if it's cacheable yet, check again now
1205 if newstat and self._cacheable is None:
1205 if newstat and self._cacheable is None:
1206 self._cacheable = newstat.cacheable()
1206 self._cacheable = newstat.cacheable()
1207
1207
1208 # check again
1208 # check again
1209 if not self._cacheable:
1209 if not self._cacheable:
1210 return True
1210 return True
1211
1211
1212 if self.cachestat != newstat:
1212 if self.cachestat != newstat:
1213 self.cachestat = newstat
1213 self.cachestat = newstat
1214 return True
1214 return True
1215 else:
1215 else:
1216 return False
1216 return False
1217
1217
1218 @staticmethod
1218 @staticmethod
1219 def stat(path):
1219 def stat(path):
1220 try:
1220 try:
1221 return util.cachestat(path)
1221 return util.cachestat(path)
1222 except OSError as e:
1222 except OSError as e:
1223 if e.errno != errno.ENOENT:
1223 if e.errno != errno.ENOENT:
1224 raise
1224 raise
1225
1225
1226 class filecacheentry(object):
1226 class filecacheentry(object):
1227 def __init__(self, paths, stat=True):
1227 def __init__(self, paths, stat=True):
1228 self._entries = []
1228 self._entries = []
1229 for path in paths:
1229 for path in paths:
1230 self._entries.append(filecachesubentry(path, stat))
1230 self._entries.append(filecachesubentry(path, stat))
1231
1231
1232 def changed(self):
1232 def changed(self):
1233 '''true if any entry has changed'''
1233 '''true if any entry has changed'''
1234 for entry in self._entries:
1234 for entry in self._entries:
1235 if entry.changed():
1235 if entry.changed():
1236 return True
1236 return True
1237 return False
1237 return False
1238
1238
1239 def refresh(self):
1239 def refresh(self):
1240 for entry in self._entries:
1240 for entry in self._entries:
1241 entry.refresh()
1241 entry.refresh()
1242
1242
1243 class filecache(object):
1243 class filecache(object):
1244 """A property like decorator that tracks files under .hg/ for updates.
1244 """A property like decorator that tracks files under .hg/ for updates.
1245
1245
1246 On first access, the files defined as arguments are stat()ed and the
1246 On first access, the files defined as arguments are stat()ed and the
1247 results cached. The decorated function is called. The results are stashed
1247 results cached. The decorated function is called. The results are stashed
1248 away in a ``_filecache`` dict on the object whose method is decorated.
1248 away in a ``_filecache`` dict on the object whose method is decorated.
1249
1249
1250 On subsequent access, the cached result is returned.
1250 On subsequent access, the cached result is returned.
1251
1251
1252 On external property set operations, stat() calls are performed and the new
1252 On external property set operations, stat() calls are performed and the new
1253 value is cached.
1253 value is cached.
1254
1254
1255 On property delete operations, cached data is removed.
1255 On property delete operations, cached data is removed.
1256
1256
1257 When using the property API, cached data is always returned, if available:
1257 When using the property API, cached data is always returned, if available:
1258 no stat() is performed to check if the file has changed and if the function
1258 no stat() is performed to check if the file has changed and if the function
1259 needs to be called to reflect file changes.
1259 needs to be called to reflect file changes.
1260
1260
1261 Others can muck about with the state of the ``_filecache`` dict. e.g. they
1261 Others can muck about with the state of the ``_filecache`` dict. e.g. they
1262 can populate an entry before the property's getter is called. In this case,
1262 can populate an entry before the property's getter is called. In this case,
1263 entries in ``_filecache`` will be used during property operations,
1263 entries in ``_filecache`` will be used during property operations,
1264 if available. If the underlying file changes, it is up to external callers
1264 if available. If the underlying file changes, it is up to external callers
1265 to reflect this by e.g. calling ``delattr(obj, attr)`` to remove the cached
1265 to reflect this by e.g. calling ``delattr(obj, attr)`` to remove the cached
1266 method result as well as possibly calling ``del obj._filecache[attr]`` to
1266 method result as well as possibly calling ``del obj._filecache[attr]`` to
1267 remove the ``filecacheentry``.
1267 remove the ``filecacheentry``.
1268 """
1268 """
1269
1269
1270 def __init__(self, *paths):
1270 def __init__(self, *paths):
1271 self.paths = paths
1271 self.paths = paths
1272
1272
1273 def join(self, obj, fname):
1273 def join(self, obj, fname):
1274 """Used to compute the runtime path of a cached file.
1274 """Used to compute the runtime path of a cached file.
1275
1275
1276 Users should subclass filecache and provide their own version of this
1276 Users should subclass filecache and provide their own version of this
1277 function to call the appropriate join function on 'obj' (an instance
1277 function to call the appropriate join function on 'obj' (an instance
1278 of the class that its member function was decorated).
1278 of the class that its member function was decorated).
1279 """
1279 """
1280 raise NotImplementedError
1280 raise NotImplementedError
1281
1281
1282 def __call__(self, func):
1282 def __call__(self, func):
1283 self.func = func
1283 self.func = func
1284 self.sname = func.__name__
1284 self.sname = func.__name__
1285 self.name = pycompat.sysbytes(self.sname)
1285 self.name = pycompat.sysbytes(self.sname)
1286 return self
1286 return self
1287
1287
1288 def __get__(self, obj, type=None):
1288 def __get__(self, obj, type=None):
1289 # if accessed on the class, return the descriptor itself.
1289 # if accessed on the class, return the descriptor itself.
1290 if obj is None:
1290 if obj is None:
1291 return self
1291 return self
1292 # do we need to check if the file changed?
1292 # do we need to check if the file changed?
1293 if self.sname in obj.__dict__:
1293 if self.sname in obj.__dict__:
1294 assert self.name in obj._filecache, self.name
1294 assert self.name in obj._filecache, self.name
1295 return obj.__dict__[self.sname]
1295 return obj.__dict__[self.sname]
1296
1296
1297 entry = obj._filecache.get(self.name)
1297 entry = obj._filecache.get(self.name)
1298
1298
1299 if entry:
1299 if entry:
1300 if entry.changed():
1300 if entry.changed():
1301 entry.obj = self.func(obj)
1301 entry.obj = self.func(obj)
1302 else:
1302 else:
1303 paths = [self.join(obj, path) for path in self.paths]
1303 paths = [self.join(obj, path) for path in self.paths]
1304
1304
1305 # We stat -before- creating the object so our cache doesn't lie if
1305 # We stat -before- creating the object so our cache doesn't lie if
1306 # a writer modified between the time we read and stat
1306 # a writer modified between the time we read and stat
1307 entry = filecacheentry(paths, True)
1307 entry = filecacheentry(paths, True)
1308 entry.obj = self.func(obj)
1308 entry.obj = self.func(obj)
1309
1309
1310 obj._filecache[self.name] = entry
1310 obj._filecache[self.name] = entry
1311
1311
1312 obj.__dict__[self.sname] = entry.obj
1312 obj.__dict__[self.sname] = entry.obj
1313 return entry.obj
1313 return entry.obj
1314
1314
1315 def __set__(self, obj, value):
1315 def __set__(self, obj, value):
1316 if self.name not in obj._filecache:
1316 if self.name not in obj._filecache:
1317 # we add an entry for the missing value because X in __dict__
1317 # we add an entry for the missing value because X in __dict__
1318 # implies X in _filecache
1318 # implies X in _filecache
1319 paths = [self.join(obj, path) for path in self.paths]
1319 paths = [self.join(obj, path) for path in self.paths]
1320 ce = filecacheentry(paths, False)
1320 ce = filecacheentry(paths, False)
1321 obj._filecache[self.name] = ce
1321 obj._filecache[self.name] = ce
1322 else:
1322 else:
1323 ce = obj._filecache[self.name]
1323 ce = obj._filecache[self.name]
1324
1324
1325 ce.obj = value # update cached copy
1325 ce.obj = value # update cached copy
1326 obj.__dict__[self.sname] = value # update copy returned by obj.x
1326 obj.__dict__[self.sname] = value # update copy returned by obj.x
1327
1327
1328 def __delete__(self, obj):
1328 def __delete__(self, obj):
1329 try:
1329 try:
1330 del obj.__dict__[self.sname]
1330 del obj.__dict__[self.sname]
1331 except KeyError:
1331 except KeyError:
1332 raise AttributeError(self.sname)
1332 raise AttributeError(self.sname)
1333
1333
1334 def extdatasource(repo, source):
1334 def extdatasource(repo, source):
1335 """Gather a map of rev -> value dict from the specified source
1335 """Gather a map of rev -> value dict from the specified source
1336
1336
1337 A source spec is treated as a URL, with a special case shell: type
1337 A source spec is treated as a URL, with a special case shell: type
1338 for parsing the output from a shell command.
1338 for parsing the output from a shell command.
1339
1339
1340 The data is parsed as a series of newline-separated records where
1340 The data is parsed as a series of newline-separated records where
1341 each record is a revision specifier optionally followed by a space
1341 each record is a revision specifier optionally followed by a space
1342 and a freeform string value. If the revision is known locally, it
1342 and a freeform string value. If the revision is known locally, it
1343 is converted to a rev, otherwise the record is skipped.
1343 is converted to a rev, otherwise the record is skipped.
1344
1344
1345 Note that both key and value are treated as UTF-8 and converted to
1345 Note that both key and value are treated as UTF-8 and converted to
1346 the local encoding. This allows uniformity between local and
1346 the local encoding. This allows uniformity between local and
1347 remote data sources.
1347 remote data sources.
1348 """
1348 """
1349
1349
1350 spec = repo.ui.config("extdata", source)
1350 spec = repo.ui.config("extdata", source)
1351 if not spec:
1351 if not spec:
1352 raise error.Abort(_("unknown extdata source '%s'") % source)
1352 raise error.Abort(_("unknown extdata source '%s'") % source)
1353
1353
1354 data = {}
1354 data = {}
1355 src = proc = None
1355 src = proc = None
1356 try:
1356 try:
1357 if spec.startswith("shell:"):
1357 if spec.startswith("shell:"):
1358 # external commands should be run relative to the repo root
1358 # external commands should be run relative to the repo root
1359 cmd = spec[6:]
1359 cmd = spec[6:]
1360 proc = subprocess.Popen(procutil.tonativestr(cmd),
1360 proc = subprocess.Popen(procutil.tonativestr(cmd),
1361 shell=True, bufsize=-1,
1361 shell=True, bufsize=-1,
1362 close_fds=procutil.closefds,
1362 close_fds=procutil.closefds,
1363 stdout=subprocess.PIPE,
1363 stdout=subprocess.PIPE,
1364 cwd=procutil.tonativestr(repo.root))
1364 cwd=procutil.tonativestr(repo.root))
1365 src = proc.stdout
1365 src = proc.stdout
1366 else:
1366 else:
1367 # treat as a URL or file
1367 # treat as a URL or file
1368 src = url.open(repo.ui, spec)
1368 src = url.open(repo.ui, spec)
1369 for l in src:
1369 for l in src:
1370 if " " in l:
1370 if " " in l:
1371 k, v = l.strip().split(" ", 1)
1371 k, v = l.strip().split(" ", 1)
1372 else:
1372 else:
1373 k, v = l.strip(), ""
1373 k, v = l.strip(), ""
1374
1374
1375 k = encoding.tolocal(k)
1375 k = encoding.tolocal(k)
1376 try:
1376 try:
1377 data[revsingle(repo, k).rev()] = encoding.tolocal(v)
1377 data[revsingle(repo, k).rev()] = encoding.tolocal(v)
1378 except (error.LookupError, error.RepoLookupError):
1378 except (error.LookupError, error.RepoLookupError):
1379 pass # we ignore data for nodes that don't exist locally
1379 pass # we ignore data for nodes that don't exist locally
1380 finally:
1380 finally:
1381 if proc:
1381 if proc:
1382 proc.communicate()
1382 proc.communicate()
1383 if src:
1383 if src:
1384 src.close()
1384 src.close()
1385 if proc and proc.returncode != 0:
1385 if proc and proc.returncode != 0:
1386 raise error.Abort(_("extdata command '%s' failed: %s")
1386 raise error.Abort(_("extdata command '%s' failed: %s")
1387 % (cmd, procutil.explainexit(proc.returncode)))
1387 % (cmd, procutil.explainexit(proc.returncode)))
1388
1388
1389 return data
1389 return data
1390
1390
1391 def _locksub(repo, lock, envvar, cmd, environ=None, *args, **kwargs):
1391 def _locksub(repo, lock, envvar, cmd, environ=None, *args, **kwargs):
1392 if lock is None:
1392 if lock is None:
1393 raise error.LockInheritanceContractViolation(
1393 raise error.LockInheritanceContractViolation(
1394 'lock can only be inherited while held')
1394 'lock can only be inherited while held')
1395 if environ is None:
1395 if environ is None:
1396 environ = {}
1396 environ = {}
1397 with lock.inherit() as locker:
1397 with lock.inherit() as locker:
1398 environ[envvar] = locker
1398 environ[envvar] = locker
1399 return repo.ui.system(cmd, environ=environ, *args, **kwargs)
1399 return repo.ui.system(cmd, environ=environ, *args, **kwargs)
1400
1400
1401 def wlocksub(repo, cmd, *args, **kwargs):
1401 def wlocksub(repo, cmd, *args, **kwargs):
1402 """run cmd as a subprocess that allows inheriting repo's wlock
1402 """run cmd as a subprocess that allows inheriting repo's wlock
1403
1403
1404 This can only be called while the wlock is held. This takes all the
1404 This can only be called while the wlock is held. This takes all the
1405 arguments that ui.system does, and returns the exit code of the
1405 arguments that ui.system does, and returns the exit code of the
1406 subprocess."""
1406 subprocess."""
1407 return _locksub(repo, repo.currentwlock(), 'HG_WLOCK_LOCKER', cmd, *args,
1407 return _locksub(repo, repo.currentwlock(), 'HG_WLOCK_LOCKER', cmd, *args,
1408 **kwargs)
1408 **kwargs)
1409
1409
1410 class progress(object):
1410 class progress(object):
1411 def __init__(self, ui, topic, unit="", total=None):
1411 def __init__(self, ui, topic, unit="", total=None):
1412 self.ui = ui
1412 self.ui = ui
1413 self.pos = 0
1413 self.pos = 0
1414 self.topic = topic
1414 self.topic = topic
1415 self.unit = unit
1415 self.unit = unit
1416 self.total = total
1416 self.total = total
1417
1417
1418 def __enter__(self):
1418 def __enter__(self):
1419 return self
1419 return self
1420
1420
1421 def __exit__(self, exc_type, exc_value, exc_tb):
1421 def __exit__(self, exc_type, exc_value, exc_tb):
1422 self.complete()
1422 self.complete()
1423
1423
1424 def update(self, pos, item="", total=None):
1424 def update(self, pos, item="", total=None):
1425 assert pos is not None
1425 assert pos is not None
1426 if total:
1426 if total:
1427 self.total = total
1427 self.total = total
1428 self.pos = pos
1428 self.pos = pos
1429 self._print(item)
1429 self._print(item)
1430
1430
1431 def increment(self, step=1, item="", total=None):
1431 def increment(self, step=1, item="", total=None):
1432 self.update(self.pos + step, item, total)
1432 self.update(self.pos + step, item, total)
1433
1433
1434 def complete(self):
1434 def complete(self):
1435 self.ui.progress(self.topic, None)
1435 self.ui.progress(self.topic, None)
1436
1436
1437 def _print(self, item):
1437 def _print(self, item):
1438 self.ui.progress(self.topic, self.pos, item, self.unit,
1438 self.ui.progress(self.topic, self.pos, item, self.unit,
1439 self.total)
1439 self.total)
1440
1440
1441 def gdinitconfig(ui):
1441 def gdinitconfig(ui):
1442 """helper function to know if a repo should be created as general delta
1442 """helper function to know if a repo should be created as general delta
1443 """
1443 """
1444 # experimental config: format.generaldelta
1444 # experimental config: format.generaldelta
1445 return (ui.configbool('format', 'generaldelta')
1445 return (ui.configbool('format', 'generaldelta')
1446 or ui.configbool('format', 'usegeneraldelta')
1446 or ui.configbool('format', 'usegeneraldelta')
1447 or ui.configbool('format', 'sparse-revlog'))
1447 or ui.configbool('format', 'sparse-revlog'))
1448
1448
1449 def gddeltaconfig(ui):
1449 def gddeltaconfig(ui):
1450 """helper function to know if incoming delta should be optimised
1450 """helper function to know if incoming delta should be optimised
1451 """
1451 """
1452 # experimental config: format.generaldelta
1452 # experimental config: format.generaldelta
1453 return ui.configbool('format', 'generaldelta')
1453 return ui.configbool('format', 'generaldelta')
1454
1454
1455 class simplekeyvaluefile(object):
1455 class simplekeyvaluefile(object):
1456 """A simple file with key=value lines
1456 """A simple file with key=value lines
1457
1457
1458 Keys must be alphanumerics and start with a letter, values must not
1458 Keys must be alphanumerics and start with a letter, values must not
1459 contain '\n' characters"""
1459 contain '\n' characters"""
1460 firstlinekey = '__firstline'
1460 firstlinekey = '__firstline'
1461
1461
1462 def __init__(self, vfs, path, keys=None):
1462 def __init__(self, vfs, path, keys=None):
1463 self.vfs = vfs
1463 self.vfs = vfs
1464 self.path = path
1464 self.path = path
1465
1465
1466 def read(self, firstlinenonkeyval=False):
1466 def read(self, firstlinenonkeyval=False):
1467 """Read the contents of a simple key-value file
1467 """Read the contents of a simple key-value file
1468
1468
1469 'firstlinenonkeyval' indicates whether the first line of file should
1469 'firstlinenonkeyval' indicates whether the first line of file should
1470 be treated as a key-value pair or reuturned fully under the
1470 be treated as a key-value pair or reuturned fully under the
1471 __firstline key."""
1471 __firstline key."""
1472 lines = self.vfs.readlines(self.path)
1472 lines = self.vfs.readlines(self.path)
1473 d = {}
1473 d = {}
1474 if firstlinenonkeyval:
1474 if firstlinenonkeyval:
1475 if not lines:
1475 if not lines:
1476 e = _("empty simplekeyvalue file")
1476 e = _("empty simplekeyvalue file")
1477 raise error.CorruptedState(e)
1477 raise error.CorruptedState(e)
1478 # we don't want to include '\n' in the __firstline
1478 # we don't want to include '\n' in the __firstline
1479 d[self.firstlinekey] = lines[0][:-1]
1479 d[self.firstlinekey] = lines[0][:-1]
1480 del lines[0]
1480 del lines[0]
1481
1481
1482 try:
1482 try:
1483 # the 'if line.strip()' part prevents us from failing on empty
1483 # the 'if line.strip()' part prevents us from failing on empty
1484 # lines which only contain '\n' therefore are not skipped
1484 # lines which only contain '\n' therefore are not skipped
1485 # by 'if line'
1485 # by 'if line'
1486 updatedict = dict(line[:-1].split('=', 1) for line in lines
1486 updatedict = dict(line[:-1].split('=', 1) for line in lines
1487 if line.strip())
1487 if line.strip())
1488 if self.firstlinekey in updatedict:
1488 if self.firstlinekey in updatedict:
1489 e = _("%r can't be used as a key")
1489 e = _("%r can't be used as a key")
1490 raise error.CorruptedState(e % self.firstlinekey)
1490 raise error.CorruptedState(e % self.firstlinekey)
1491 d.update(updatedict)
1491 d.update(updatedict)
1492 except ValueError as e:
1492 except ValueError as e:
1493 raise error.CorruptedState(str(e))
1493 raise error.CorruptedState(str(e))
1494 return d
1494 return d
1495
1495
1496 def write(self, data, firstline=None):
1496 def write(self, data, firstline=None):
1497 """Write key=>value mapping to a file
1497 """Write key=>value mapping to a file
1498 data is a dict. Keys must be alphanumerical and start with a letter.
1498 data is a dict. Keys must be alphanumerical and start with a letter.
1499 Values must not contain newline characters.
1499 Values must not contain newline characters.
1500
1500
1501 If 'firstline' is not None, it is written to file before
1501 If 'firstline' is not None, it is written to file before
1502 everything else, as it is, not in a key=value form"""
1502 everything else, as it is, not in a key=value form"""
1503 lines = []
1503 lines = []
1504 if firstline is not None:
1504 if firstline is not None:
1505 lines.append('%s\n' % firstline)
1505 lines.append('%s\n' % firstline)
1506
1506
1507 for k, v in data.items():
1507 for k, v in data.items():
1508 if k == self.firstlinekey:
1508 if k == self.firstlinekey:
1509 e = "key name '%s' is reserved" % self.firstlinekey
1509 e = "key name '%s' is reserved" % self.firstlinekey
1510 raise error.ProgrammingError(e)
1510 raise error.ProgrammingError(e)
1511 if not k[0:1].isalpha():
1511 if not k[0:1].isalpha():
1512 e = "keys must start with a letter in a key-value file"
1512 e = "keys must start with a letter in a key-value file"
1513 raise error.ProgrammingError(e)
1513 raise error.ProgrammingError(e)
1514 if not k.isalnum():
1514 if not k.isalnum():
1515 e = "invalid key name in a simple key-value file"
1515 e = "invalid key name in a simple key-value file"
1516 raise error.ProgrammingError(e)
1516 raise error.ProgrammingError(e)
1517 if '\n' in v:
1517 if '\n' in v:
1518 e = "invalid value in a simple key-value file"
1518 e = "invalid value in a simple key-value file"
1519 raise error.ProgrammingError(e)
1519 raise error.ProgrammingError(e)
1520 lines.append("%s=%s\n" % (k, v))
1520 lines.append("%s=%s\n" % (k, v))
1521 with self.vfs(self.path, mode='wb', atomictemp=True) as fp:
1521 with self.vfs(self.path, mode='wb', atomictemp=True) as fp:
1522 fp.write(''.join(lines))
1522 fp.write(''.join(lines))
1523
1523
1524 _reportobsoletedsource = [
1524 _reportobsoletedsource = [
1525 'debugobsolete',
1525 'debugobsolete',
1526 'pull',
1526 'pull',
1527 'push',
1527 'push',
1528 'serve',
1528 'serve',
1529 'unbundle',
1529 'unbundle',
1530 ]
1530 ]
1531
1531
1532 _reportnewcssource = [
1532 _reportnewcssource = [
1533 'pull',
1533 'pull',
1534 'unbundle',
1534 'unbundle',
1535 ]
1535 ]
1536
1536
1537 def prefetchfiles(repo, revs, match):
1537 def prefetchfiles(repo, revs, match):
1538 """Invokes the registered file prefetch functions, allowing extensions to
1538 """Invokes the registered file prefetch functions, allowing extensions to
1539 ensure the corresponding files are available locally, before the command
1539 ensure the corresponding files are available locally, before the command
1540 uses them."""
1540 uses them."""
1541 if match:
1541 if match:
1542 # The command itself will complain about files that don't exist, so
1542 # The command itself will complain about files that don't exist, so
1543 # don't duplicate the message.
1543 # don't duplicate the message.
1544 match = matchmod.badmatch(match, lambda fn, msg: None)
1544 match = matchmod.badmatch(match, lambda fn, msg: None)
1545 else:
1545 else:
1546 match = matchall(repo)
1546 match = matchall(repo)
1547
1547
1548 fileprefetchhooks(repo, revs, match)
1548 fileprefetchhooks(repo, revs, match)
1549
1549
1550 # a list of (repo, revs, match) prefetch functions
1550 # a list of (repo, revs, match) prefetch functions
1551 fileprefetchhooks = util.hooks()
1551 fileprefetchhooks = util.hooks()
1552
1552
1553 # A marker that tells the evolve extension to suppress its own reporting
1553 # A marker that tells the evolve extension to suppress its own reporting
1554 _reportstroubledchangesets = True
1554 _reportstroubledchangesets = True
1555
1555
1556 def registersummarycallback(repo, otr, txnname=''):
1556 def registersummarycallback(repo, otr, txnname=''):
1557 """register a callback to issue a summary after the transaction is closed
1557 """register a callback to issue a summary after the transaction is closed
1558 """
1558 """
1559 def txmatch(sources):
1559 def txmatch(sources):
1560 return any(txnname.startswith(source) for source in sources)
1560 return any(txnname.startswith(source) for source in sources)
1561
1561
1562 categories = []
1562 categories = []
1563
1563
1564 def reportsummary(func):
1564 def reportsummary(func):
1565 """decorator for report callbacks."""
1565 """decorator for report callbacks."""
1566 # The repoview life cycle is shorter than the one of the actual
1566 # The repoview life cycle is shorter than the one of the actual
1567 # underlying repository. So the filtered object can die before the
1567 # underlying repository. So the filtered object can die before the
1568 # weakref is used leading to troubles. We keep a reference to the
1568 # weakref is used leading to troubles. We keep a reference to the
1569 # unfiltered object and restore the filtering when retrieving the
1569 # unfiltered object and restore the filtering when retrieving the
1570 # repository through the weakref.
1570 # repository through the weakref.
1571 filtername = repo.filtername
1571 filtername = repo.filtername
1572 reporef = weakref.ref(repo.unfiltered())
1572 reporef = weakref.ref(repo.unfiltered())
1573 def wrapped(tr):
1573 def wrapped(tr):
1574 repo = reporef()
1574 repo = reporef()
1575 if filtername:
1575 if filtername:
1576 repo = repo.filtered(filtername)
1576 repo = repo.filtered(filtername)
1577 func(repo, tr)
1577 func(repo, tr)
1578 newcat = '%02i-txnreport' % len(categories)
1578 newcat = '%02i-txnreport' % len(categories)
1579 otr.addpostclose(newcat, wrapped)
1579 otr.addpostclose(newcat, wrapped)
1580 categories.append(newcat)
1580 categories.append(newcat)
1581 return wrapped
1581 return wrapped
1582
1582
1583 if txmatch(_reportobsoletedsource):
1583 if txmatch(_reportobsoletedsource):
1584 @reportsummary
1584 @reportsummary
1585 def reportobsoleted(repo, tr):
1585 def reportobsoleted(repo, tr):
1586 obsoleted = obsutil.getobsoleted(repo, tr)
1586 obsoleted = obsutil.getobsoleted(repo, tr)
1587 if obsoleted:
1587 if obsoleted:
1588 repo.ui.status(_('obsoleted %i changesets\n')
1588 repo.ui.status(_('obsoleted %i changesets\n')
1589 % len(obsoleted))
1589 % len(obsoleted))
1590
1590
1591 if (obsolete.isenabled(repo, obsolete.createmarkersopt) and
1591 if (obsolete.isenabled(repo, obsolete.createmarkersopt) and
1592 repo.ui.configbool('experimental', 'evolution.report-instabilities')):
1592 repo.ui.configbool('experimental', 'evolution.report-instabilities')):
1593 instabilitytypes = [
1593 instabilitytypes = [
1594 ('orphan', 'orphan'),
1594 ('orphan', 'orphan'),
1595 ('phase-divergent', 'phasedivergent'),
1595 ('phase-divergent', 'phasedivergent'),
1596 ('content-divergent', 'contentdivergent'),
1596 ('content-divergent', 'contentdivergent'),
1597 ]
1597 ]
1598
1598
1599 def getinstabilitycounts(repo):
1599 def getinstabilitycounts(repo):
1600 filtered = repo.changelog.filteredrevs
1600 filtered = repo.changelog.filteredrevs
1601 counts = {}
1601 counts = {}
1602 for instability, revset in instabilitytypes:
1602 for instability, revset in instabilitytypes:
1603 counts[instability] = len(set(obsolete.getrevs(repo, revset)) -
1603 counts[instability] = len(set(obsolete.getrevs(repo, revset)) -
1604 filtered)
1604 filtered)
1605 return counts
1605 return counts
1606
1606
1607 oldinstabilitycounts = getinstabilitycounts(repo)
1607 oldinstabilitycounts = getinstabilitycounts(repo)
1608 @reportsummary
1608 @reportsummary
1609 def reportnewinstabilities(repo, tr):
1609 def reportnewinstabilities(repo, tr):
1610 newinstabilitycounts = getinstabilitycounts(repo)
1610 newinstabilitycounts = getinstabilitycounts(repo)
1611 for instability, revset in instabilitytypes:
1611 for instability, revset in instabilitytypes:
1612 delta = (newinstabilitycounts[instability] -
1612 delta = (newinstabilitycounts[instability] -
1613 oldinstabilitycounts[instability])
1613 oldinstabilitycounts[instability])
1614 msg = getinstabilitymessage(delta, instability)
1614 msg = getinstabilitymessage(delta, instability)
1615 if msg:
1615 if msg:
1616 repo.ui.warn(msg)
1616 repo.ui.warn(msg)
1617
1617
1618 if txmatch(_reportnewcssource):
1618 if txmatch(_reportnewcssource):
1619 @reportsummary
1619 @reportsummary
1620 def reportnewcs(repo, tr):
1620 def reportnewcs(repo, tr):
1621 """Report the range of new revisions pulled/unbundled."""
1621 """Report the range of new revisions pulled/unbundled."""
1622 origrepolen = tr.changes.get('origrepolen', len(repo))
1622 origrepolen = tr.changes.get('origrepolen', len(repo))
1623 unfi = repo.unfiltered()
1623 unfi = repo.unfiltered()
1624 if origrepolen >= len(unfi):
1624 if origrepolen >= len(unfi):
1625 return
1625 return
1626
1626
1627 # Compute the bounds of new visible revisions' range.
1627 # Compute the bounds of new visible revisions' range.
1628 revs = smartset.spanset(repo, start=origrepolen)
1628 revs = smartset.spanset(repo, start=origrepolen)
1629 if revs:
1629 if revs:
1630 minrev, maxrev = repo[revs.min()], repo[revs.max()]
1630 minrev, maxrev = repo[revs.min()], repo[revs.max()]
1631
1631
1632 if minrev == maxrev:
1632 if minrev == maxrev:
1633 revrange = minrev
1633 revrange = minrev
1634 else:
1634 else:
1635 revrange = '%s:%s' % (minrev, maxrev)
1635 revrange = '%s:%s' % (minrev, maxrev)
1636 draft = len(repo.revs('%ld and draft()', revs))
1636 draft = len(repo.revs('%ld and draft()', revs))
1637 secret = len(repo.revs('%ld and secret()', revs))
1637 secret = len(repo.revs('%ld and secret()', revs))
1638 if not (draft or secret):
1638 if not (draft or secret):
1639 msg = _('new changesets %s\n') % revrange
1639 msg = _('new changesets %s\n') % revrange
1640 elif draft and secret:
1640 elif draft and secret:
1641 msg = _('new changesets %s (%d drafts, %d secrets)\n')
1641 msg = _('new changesets %s (%d drafts, %d secrets)\n')
1642 msg %= (revrange, draft, secret)
1642 msg %= (revrange, draft, secret)
1643 elif draft:
1643 elif draft:
1644 msg = _('new changesets %s (%d drafts)\n')
1644 msg = _('new changesets %s (%d drafts)\n')
1645 msg %= (revrange, draft)
1645 msg %= (revrange, draft)
1646 elif secret:
1646 elif secret:
1647 msg = _('new changesets %s (%d secrets)\n')
1647 msg = _('new changesets %s (%d secrets)\n')
1648 msg %= (revrange, secret)
1648 msg %= (revrange, secret)
1649 else:
1649 else:
1650 errormsg = 'entered unreachable condition'
1650 errormsg = 'entered unreachable condition'
1651 raise error.ProgrammingError(errormsg)
1651 raise error.ProgrammingError(errormsg)
1652 repo.ui.status(msg)
1652 repo.ui.status(msg)
1653
1653
1654 # search new changesets directly pulled as obsolete
1654 # search new changesets directly pulled as obsolete
1655 obsadded = unfi.revs('%d: and obsolete()', origrepolen)
1655 duplicates = tr.changes.get('revduplicates', ())
1656 obsadded = unfi.revs('(%d: + %ld) and obsolete()',
1657 origrepolen, duplicates)
1656 cl = repo.changelog
1658 cl = repo.changelog
1657 extinctadded = [r for r in obsadded if r not in cl]
1659 extinctadded = [r for r in obsadded if r not in cl]
1658 if extinctadded:
1660 if extinctadded:
1659 # They are not just obsolete, but obsolete and invisible
1661 # They are not just obsolete, but obsolete and invisible
1660 # we call them "extinct" internally but the terms have not been
1662 # we call them "extinct" internally but the terms have not been
1661 # exposed to users.
1663 # exposed to users.
1662 msg = '(%d other changesets obsolete on arrival)\n'
1664 msg = '(%d other changesets obsolete on arrival)\n'
1663 repo.ui.status(msg % len(extinctadded))
1665 repo.ui.status(msg % len(extinctadded))
1664
1666
1665 @reportsummary
1667 @reportsummary
1666 def reportphasechanges(repo, tr):
1668 def reportphasechanges(repo, tr):
1667 """Report statistics of phase changes for changesets pre-existing
1669 """Report statistics of phase changes for changesets pre-existing
1668 pull/unbundle.
1670 pull/unbundle.
1669 """
1671 """
1670 origrepolen = tr.changes.get('origrepolen', len(repo))
1672 origrepolen = tr.changes.get('origrepolen', len(repo))
1671 phasetracking = tr.changes.get('phases', {})
1673 phasetracking = tr.changes.get('phases', {})
1672 if not phasetracking:
1674 if not phasetracking:
1673 return
1675 return
1674 published = [
1676 published = [
1675 rev for rev, (old, new) in phasetracking.iteritems()
1677 rev for rev, (old, new) in phasetracking.iteritems()
1676 if new == phases.public and rev < origrepolen
1678 if new == phases.public and rev < origrepolen
1677 ]
1679 ]
1678 if not published:
1680 if not published:
1679 return
1681 return
1680 repo.ui.status(_('%d local changesets published\n')
1682 repo.ui.status(_('%d local changesets published\n')
1681 % len(published))
1683 % len(published))
1682
1684
1683 def getinstabilitymessage(delta, instability):
1685 def getinstabilitymessage(delta, instability):
1684 """function to return the message to show warning about new instabilities
1686 """function to return the message to show warning about new instabilities
1685
1687
1686 exists as a separate function so that extension can wrap to show more
1688 exists as a separate function so that extension can wrap to show more
1687 information like how to fix instabilities"""
1689 information like how to fix instabilities"""
1688 if delta > 0:
1690 if delta > 0:
1689 return _('%i new %s changesets\n') % (delta, instability)
1691 return _('%i new %s changesets\n') % (delta, instability)
1690
1692
1691 def nodesummaries(repo, nodes, maxnumnodes=4):
1693 def nodesummaries(repo, nodes, maxnumnodes=4):
1692 if len(nodes) <= maxnumnodes or repo.ui.verbose:
1694 if len(nodes) <= maxnumnodes or repo.ui.verbose:
1693 return ' '.join(short(h) for h in nodes)
1695 return ' '.join(short(h) for h in nodes)
1694 first = ' '.join(short(h) for h in nodes[:maxnumnodes])
1696 first = ' '.join(short(h) for h in nodes[:maxnumnodes])
1695 return _("%s and %d others") % (first, len(nodes) - maxnumnodes)
1697 return _("%s and %d others") % (first, len(nodes) - maxnumnodes)
1696
1698
1697 def enforcesinglehead(repo, tr, desc):
1699 def enforcesinglehead(repo, tr, desc):
1698 """check that no named branch has multiple heads"""
1700 """check that no named branch has multiple heads"""
1699 if desc in ('strip', 'repair'):
1701 if desc in ('strip', 'repair'):
1700 # skip the logic during strip
1702 # skip the logic during strip
1701 return
1703 return
1702 visible = repo.filtered('visible')
1704 visible = repo.filtered('visible')
1703 # possible improvement: we could restrict the check to affected branch
1705 # possible improvement: we could restrict the check to affected branch
1704 for name, heads in visible.branchmap().iteritems():
1706 for name, heads in visible.branchmap().iteritems():
1705 if len(heads) > 1:
1707 if len(heads) > 1:
1706 msg = _('rejecting multiple heads on branch "%s"')
1708 msg = _('rejecting multiple heads on branch "%s"')
1707 msg %= name
1709 msg %= name
1708 hint = _('%d heads: %s')
1710 hint = _('%d heads: %s')
1709 hint %= (len(heads), nodesummaries(repo, heads))
1711 hint %= (len(heads), nodesummaries(repo, heads))
1710 raise error.Abort(msg, hint=hint)
1712 raise error.Abort(msg, hint=hint)
1711
1713
1712 def wrapconvertsink(sink):
1714 def wrapconvertsink(sink):
1713 """Allow extensions to wrap the sink returned by convcmd.convertsink()
1715 """Allow extensions to wrap the sink returned by convcmd.convertsink()
1714 before it is used, whether or not the convert extension was formally loaded.
1716 before it is used, whether or not the convert extension was formally loaded.
1715 """
1717 """
1716 return sink
1718 return sink
1717
1719
1718 def unhidehashlikerevs(repo, specs, hiddentype):
1720 def unhidehashlikerevs(repo, specs, hiddentype):
1719 """parse the user specs and unhide changesets whose hash or revision number
1721 """parse the user specs and unhide changesets whose hash or revision number
1720 is passed.
1722 is passed.
1721
1723
1722 hiddentype can be: 1) 'warn': warn while unhiding changesets
1724 hiddentype can be: 1) 'warn': warn while unhiding changesets
1723 2) 'nowarn': don't warn while unhiding changesets
1725 2) 'nowarn': don't warn while unhiding changesets
1724
1726
1725 returns a repo object with the required changesets unhidden
1727 returns a repo object with the required changesets unhidden
1726 """
1728 """
1727 if not repo.filtername or not repo.ui.configbool('experimental',
1729 if not repo.filtername or not repo.ui.configbool('experimental',
1728 'directaccess'):
1730 'directaccess'):
1729 return repo
1731 return repo
1730
1732
1731 if repo.filtername not in ('visible', 'visible-hidden'):
1733 if repo.filtername not in ('visible', 'visible-hidden'):
1732 return repo
1734 return repo
1733
1735
1734 symbols = set()
1736 symbols = set()
1735 for spec in specs:
1737 for spec in specs:
1736 try:
1738 try:
1737 tree = revsetlang.parse(spec)
1739 tree = revsetlang.parse(spec)
1738 except error.ParseError: # will be reported by scmutil.revrange()
1740 except error.ParseError: # will be reported by scmutil.revrange()
1739 continue
1741 continue
1740
1742
1741 symbols.update(revsetlang.gethashlikesymbols(tree))
1743 symbols.update(revsetlang.gethashlikesymbols(tree))
1742
1744
1743 if not symbols:
1745 if not symbols:
1744 return repo
1746 return repo
1745
1747
1746 revs = _getrevsfromsymbols(repo, symbols)
1748 revs = _getrevsfromsymbols(repo, symbols)
1747
1749
1748 if not revs:
1750 if not revs:
1749 return repo
1751 return repo
1750
1752
1751 if hiddentype == 'warn':
1753 if hiddentype == 'warn':
1752 unfi = repo.unfiltered()
1754 unfi = repo.unfiltered()
1753 revstr = ", ".join([pycompat.bytestr(unfi[l]) for l in revs])
1755 revstr = ", ".join([pycompat.bytestr(unfi[l]) for l in revs])
1754 repo.ui.warn(_("warning: accessing hidden changesets for write "
1756 repo.ui.warn(_("warning: accessing hidden changesets for write "
1755 "operation: %s\n") % revstr)
1757 "operation: %s\n") % revstr)
1756
1758
1757 # we have to use new filtername to separate branch/tags cache until we can
1759 # we have to use new filtername to separate branch/tags cache until we can
1758 # disbale these cache when revisions are dynamically pinned.
1760 # disbale these cache when revisions are dynamically pinned.
1759 return repo.filtered('visible-hidden', revs)
1761 return repo.filtered('visible-hidden', revs)
1760
1762
1761 def _getrevsfromsymbols(repo, symbols):
1763 def _getrevsfromsymbols(repo, symbols):
1762 """parse the list of symbols and returns a set of revision numbers of hidden
1764 """parse the list of symbols and returns a set of revision numbers of hidden
1763 changesets present in symbols"""
1765 changesets present in symbols"""
1764 revs = set()
1766 revs = set()
1765 unfi = repo.unfiltered()
1767 unfi = repo.unfiltered()
1766 unficl = unfi.changelog
1768 unficl = unfi.changelog
1767 cl = repo.changelog
1769 cl = repo.changelog
1768 tiprev = len(unficl)
1770 tiprev = len(unficl)
1769 allowrevnums = repo.ui.configbool('experimental', 'directaccess.revnums')
1771 allowrevnums = repo.ui.configbool('experimental', 'directaccess.revnums')
1770 for s in symbols:
1772 for s in symbols:
1771 try:
1773 try:
1772 n = int(s)
1774 n = int(s)
1773 if n <= tiprev:
1775 if n <= tiprev:
1774 if not allowrevnums:
1776 if not allowrevnums:
1775 continue
1777 continue
1776 else:
1778 else:
1777 if n not in cl:
1779 if n not in cl:
1778 revs.add(n)
1780 revs.add(n)
1779 continue
1781 continue
1780 except ValueError:
1782 except ValueError:
1781 pass
1783 pass
1782
1784
1783 try:
1785 try:
1784 s = resolvehexnodeidprefix(unfi, s)
1786 s = resolvehexnodeidprefix(unfi, s)
1785 except (error.LookupError, error.WdirUnsupported):
1787 except (error.LookupError, error.WdirUnsupported):
1786 s = None
1788 s = None
1787
1789
1788 if s is not None:
1790 if s is not None:
1789 rev = unficl.rev(s)
1791 rev = unficl.rev(s)
1790 if rev not in cl:
1792 if rev not in cl:
1791 revs.add(rev)
1793 revs.add(rev)
1792
1794
1793 return revs
1795 return revs
1794
1796
1795 def bookmarkrevs(repo, mark):
1797 def bookmarkrevs(repo, mark):
1796 """
1798 """
1797 Select revisions reachable by a given bookmark
1799 Select revisions reachable by a given bookmark
1798 """
1800 """
1799 return repo.revs("ancestors(bookmark(%s)) - "
1801 return repo.revs("ancestors(bookmark(%s)) - "
1800 "ancestors(head() and not bookmark(%s)) - "
1802 "ancestors(head() and not bookmark(%s)) - "
1801 "ancestors(bookmark() and not bookmark(%s))",
1803 "ancestors(bookmark() and not bookmark(%s))",
1802 mark, mark, mark)
1804 mark, mark, mark)
@@ -1,1621 +1,1622 b''
1 $ cat >> $HGRCPATH << EOF
1 $ cat >> $HGRCPATH << EOF
2 > [phases]
2 > [phases]
3 > # public changeset are not obsolete
3 > # public changeset are not obsolete
4 > publish=false
4 > publish=false
5 > [ui]
5 > [ui]
6 > logtemplate="{rev}:{node|short} ({phase}{if(obsolete, ' *{obsolete}*')}{if(instabilities, ' {instabilities}')}) [{tags} {bookmarks}] {desc|firstline}{if(obsfate, " [{join(obsfate, "; ")}]")}\n"
6 > logtemplate="{rev}:{node|short} ({phase}{if(obsolete, ' *{obsolete}*')}{if(instabilities, ' {instabilities}')}) [{tags} {bookmarks}] {desc|firstline}{if(obsfate, " [{join(obsfate, "; ")}]")}\n"
7 > EOF
7 > EOF
8 $ mkcommit() {
8 $ mkcommit() {
9 > echo "$1" > "$1"
9 > echo "$1" > "$1"
10 > hg add "$1"
10 > hg add "$1"
11 > hg ci -m "add $1"
11 > hg ci -m "add $1"
12 > }
12 > }
13 $ getid() {
13 $ getid() {
14 > hg log -T "{node}\n" --hidden -r "desc('$1')"
14 > hg log -T "{node}\n" --hidden -r "desc('$1')"
15 > }
15 > }
16
16
17 $ cat > debugkeys.py <<EOF
17 $ cat > debugkeys.py <<EOF
18 > def reposetup(ui, repo):
18 > def reposetup(ui, repo):
19 > class debugkeysrepo(repo.__class__):
19 > class debugkeysrepo(repo.__class__):
20 > def listkeys(self, namespace):
20 > def listkeys(self, namespace):
21 > ui.write(b'listkeys %s\n' % (namespace,))
21 > ui.write(b'listkeys %s\n' % (namespace,))
22 > return super(debugkeysrepo, self).listkeys(namespace)
22 > return super(debugkeysrepo, self).listkeys(namespace)
23 >
23 >
24 > if repo.local():
24 > if repo.local():
25 > repo.__class__ = debugkeysrepo
25 > repo.__class__ = debugkeysrepo
26 > EOF
26 > EOF
27
27
28 $ hg init tmpa
28 $ hg init tmpa
29 $ cd tmpa
29 $ cd tmpa
30 $ mkcommit kill_me
30 $ mkcommit kill_me
31
31
32 Checking that the feature is properly disabled
32 Checking that the feature is properly disabled
33
33
34 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
34 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
35 abort: creating obsolete markers is not enabled on this repo
35 abort: creating obsolete markers is not enabled on this repo
36 [255]
36 [255]
37
37
38 Enabling it
38 Enabling it
39
39
40 $ cat >> $HGRCPATH << EOF
40 $ cat >> $HGRCPATH << EOF
41 > [experimental]
41 > [experimental]
42 > evolution=exchange
42 > evolution=exchange
43 > evolution.createmarkers=True
43 > evolution.createmarkers=True
44 > EOF
44 > EOF
45
45
46 Killing a single changeset without replacement
46 Killing a single changeset without replacement
47
47
48 $ hg debugobsolete 0
48 $ hg debugobsolete 0
49 abort: changeset references must be full hexadecimal node identifiers
49 abort: changeset references must be full hexadecimal node identifiers
50 [255]
50 [255]
51 $ hg debugobsolete '00'
51 $ hg debugobsolete '00'
52 abort: changeset references must be full hexadecimal node identifiers
52 abort: changeset references must be full hexadecimal node identifiers
53 [255]
53 [255]
54 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
54 $ hg debugobsolete -d '0 0' `getid kill_me` -u babar
55 obsoleted 1 changesets
55 obsoleted 1 changesets
56 $ hg debugobsolete
56 $ hg debugobsolete
57 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'babar'}
57 97b7c2d76b1845ed3eb988cd612611e72406cef0 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'babar'}
58
58
59 (test that mercurial is not confused)
59 (test that mercurial is not confused)
60
60
61 $ hg up null --quiet # having 0 as parent prevents it to be hidden
61 $ hg up null --quiet # having 0 as parent prevents it to be hidden
62 $ hg tip
62 $ hg tip
63 -1:000000000000 (public) [tip ]
63 -1:000000000000 (public) [tip ]
64 $ hg up --hidden tip --quiet
64 $ hg up --hidden tip --quiet
65 updated to hidden changeset 97b7c2d76b18
65 updated to hidden changeset 97b7c2d76b18
66 (hidden revision '97b7c2d76b18' is pruned)
66 (hidden revision '97b7c2d76b18' is pruned)
67
67
68 Killing a single changeset with itself should fail
68 Killing a single changeset with itself should fail
69 (simple local safeguard)
69 (simple local safeguard)
70
70
71 $ hg debugobsolete `getid kill_me` `getid kill_me`
71 $ hg debugobsolete `getid kill_me` `getid kill_me`
72 abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0
72 abort: bad obsmarker input: in-marker cycle with 97b7c2d76b1845ed3eb988cd612611e72406cef0
73 [255]
73 [255]
74
74
75 $ cd ..
75 $ cd ..
76
76
77 Killing a single changeset with replacement
77 Killing a single changeset with replacement
78 (and testing the format option)
78 (and testing the format option)
79
79
80 $ hg init tmpb
80 $ hg init tmpb
81 $ cd tmpb
81 $ cd tmpb
82 $ mkcommit a
82 $ mkcommit a
83 $ mkcommit b
83 $ mkcommit b
84 $ mkcommit original_c
84 $ mkcommit original_c
85 $ hg up "desc('b')"
85 $ hg up "desc('b')"
86 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
86 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
87 $ mkcommit new_c
87 $ mkcommit new_c
88 created new head
88 created new head
89 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
89 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
90 $ hg debugobsolete --config format.obsstore-version=0 --flag 12 `getid original_c` `getid new_c` -d '121 120'
90 $ hg debugobsolete --config format.obsstore-version=0 --flag 12 `getid original_c` `getid new_c` -d '121 120'
91 obsoleted 1 changesets
91 obsoleted 1 changesets
92 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
92 $ hg log -r 'hidden()' --template '{rev}:{node|short} {desc}\n' --hidden
93 2:245bde4270cd add original_c
93 2:245bde4270cd add original_c
94 $ hg debugrevlog -cd
94 $ hg debugrevlog -cd
95 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
95 # rev p1rev p2rev start end deltastart base p1 p2 rawsize totalsize compression heads chainlen
96 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0
96 0 -1 -1 0 59 0 0 0 0 58 58 0 1 0
97 1 0 -1 59 118 59 59 0 0 58 116 0 1 0
97 1 0 -1 59 118 59 59 0 0 58 116 0 1 0
98 2 1 -1 118 193 118 118 59 0 76 192 0 1 0
98 2 1 -1 118 193 118 118 59 0 76 192 0 1 0
99 3 1 -1 193 260 193 193 59 0 66 258 0 2 0
99 3 1 -1 193 260 193 193 59 0 66 258 0 2 0
100 $ hg debugobsolete
100 $ hg debugobsolete
101 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
101 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
102
102
103 (check for version number of the obsstore)
103 (check for version number of the obsstore)
104
104
105 $ dd bs=1 count=1 if=.hg/store/obsstore 2>/dev/null
105 $ dd bs=1 count=1 if=.hg/store/obsstore 2>/dev/null
106 \x00 (no-eol) (esc)
106 \x00 (no-eol) (esc)
107
107
108 do it again (it read the obsstore before adding new changeset)
108 do it again (it read the obsstore before adding new changeset)
109
109
110 $ hg up '.^'
110 $ hg up '.^'
111 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
111 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
112 $ mkcommit new_2_c
112 $ mkcommit new_2_c
113 created new head
113 created new head
114 $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
114 $ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
115 obsoleted 1 changesets
115 obsoleted 1 changesets
116 $ hg debugobsolete
116 $ hg debugobsolete
117 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
117 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
118 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
118 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
119
119
120 Register two markers with a missing node
120 Register two markers with a missing node
121
121
122 $ hg up '.^'
122 $ hg up '.^'
123 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
123 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
124 $ mkcommit new_3_c
124 $ mkcommit new_3_c
125 created new head
125 created new head
126 $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337
126 $ hg debugobsolete -d '1338 0' `getid new_2_c` 1337133713371337133713371337133713371337
127 obsoleted 1 changesets
127 obsoleted 1 changesets
128 $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c`
128 $ hg debugobsolete -d '1339 0' 1337133713371337133713371337133713371337 `getid new_3_c`
129 $ hg debugobsolete
129 $ hg debugobsolete
130 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
130 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
131 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
131 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
132 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
132 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
133 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
133 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
134
134
135 Test the --index option of debugobsolete command
135 Test the --index option of debugobsolete command
136 $ hg debugobsolete --index
136 $ hg debugobsolete --index
137 0 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
137 0 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
138 1 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
138 1 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
139 2 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
139 2 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
140 3 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
140 3 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
141
141
142 Refuse pathological nullid successors
142 Refuse pathological nullid successors
143 $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000
143 $ hg debugobsolete -d '9001 0' 1337133713371337133713371337133713371337 0000000000000000000000000000000000000000
144 transaction abort!
144 transaction abort!
145 rollback completed
145 rollback completed
146 abort: bad obsolescence marker detected: invalid successors nullid
146 abort: bad obsolescence marker detected: invalid successors nullid
147 [255]
147 [255]
148
148
149 Check that graphlog detect that a changeset is obsolete:
149 Check that graphlog detect that a changeset is obsolete:
150
150
151 $ hg log -G
151 $ hg log -G
152 @ 5:5601fb93a350 (draft) [tip ] add new_3_c
152 @ 5:5601fb93a350 (draft) [tip ] add new_3_c
153 |
153 |
154 o 1:7c3bad9141dc (draft) [ ] add b
154 o 1:7c3bad9141dc (draft) [ ] add b
155 |
155 |
156 o 0:1f0dee641bb7 (draft) [ ] add a
156 o 0:1f0dee641bb7 (draft) [ ] add a
157
157
158
158
159 check that heads does not report them
159 check that heads does not report them
160
160
161 $ hg heads
161 $ hg heads
162 5:5601fb93a350 (draft) [tip ] add new_3_c
162 5:5601fb93a350 (draft) [tip ] add new_3_c
163 $ hg heads --hidden
163 $ hg heads --hidden
164 5:5601fb93a350 (draft) [tip ] add new_3_c
164 5:5601fb93a350 (draft) [tip ] add new_3_c
165 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
165 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
166 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
166 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
167 2:245bde4270cd (draft *obsolete*) [ ] add original_c [rewritten as 3:cdbce2fbb163]
167 2:245bde4270cd (draft *obsolete*) [ ] add original_c [rewritten as 3:cdbce2fbb163]
168
168
169
169
170 check that summary does not report them
170 check that summary does not report them
171
171
172 $ hg init ../sink
172 $ hg init ../sink
173 $ echo '[paths]' >> .hg/hgrc
173 $ echo '[paths]' >> .hg/hgrc
174 $ echo 'default=../sink' >> .hg/hgrc
174 $ echo 'default=../sink' >> .hg/hgrc
175 $ hg summary --remote
175 $ hg summary --remote
176 parent: 5:5601fb93a350 tip
176 parent: 5:5601fb93a350 tip
177 add new_3_c
177 add new_3_c
178 branch: default
178 branch: default
179 commit: (clean)
179 commit: (clean)
180 update: (current)
180 update: (current)
181 phases: 3 draft
181 phases: 3 draft
182 remote: 3 outgoing
182 remote: 3 outgoing
183
183
184 $ hg summary --remote --hidden
184 $ hg summary --remote --hidden
185 parent: 5:5601fb93a350 tip
185 parent: 5:5601fb93a350 tip
186 add new_3_c
186 add new_3_c
187 branch: default
187 branch: default
188 commit: (clean)
188 commit: (clean)
189 update: 3 new changesets, 4 branch heads (merge)
189 update: 3 new changesets, 4 branch heads (merge)
190 phases: 6 draft
190 phases: 6 draft
191 remote: 3 outgoing
191 remote: 3 outgoing
192
192
193 check that various commands work well with filtering
193 check that various commands work well with filtering
194
194
195 $ hg tip
195 $ hg tip
196 5:5601fb93a350 (draft) [tip ] add new_3_c
196 5:5601fb93a350 (draft) [tip ] add new_3_c
197 $ hg log -r 6
197 $ hg log -r 6
198 abort: unknown revision '6'!
198 abort: unknown revision '6'!
199 [255]
199 [255]
200 $ hg log -r 4
200 $ hg log -r 4
201 abort: hidden revision '4' was rewritten as: 5601fb93a350!
201 abort: hidden revision '4' was rewritten as: 5601fb93a350!
202 (use --hidden to access hidden revisions)
202 (use --hidden to access hidden revisions)
203 [255]
203 [255]
204 $ hg debugrevspec 'rev(6)'
204 $ hg debugrevspec 'rev(6)'
205 $ hg debugrevspec 'rev(4)'
205 $ hg debugrevspec 'rev(4)'
206 $ hg debugrevspec 'null'
206 $ hg debugrevspec 'null'
207 -1
207 -1
208
208
209 Check that public changeset are not accounted as obsolete:
209 Check that public changeset are not accounted as obsolete:
210
210
211 $ hg --hidden phase --public 2
211 $ hg --hidden phase --public 2
212 1 new phase-divergent changesets
212 1 new phase-divergent changesets
213 $ hg log -G
213 $ hg log -G
214 @ 5:5601fb93a350 (draft phase-divergent) [tip ] add new_3_c
214 @ 5:5601fb93a350 (draft phase-divergent) [tip ] add new_3_c
215 |
215 |
216 | o 2:245bde4270cd (public) [ ] add original_c
216 | o 2:245bde4270cd (public) [ ] add original_c
217 |/
217 |/
218 o 1:7c3bad9141dc (public) [ ] add b
218 o 1:7c3bad9141dc (public) [ ] add b
219 |
219 |
220 o 0:1f0dee641bb7 (public) [ ] add a
220 o 0:1f0dee641bb7 (public) [ ] add a
221
221
222
222
223 And that bumped changeset are detected
223 And that bumped changeset are detected
224 --------------------------------------
224 --------------------------------------
225
225
226 If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also
226 If we didn't filtered obsolete changesets out, 3 and 4 would show up too. Also
227 note that the bumped changeset (5:5601fb93a350) is not a direct successor of
227 note that the bumped changeset (5:5601fb93a350) is not a direct successor of
228 the public changeset
228 the public changeset
229
229
230 $ hg log --hidden -r 'phasedivergent()'
230 $ hg log --hidden -r 'phasedivergent()'
231 5:5601fb93a350 (draft phase-divergent) [tip ] add new_3_c
231 5:5601fb93a350 (draft phase-divergent) [tip ] add new_3_c
232
232
233 And that we can't push bumped changeset
233 And that we can't push bumped changeset
234
234
235 $ hg push ../tmpa -r 0 --force #(make repo related)
235 $ hg push ../tmpa -r 0 --force #(make repo related)
236 pushing to ../tmpa
236 pushing to ../tmpa
237 searching for changes
237 searching for changes
238 warning: repository is unrelated
238 warning: repository is unrelated
239 adding changesets
239 adding changesets
240 adding manifests
240 adding manifests
241 adding file changes
241 adding file changes
242 added 1 changesets with 1 changes to 1 files (+1 heads)
242 added 1 changesets with 1 changes to 1 files (+1 heads)
243 $ hg push ../tmpa
243 $ hg push ../tmpa
244 pushing to ../tmpa
244 pushing to ../tmpa
245 searching for changes
245 searching for changes
246 abort: push includes phase-divergent changeset: 5601fb93a350!
246 abort: push includes phase-divergent changeset: 5601fb93a350!
247 [255]
247 [255]
248
248
249 Fixing "bumped" situation
249 Fixing "bumped" situation
250 We need to create a clone of 5 and add a special marker with a flag
250 We need to create a clone of 5 and add a special marker with a flag
251
251
252 $ hg summary
252 $ hg summary
253 parent: 5:5601fb93a350 tip (phase-divergent)
253 parent: 5:5601fb93a350 tip (phase-divergent)
254 add new_3_c
254 add new_3_c
255 branch: default
255 branch: default
256 commit: (clean)
256 commit: (clean)
257 update: 1 new changesets, 2 branch heads (merge)
257 update: 1 new changesets, 2 branch heads (merge)
258 phases: 1 draft
258 phases: 1 draft
259 phase-divergent: 1 changesets
259 phase-divergent: 1 changesets
260 $ hg up '5^'
260 $ hg up '5^'
261 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
261 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
262 $ hg revert -ar 5
262 $ hg revert -ar 5
263 adding new_3_c
263 adding new_3_c
264 $ hg ci -m 'add n3w_3_c'
264 $ hg ci -m 'add n3w_3_c'
265 created new head
265 created new head
266 $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c`
266 $ hg debugobsolete -d '1338 0' --flags 1 `getid new_3_c` `getid n3w_3_c`
267 obsoleted 1 changesets
267 obsoleted 1 changesets
268 $ hg log -r 'phasedivergent()'
268 $ hg log -r 'phasedivergent()'
269 $ hg log -G
269 $ hg log -G
270 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
270 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
271 |
271 |
272 | o 2:245bde4270cd (public) [ ] add original_c
272 | o 2:245bde4270cd (public) [ ] add original_c
273 |/
273 |/
274 o 1:7c3bad9141dc (public) [ ] add b
274 o 1:7c3bad9141dc (public) [ ] add b
275 |
275 |
276 o 0:1f0dee641bb7 (public) [ ] add a
276 o 0:1f0dee641bb7 (public) [ ] add a
277
277
278
278
279 Basic exclusive testing
279 Basic exclusive testing
280
280
281 $ hg log -G --hidden
281 $ hg log -G --hidden
282 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
282 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
283 |
283 |
284 | x 5:5601fb93a350 (draft *obsolete*) [ ] add new_3_c [rewritten as 6:6f9641995072]
284 | x 5:5601fb93a350 (draft *obsolete*) [ ] add new_3_c [rewritten as 6:6f9641995072]
285 |/
285 |/
286 | x 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
286 | x 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
287 |/
287 |/
288 | x 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
288 | x 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
289 |/
289 |/
290 | o 2:245bde4270cd (public) [ ] add original_c
290 | o 2:245bde4270cd (public) [ ] add original_c
291 |/
291 |/
292 o 1:7c3bad9141dc (public) [ ] add b
292 o 1:7c3bad9141dc (public) [ ] add b
293 |
293 |
294 o 0:1f0dee641bb7 (public) [ ] add a
294 o 0:1f0dee641bb7 (public) [ ] add a
295
295
296 $ hg debugobsolete --rev 6f9641995072
296 $ hg debugobsolete --rev 6f9641995072
297 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
297 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
298 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
298 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
299 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
299 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
300 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
300 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
301 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
301 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
302 $ hg debugobsolete --rev 6f9641995072 --exclusive
302 $ hg debugobsolete --rev 6f9641995072 --exclusive
303 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
303 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
304 $ hg debugobsolete --rev 5601fb93a350 --hidden
304 $ hg debugobsolete --rev 5601fb93a350 --hidden
305 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
305 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
306 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
306 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
307 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
307 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
308 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
308 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
309 $ hg debugobsolete --rev 5601fb93a350 --hidden --exclusive
309 $ hg debugobsolete --rev 5601fb93a350 --hidden --exclusive
310 $ hg debugobsolete --rev 5601fb93a350+6f9641995072 --hidden --exclusive
310 $ hg debugobsolete --rev 5601fb93a350+6f9641995072 --hidden --exclusive
311 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
311 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
312 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
312 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
313 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
313 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
314
314
315 $ cd ..
315 $ cd ..
316
316
317 Revision 0 is hidden
317 Revision 0 is hidden
318 --------------------
318 --------------------
319
319
320 $ hg init rev0hidden
320 $ hg init rev0hidden
321 $ cd rev0hidden
321 $ cd rev0hidden
322
322
323 $ mkcommit kill0
323 $ mkcommit kill0
324 $ hg up -q null
324 $ hg up -q null
325 $ hg debugobsolete `getid kill0`
325 $ hg debugobsolete `getid kill0`
326 obsoleted 1 changesets
326 obsoleted 1 changesets
327 $ mkcommit a
327 $ mkcommit a
328 $ mkcommit b
328 $ mkcommit b
329
329
330 Should pick the first visible revision as "repo" node
330 Should pick the first visible revision as "repo" node
331
331
332 $ hg archive ../archive-null
332 $ hg archive ../archive-null
333 $ cat ../archive-null/.hg_archival.txt
333 $ cat ../archive-null/.hg_archival.txt
334 repo: 1f0dee641bb7258c56bd60e93edfa2405381c41e
334 repo: 1f0dee641bb7258c56bd60e93edfa2405381c41e
335 node: 7c3bad9141dcb46ff89abf5f61856facd56e476c
335 node: 7c3bad9141dcb46ff89abf5f61856facd56e476c
336 branch: default
336 branch: default
337 latesttag: null
337 latesttag: null
338 latesttagdistance: 2
338 latesttagdistance: 2
339 changessincelatesttag: 2
339 changessincelatesttag: 2
340
340
341
341
342 $ cd ..
342 $ cd ..
343
343
344 Can disable transaction summary report
344 Can disable transaction summary report
345
345
346 $ hg init transaction-summary
346 $ hg init transaction-summary
347 $ cd transaction-summary
347 $ cd transaction-summary
348 $ mkcommit a
348 $ mkcommit a
349 $ mkcommit b
349 $ mkcommit b
350 $ hg up -q null
350 $ hg up -q null
351 $ hg --config experimental.evolution.report-instabilities=false debugobsolete `getid a`
351 $ hg --config experimental.evolution.report-instabilities=false debugobsolete `getid a`
352 obsoleted 1 changesets
352 obsoleted 1 changesets
353 $ cd ..
353 $ cd ..
354
354
355 Exchange Test
355 Exchange Test
356 ============================
356 ============================
357
357
358 Destination repo does not have any data
358 Destination repo does not have any data
359 ---------------------------------------
359 ---------------------------------------
360
360
361 Simple incoming test
361 Simple incoming test
362
362
363 $ hg init tmpc
363 $ hg init tmpc
364 $ cd tmpc
364 $ cd tmpc
365 $ hg incoming ../tmpb
365 $ hg incoming ../tmpb
366 comparing with ../tmpb
366 comparing with ../tmpb
367 0:1f0dee641bb7 (public) [ ] add a
367 0:1f0dee641bb7 (public) [ ] add a
368 1:7c3bad9141dc (public) [ ] add b
368 1:7c3bad9141dc (public) [ ] add b
369 2:245bde4270cd (public) [ ] add original_c
369 2:245bde4270cd (public) [ ] add original_c
370 6:6f9641995072 (draft) [tip ] add n3w_3_c
370 6:6f9641995072 (draft) [tip ] add n3w_3_c
371
371
372 Try to pull markers
372 Try to pull markers
373 (extinct changeset are excluded but marker are pushed)
373 (extinct changeset are excluded but marker are pushed)
374
374
375 $ hg pull ../tmpb
375 $ hg pull ../tmpb
376 pulling from ../tmpb
376 pulling from ../tmpb
377 requesting all changes
377 requesting all changes
378 adding changesets
378 adding changesets
379 adding manifests
379 adding manifests
380 adding file changes
380 adding file changes
381 added 4 changesets with 4 changes to 4 files (+1 heads)
381 added 4 changesets with 4 changes to 4 files (+1 heads)
382 5 new obsolescence markers
382 5 new obsolescence markers
383 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
383 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
384 (run 'hg heads' to see heads, 'hg merge' to merge)
384 (run 'hg heads' to see heads, 'hg merge' to merge)
385 $ hg debugobsolete
385 $ hg debugobsolete
386 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
386 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
387 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
387 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
388 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
388 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
389 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
389 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
390 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
390 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
391
391
392 Rollback//Transaction support
392 Rollback//Transaction support
393
393
394 $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
394 $ hg debugobsolete -d '1340 0' aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
395 $ hg debugobsolete
395 $ hg debugobsolete
396 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
396 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
397 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
397 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
398 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
398 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
399 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
399 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
400 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
400 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
401 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 (Thu Jan 01 00:22:20 1970 +0000) {'user': 'test'}
401 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 0 (Thu Jan 01 00:22:20 1970 +0000) {'user': 'test'}
402 $ hg rollback -n
402 $ hg rollback -n
403 repository tip rolled back to revision 3 (undo debugobsolete)
403 repository tip rolled back to revision 3 (undo debugobsolete)
404 $ hg rollback
404 $ hg rollback
405 repository tip rolled back to revision 3 (undo debugobsolete)
405 repository tip rolled back to revision 3 (undo debugobsolete)
406 $ hg debugobsolete
406 $ hg debugobsolete
407 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
407 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
408 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
408 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
409 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
409 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
410 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
410 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
411 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
411 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
412
412
413 $ cd ..
413 $ cd ..
414
414
415 Try to push markers
415 Try to push markers
416
416
417 $ hg init tmpd
417 $ hg init tmpd
418 $ hg -R tmpb push tmpd
418 $ hg -R tmpb push tmpd
419 pushing to tmpd
419 pushing to tmpd
420 searching for changes
420 searching for changes
421 adding changesets
421 adding changesets
422 adding manifests
422 adding manifests
423 adding file changes
423 adding file changes
424 added 4 changesets with 4 changes to 4 files (+1 heads)
424 added 4 changesets with 4 changes to 4 files (+1 heads)
425 5 new obsolescence markers
425 5 new obsolescence markers
426 $ hg -R tmpd debugobsolete | sort
426 $ hg -R tmpd debugobsolete | sort
427 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
427 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
428 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
428 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
429 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
429 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
430 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
430 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
431 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
431 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
432
432
433 Check obsolete keys are exchanged only if source has an obsolete store
433 Check obsolete keys are exchanged only if source has an obsolete store
434
434
435 $ hg init empty
435 $ hg init empty
436 $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
436 $ hg --config extensions.debugkeys=debugkeys.py -R empty push tmpd
437 pushing to tmpd
437 pushing to tmpd
438 listkeys phases
438 listkeys phases
439 listkeys bookmarks
439 listkeys bookmarks
440 no changes found
440 no changes found
441 listkeys phases
441 listkeys phases
442 [1]
442 [1]
443
443
444 clone support
444 clone support
445 (markers are copied and extinct changesets are included to allow hardlinks)
445 (markers are copied and extinct changesets are included to allow hardlinks)
446
446
447 $ hg clone tmpb clone-dest
447 $ hg clone tmpb clone-dest
448 updating to branch default
448 updating to branch default
449 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
449 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
450 $ hg -R clone-dest log -G --hidden
450 $ hg -R clone-dest log -G --hidden
451 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
451 @ 6:6f9641995072 (draft) [tip ] add n3w_3_c
452 |
452 |
453 | x 5:5601fb93a350 (draft *obsolete*) [ ] add new_3_c [rewritten as 6:6f9641995072]
453 | x 5:5601fb93a350 (draft *obsolete*) [ ] add new_3_c [rewritten as 6:6f9641995072]
454 |/
454 |/
455 | x 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
455 | x 4:ca819180edb9 (draft *obsolete*) [ ] add new_2_c [rewritten as 5:5601fb93a350]
456 |/
456 |/
457 | x 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
457 | x 3:cdbce2fbb163 (draft *obsolete*) [ ] add new_c [rewritten as 4:ca819180edb9]
458 |/
458 |/
459 | o 2:245bde4270cd (public) [ ] add original_c
459 | o 2:245bde4270cd (public) [ ] add original_c
460 |/
460 |/
461 o 1:7c3bad9141dc (public) [ ] add b
461 o 1:7c3bad9141dc (public) [ ] add b
462 |
462 |
463 o 0:1f0dee641bb7 (public) [ ] add a
463 o 0:1f0dee641bb7 (public) [ ] add a
464
464
465 $ hg -R clone-dest debugobsolete
465 $ hg -R clone-dest debugobsolete
466 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
466 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
467 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
467 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
468 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
468 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
469 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
469 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
470 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
470 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
471
471
472
472
473 Destination repo have existing data
473 Destination repo have existing data
474 ---------------------------------------
474 ---------------------------------------
475
475
476 On pull
476 On pull
477
477
478 $ hg init tmpe
478 $ hg init tmpe
479 $ cd tmpe
479 $ cd tmpe
480 $ hg debugobsolete -d '1339 0' 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00
480 $ hg debugobsolete -d '1339 0' 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00
481 $ hg pull ../tmpb
481 $ hg pull ../tmpb
482 pulling from ../tmpb
482 pulling from ../tmpb
483 requesting all changes
483 requesting all changes
484 adding changesets
484 adding changesets
485 adding manifests
485 adding manifests
486 adding file changes
486 adding file changes
487 added 4 changesets with 4 changes to 4 files (+1 heads)
487 added 4 changesets with 4 changes to 4 files (+1 heads)
488 5 new obsolescence markers
488 5 new obsolescence markers
489 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
489 new changesets 1f0dee641bb7:6f9641995072 (1 drafts)
490 (run 'hg heads' to see heads, 'hg merge' to merge)
490 (run 'hg heads' to see heads, 'hg merge' to merge)
491 $ hg debugobsolete
491 $ hg debugobsolete
492 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
492 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
493 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
493 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
494 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
494 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
495 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
495 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
496 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
496 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
497 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
497 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
498
498
499
499
500 On push
500 On push
501
501
502 $ hg push ../tmpc
502 $ hg push ../tmpc
503 pushing to ../tmpc
503 pushing to ../tmpc
504 searching for changes
504 searching for changes
505 no changes found
505 no changes found
506 1 new obsolescence markers
506 1 new obsolescence markers
507 [1]
507 [1]
508 $ hg -R ../tmpc debugobsolete
508 $ hg -R ../tmpc debugobsolete
509 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
509 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
510 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
510 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
511 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
511 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
512 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
512 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
513 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
513 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
514 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
514 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
515
515
516 detect outgoing obsolete and unstable
516 detect outgoing obsolete and unstable
517 ---------------------------------------
517 ---------------------------------------
518
518
519
519
520 $ hg log -G
520 $ hg log -G
521 o 3:6f9641995072 (draft) [tip ] add n3w_3_c
521 o 3:6f9641995072 (draft) [tip ] add n3w_3_c
522 |
522 |
523 | o 2:245bde4270cd (public) [ ] add original_c
523 | o 2:245bde4270cd (public) [ ] add original_c
524 |/
524 |/
525 o 1:7c3bad9141dc (public) [ ] add b
525 o 1:7c3bad9141dc (public) [ ] add b
526 |
526 |
527 o 0:1f0dee641bb7 (public) [ ] add a
527 o 0:1f0dee641bb7 (public) [ ] add a
528
528
529 $ hg up 'desc("n3w_3_c")'
529 $ hg up 'desc("n3w_3_c")'
530 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
530 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
531 $ mkcommit original_d
531 $ mkcommit original_d
532 $ mkcommit original_e
532 $ mkcommit original_e
533 $ hg debugobsolete --record-parents `getid original_d` -d '0 0'
533 $ hg debugobsolete --record-parents `getid original_d` -d '0 0'
534 obsoleted 1 changesets
534 obsoleted 1 changesets
535 1 new orphan changesets
535 1 new orphan changesets
536 $ hg debugobsolete | grep `getid original_d`
536 $ hg debugobsolete | grep `getid original_d`
537 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
537 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
538 $ hg log -r 'obsolete()'
538 $ hg log -r 'obsolete()'
539 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
539 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
540 $ hg summary
540 $ hg summary
541 parent: 5:cda648ca50f5 tip (orphan)
541 parent: 5:cda648ca50f5 tip (orphan)
542 add original_e
542 add original_e
543 branch: default
543 branch: default
544 commit: (clean)
544 commit: (clean)
545 update: 1 new changesets, 2 branch heads (merge)
545 update: 1 new changesets, 2 branch heads (merge)
546 phases: 3 draft
546 phases: 3 draft
547 orphan: 1 changesets
547 orphan: 1 changesets
548 $ hg log -G -r '::orphan()'
548 $ hg log -G -r '::orphan()'
549 @ 5:cda648ca50f5 (draft orphan) [tip ] add original_e
549 @ 5:cda648ca50f5 (draft orphan) [tip ] add original_e
550 |
550 |
551 x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
551 x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
552 |
552 |
553 o 3:6f9641995072 (draft) [ ] add n3w_3_c
553 o 3:6f9641995072 (draft) [ ] add n3w_3_c
554 |
554 |
555 o 1:7c3bad9141dc (public) [ ] add b
555 o 1:7c3bad9141dc (public) [ ] add b
556 |
556 |
557 o 0:1f0dee641bb7 (public) [ ] add a
557 o 0:1f0dee641bb7 (public) [ ] add a
558
558
559
559
560 refuse to push obsolete changeset
560 refuse to push obsolete changeset
561
561
562 $ hg push ../tmpc/ -r 'desc("original_d")'
562 $ hg push ../tmpc/ -r 'desc("original_d")'
563 pushing to ../tmpc/
563 pushing to ../tmpc/
564 searching for changes
564 searching for changes
565 abort: push includes obsolete changeset: 94b33453f93b!
565 abort: push includes obsolete changeset: 94b33453f93b!
566 [255]
566 [255]
567
567
568 refuse to push unstable changeset
568 refuse to push unstable changeset
569
569
570 $ hg push ../tmpc/
570 $ hg push ../tmpc/
571 pushing to ../tmpc/
571 pushing to ../tmpc/
572 searching for changes
572 searching for changes
573 abort: push includes orphan changeset: cda648ca50f5!
573 abort: push includes orphan changeset: cda648ca50f5!
574 [255]
574 [255]
575
575
576 Test that extinct changeset are properly detected
576 Test that extinct changeset are properly detected
577
577
578 $ hg log -r 'extinct()'
578 $ hg log -r 'extinct()'
579
579
580 Don't try to push extinct changeset
580 Don't try to push extinct changeset
581
581
582 $ hg init ../tmpf
582 $ hg init ../tmpf
583 $ hg out ../tmpf
583 $ hg out ../tmpf
584 comparing with ../tmpf
584 comparing with ../tmpf
585 searching for changes
585 searching for changes
586 0:1f0dee641bb7 (public) [ ] add a
586 0:1f0dee641bb7 (public) [ ] add a
587 1:7c3bad9141dc (public) [ ] add b
587 1:7c3bad9141dc (public) [ ] add b
588 2:245bde4270cd (public) [ ] add original_c
588 2:245bde4270cd (public) [ ] add original_c
589 3:6f9641995072 (draft) [ ] add n3w_3_c
589 3:6f9641995072 (draft) [ ] add n3w_3_c
590 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
590 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
591 5:cda648ca50f5 (draft orphan) [tip ] add original_e
591 5:cda648ca50f5 (draft orphan) [tip ] add original_e
592 $ hg push ../tmpf -f # -f because be push unstable too
592 $ hg push ../tmpf -f # -f because be push unstable too
593 pushing to ../tmpf
593 pushing to ../tmpf
594 searching for changes
594 searching for changes
595 adding changesets
595 adding changesets
596 adding manifests
596 adding manifests
597 adding file changes
597 adding file changes
598 added 6 changesets with 6 changes to 6 files (+1 heads)
598 added 6 changesets with 6 changes to 6 files (+1 heads)
599 7 new obsolescence markers
599 7 new obsolescence markers
600 1 new orphan changesets
600 1 new orphan changesets
601
601
602 no warning displayed
602 no warning displayed
603
603
604 $ hg push ../tmpf
604 $ hg push ../tmpf
605 pushing to ../tmpf
605 pushing to ../tmpf
606 searching for changes
606 searching for changes
607 no changes found
607 no changes found
608 [1]
608 [1]
609
609
610 Do not warn about new head when the new head is a successors of a remote one
610 Do not warn about new head when the new head is a successors of a remote one
611
611
612 $ hg log -G
612 $ hg log -G
613 @ 5:cda648ca50f5 (draft orphan) [tip ] add original_e
613 @ 5:cda648ca50f5 (draft orphan) [tip ] add original_e
614 |
614 |
615 x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
615 x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
616 |
616 |
617 o 3:6f9641995072 (draft) [ ] add n3w_3_c
617 o 3:6f9641995072 (draft) [ ] add n3w_3_c
618 |
618 |
619 | o 2:245bde4270cd (public) [ ] add original_c
619 | o 2:245bde4270cd (public) [ ] add original_c
620 |/
620 |/
621 o 1:7c3bad9141dc (public) [ ] add b
621 o 1:7c3bad9141dc (public) [ ] add b
622 |
622 |
623 o 0:1f0dee641bb7 (public) [ ] add a
623 o 0:1f0dee641bb7 (public) [ ] add a
624
624
625 $ hg up -q 'desc(n3w_3_c)'
625 $ hg up -q 'desc(n3w_3_c)'
626 $ mkcommit obsolete_e
626 $ mkcommit obsolete_e
627 created new head
627 created new head
628 $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'` \
628 $ hg debugobsolete `getid 'original_e'` `getid 'obsolete_e'` \
629 > -u 'test <test@example.net>'
629 > -u 'test <test@example.net>'
630 obsoleted 1 changesets
630 obsoleted 1 changesets
631 $ hg outgoing ../tmpf # parasite hg outgoing testin
631 $ hg outgoing ../tmpf # parasite hg outgoing testin
632 comparing with ../tmpf
632 comparing with ../tmpf
633 searching for changes
633 searching for changes
634 6:3de5eca88c00 (draft) [tip ] add obsolete_e
634 6:3de5eca88c00 (draft) [tip ] add obsolete_e
635 $ hg push ../tmpf
635 $ hg push ../tmpf
636 pushing to ../tmpf
636 pushing to ../tmpf
637 searching for changes
637 searching for changes
638 adding changesets
638 adding changesets
639 adding manifests
639 adding manifests
640 adding file changes
640 adding file changes
641 added 1 changesets with 1 changes to 1 files (+1 heads)
641 added 1 changesets with 1 changes to 1 files (+1 heads)
642 1 new obsolescence markers
642 1 new obsolescence markers
643 obsoleted 1 changesets
643 obsoleted 1 changesets
644
644
645 test relevance computation
645 test relevance computation
646 ---------------------------------------
646 ---------------------------------------
647
647
648 Checking simple case of "marker relevance".
648 Checking simple case of "marker relevance".
649
649
650
650
651 Reminder of the repo situation
651 Reminder of the repo situation
652
652
653 $ hg log --hidden --graph
653 $ hg log --hidden --graph
654 @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e
654 @ 6:3de5eca88c00 (draft) [tip ] add obsolete_e
655 |
655 |
656 | x 5:cda648ca50f5 (draft *obsolete*) [ ] add original_e [rewritten as 6:3de5eca88c00 by test <test@example.net>]
656 | x 5:cda648ca50f5 (draft *obsolete*) [ ] add original_e [rewritten as 6:3de5eca88c00 by test <test@example.net>]
657 | |
657 | |
658 | x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
658 | x 4:94b33453f93b (draft *obsolete*) [ ] add original_d [pruned]
659 |/
659 |/
660 o 3:6f9641995072 (draft) [ ] add n3w_3_c
660 o 3:6f9641995072 (draft) [ ] add n3w_3_c
661 |
661 |
662 | o 2:245bde4270cd (public) [ ] add original_c
662 | o 2:245bde4270cd (public) [ ] add original_c
663 |/
663 |/
664 o 1:7c3bad9141dc (public) [ ] add b
664 o 1:7c3bad9141dc (public) [ ] add b
665 |
665 |
666 o 0:1f0dee641bb7 (public) [ ] add a
666 o 0:1f0dee641bb7 (public) [ ] add a
667
667
668
668
669 List of all markers
669 List of all markers
670
670
671 $ hg debugobsolete
671 $ hg debugobsolete
672 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
672 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
673 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
673 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
674 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
674 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
675 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
675 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
676 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
676 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
677 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
677 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
678 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
678 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
679 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
679 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
680
680
681 List of changesets with no chain
681 List of changesets with no chain
682
682
683 $ hg debugobsolete --hidden --rev ::2
683 $ hg debugobsolete --hidden --rev ::2
684
684
685 List of changesets that are included on marker chain
685 List of changesets that are included on marker chain
686
686
687 $ hg debugobsolete --hidden --rev 6
687 $ hg debugobsolete --hidden --rev 6
688 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
688 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
689
689
690 List of changesets with a longer chain, (including a pruned children)
690 List of changesets with a longer chain, (including a pruned children)
691
691
692 $ hg debugobsolete --hidden --rev 3
692 $ hg debugobsolete --hidden --rev 3
693 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
693 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
694 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
694 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
695 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
695 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
696 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
696 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
697 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
697 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
698 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
698 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
699 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
699 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
700
700
701 List of both
701 List of both
702
702
703 $ hg debugobsolete --hidden --rev 3::6
703 $ hg debugobsolete --hidden --rev 3::6
704 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
704 1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
705 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
705 1339133913391339133913391339133913391339 ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:19 1970 +0000) {'user': 'test'}
706 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
706 245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f C (Thu Jan 01 00:00:01 1970 -0002) {'user': 'test'}
707 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
707 5601fb93a350734d935195fee37f4054c529ff39 6f96419950729f3671185b847352890f074f7557 1 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
708 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
708 94b33453f93bdb8d457ef9b770851a618bf413e1 0 {6f96419950729f3671185b847352890f074f7557} (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
709 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
709 ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 (Thu Jan 01 00:22:18 1970 +0000) {'user': 'test'}
710 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
710 cda648ca50f50482b7055c0b0c4c117bba6733d9 3de5eca88c00aa039da7399a220f4a5221faa585 0 (*) {'user': 'test <test@example.net>'} (glob)
711 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
711 cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 (Thu Jan 01 00:22:17 1970 +0000) {'user': 'test'}
712
712
713 List of all markers in JSON
713 List of all markers in JSON
714
714
715 $ hg debugobsolete -Tjson
715 $ hg debugobsolete -Tjson
716 [
716 [
717 {
717 {
718 "date": [1339, 0],
718 "date": [1339, 0],
719 "flag": 0,
719 "flag": 0,
720 "metadata": {"user": "test"},
720 "metadata": {"user": "test"},
721 "prednode": "1339133913391339133913391339133913391339",
721 "prednode": "1339133913391339133913391339133913391339",
722 "succnodes": ["ca819180edb99ed25ceafb3e9584ac287e240b00"]
722 "succnodes": ["ca819180edb99ed25ceafb3e9584ac287e240b00"]
723 },
723 },
724 {
724 {
725 "date": [1339, 0],
725 "date": [1339, 0],
726 "flag": 0,
726 "flag": 0,
727 "metadata": {"user": "test"},
727 "metadata": {"user": "test"},
728 "prednode": "1337133713371337133713371337133713371337",
728 "prednode": "1337133713371337133713371337133713371337",
729 "succnodes": ["5601fb93a350734d935195fee37f4054c529ff39"]
729 "succnodes": ["5601fb93a350734d935195fee37f4054c529ff39"]
730 },
730 },
731 {
731 {
732 "date": [121, 120],
732 "date": [121, 120],
733 "flag": 12,
733 "flag": 12,
734 "metadata": {"user": "test"},
734 "metadata": {"user": "test"},
735 "prednode": "245bde4270cd1072a27757984f9cda8ba26f08ca",
735 "prednode": "245bde4270cd1072a27757984f9cda8ba26f08ca",
736 "succnodes": ["cdbce2fbb16313928851e97e0d85413f3f7eb77f"]
736 "succnodes": ["cdbce2fbb16313928851e97e0d85413f3f7eb77f"]
737 },
737 },
738 {
738 {
739 "date": [1338, 0],
739 "date": [1338, 0],
740 "flag": 1,
740 "flag": 1,
741 "metadata": {"user": "test"},
741 "metadata": {"user": "test"},
742 "prednode": "5601fb93a350734d935195fee37f4054c529ff39",
742 "prednode": "5601fb93a350734d935195fee37f4054c529ff39",
743 "succnodes": ["6f96419950729f3671185b847352890f074f7557"]
743 "succnodes": ["6f96419950729f3671185b847352890f074f7557"]
744 },
744 },
745 {
745 {
746 "date": [1338, 0],
746 "date": [1338, 0],
747 "flag": 0,
747 "flag": 0,
748 "metadata": {"user": "test"},
748 "metadata": {"user": "test"},
749 "prednode": "ca819180edb99ed25ceafb3e9584ac287e240b00",
749 "prednode": "ca819180edb99ed25ceafb3e9584ac287e240b00",
750 "succnodes": ["1337133713371337133713371337133713371337"]
750 "succnodes": ["1337133713371337133713371337133713371337"]
751 },
751 },
752 {
752 {
753 "date": [1337, 0],
753 "date": [1337, 0],
754 "flag": 0,
754 "flag": 0,
755 "metadata": {"user": "test"},
755 "metadata": {"user": "test"},
756 "prednode": "cdbce2fbb16313928851e97e0d85413f3f7eb77f",
756 "prednode": "cdbce2fbb16313928851e97e0d85413f3f7eb77f",
757 "succnodes": ["ca819180edb99ed25ceafb3e9584ac287e240b00"]
757 "succnodes": ["ca819180edb99ed25ceafb3e9584ac287e240b00"]
758 },
758 },
759 {
759 {
760 "date": [0, 0],
760 "date": [0, 0],
761 "flag": 0,
761 "flag": 0,
762 "metadata": {"user": "test"},
762 "metadata": {"user": "test"},
763 "parentnodes": ["6f96419950729f3671185b847352890f074f7557"],
763 "parentnodes": ["6f96419950729f3671185b847352890f074f7557"],
764 "prednode": "94b33453f93bdb8d457ef9b770851a618bf413e1",
764 "prednode": "94b33453f93bdb8d457ef9b770851a618bf413e1",
765 "succnodes": []
765 "succnodes": []
766 },
766 },
767 {
767 {
768 "date": *, (glob)
768 "date": *, (glob)
769 "flag": 0,
769 "flag": 0,
770 "metadata": {"user": "test <test@example.net>"},
770 "metadata": {"user": "test <test@example.net>"},
771 "prednode": "cda648ca50f50482b7055c0b0c4c117bba6733d9",
771 "prednode": "cda648ca50f50482b7055c0b0c4c117bba6733d9",
772 "succnodes": ["3de5eca88c00aa039da7399a220f4a5221faa585"]
772 "succnodes": ["3de5eca88c00aa039da7399a220f4a5221faa585"]
773 }
773 }
774 ]
774 ]
775
775
776 Template keywords
776 Template keywords
777
777
778 $ hg debugobsolete -r6 -T '{succnodes % "{node|short}"} {date|shortdate}\n'
778 $ hg debugobsolete -r6 -T '{succnodes % "{node|short}"} {date|shortdate}\n'
779 3de5eca88c00 ????-??-?? (glob)
779 3de5eca88c00 ????-??-?? (glob)
780 $ hg debugobsolete -r6 -T '{join(metadata % "{key}={value}", " ")}\n'
780 $ hg debugobsolete -r6 -T '{join(metadata % "{key}={value}", " ")}\n'
781 user=test <test@example.net>
781 user=test <test@example.net>
782 $ hg debugobsolete -r6 -T '{metadata}\n{metadata}\n'
782 $ hg debugobsolete -r6 -T '{metadata}\n{metadata}\n'
783 'user': 'test <test@example.net>'
783 'user': 'test <test@example.net>'
784 'user': 'test <test@example.net>'
784 'user': 'test <test@example.net>'
785 $ hg debugobsolete -r6 -T '{succnodes}\n{succnodes}\n'
785 $ hg debugobsolete -r6 -T '{succnodes}\n{succnodes}\n'
786 3de5eca88c00aa039da7399a220f4a5221faa585
786 3de5eca88c00aa039da7399a220f4a5221faa585
787 3de5eca88c00aa039da7399a220f4a5221faa585
787 3de5eca88c00aa039da7399a220f4a5221faa585
788 $ hg debugobsolete -r6 -T '{flag} {get(metadata, "user")}\n'
788 $ hg debugobsolete -r6 -T '{flag} {get(metadata, "user")}\n'
789 0 test <test@example.net>
789 0 test <test@example.net>
790
790
791 Test the debug output for exchange
791 Test the debug output for exchange
792 ----------------------------------
792 ----------------------------------
793
793
794 $ hg pull ../tmpb --config 'experimental.obsmarkers-exchange-debug=True' # bundle2
794 $ hg pull ../tmpb --config 'experimental.obsmarkers-exchange-debug=True' # bundle2
795 pulling from ../tmpb
795 pulling from ../tmpb
796 searching for changes
796 searching for changes
797 no changes found
797 no changes found
798 obsmarker-exchange: 346 bytes received
798 obsmarker-exchange: 346 bytes received
799
799
800 check hgweb does not explode
800 check hgweb does not explode
801 ====================================
801 ====================================
802
802
803 $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg
803 $ hg unbundle $TESTDIR/bundles/hgweb+obs.hg
804 adding changesets
804 adding changesets
805 adding manifests
805 adding manifests
806 adding file changes
806 adding file changes
807 added 62 changesets with 63 changes to 9 files (+60 heads)
807 added 62 changesets with 63 changes to 9 files (+60 heads)
808 new changesets 50c51b361e60:c15e9edfca13 (62 drafts)
808 new changesets 50c51b361e60:c15e9edfca13 (62 drafts)
809 (2 other changesets obsolete on arrival)
809 (run 'hg heads .' to see heads, 'hg merge' to merge)
810 (run 'hg heads .' to see heads, 'hg merge' to merge)
810 $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`;
811 $ for node in `hg log -r 'desc(babar_)' --template '{node}\n'`;
811 > do
812 > do
812 > hg debugobsolete $node
813 > hg debugobsolete $node
813 > done
814 > done
814 obsoleted 1 changesets
815 obsoleted 1 changesets
815 obsoleted 1 changesets
816 obsoleted 1 changesets
816 obsoleted 1 changesets
817 obsoleted 1 changesets
817 obsoleted 1 changesets
818 obsoleted 1 changesets
818 obsoleted 1 changesets
819 obsoleted 1 changesets
819 obsoleted 1 changesets
820 obsoleted 1 changesets
820 obsoleted 1 changesets
821 obsoleted 1 changesets
821 obsoleted 1 changesets
822 obsoleted 1 changesets
822 obsoleted 1 changesets
823 obsoleted 1 changesets
823 obsoleted 1 changesets
824 obsoleted 1 changesets
824 obsoleted 1 changesets
825 obsoleted 1 changesets
825 obsoleted 1 changesets
826 obsoleted 1 changesets
826 obsoleted 1 changesets
827 obsoleted 1 changesets
827 obsoleted 1 changesets
828 obsoleted 1 changesets
828 obsoleted 1 changesets
829 obsoleted 1 changesets
829 obsoleted 1 changesets
830 obsoleted 1 changesets
830 obsoleted 1 changesets
831 obsoleted 1 changesets
831 obsoleted 1 changesets
832 obsoleted 1 changesets
832 obsoleted 1 changesets
833 obsoleted 1 changesets
833 obsoleted 1 changesets
834 obsoleted 1 changesets
834 obsoleted 1 changesets
835 obsoleted 1 changesets
835 obsoleted 1 changesets
836 obsoleted 1 changesets
836 obsoleted 1 changesets
837 obsoleted 1 changesets
837 obsoleted 1 changesets
838 obsoleted 1 changesets
838 obsoleted 1 changesets
839 obsoleted 1 changesets
839 obsoleted 1 changesets
840 obsoleted 1 changesets
840 obsoleted 1 changesets
841 obsoleted 1 changesets
841 obsoleted 1 changesets
842 obsoleted 1 changesets
842 obsoleted 1 changesets
843 obsoleted 1 changesets
843 obsoleted 1 changesets
844 obsoleted 1 changesets
844 obsoleted 1 changesets
845 obsoleted 1 changesets
845 obsoleted 1 changesets
846 obsoleted 1 changesets
846 obsoleted 1 changesets
847 obsoleted 1 changesets
847 obsoleted 1 changesets
848 obsoleted 1 changesets
848 obsoleted 1 changesets
849 obsoleted 1 changesets
849 obsoleted 1 changesets
850 obsoleted 1 changesets
850 obsoleted 1 changesets
851 obsoleted 1 changesets
851 obsoleted 1 changesets
852 obsoleted 1 changesets
852 obsoleted 1 changesets
853 obsoleted 1 changesets
853 obsoleted 1 changesets
854 obsoleted 1 changesets
854 obsoleted 1 changesets
855 obsoleted 1 changesets
855 obsoleted 1 changesets
856 obsoleted 1 changesets
856 obsoleted 1 changesets
857 obsoleted 1 changesets
857 obsoleted 1 changesets
858 obsoleted 1 changesets
858 obsoleted 1 changesets
859 obsoleted 1 changesets
859 obsoleted 1 changesets
860 obsoleted 1 changesets
860 obsoleted 1 changesets
861 obsoleted 1 changesets
861 obsoleted 1 changesets
862 obsoleted 1 changesets
862 obsoleted 1 changesets
863 obsoleted 1 changesets
863 obsoleted 1 changesets
864 obsoleted 1 changesets
864 obsoleted 1 changesets
865 obsoleted 1 changesets
865 obsoleted 1 changesets
866 obsoleted 1 changesets
866 obsoleted 1 changesets
867 obsoleted 1 changesets
867 obsoleted 1 changesets
868 obsoleted 1 changesets
868 obsoleted 1 changesets
869 obsoleted 1 changesets
869 obsoleted 1 changesets
870 obsoleted 1 changesets
870 obsoleted 1 changesets
871 obsoleted 1 changesets
871 obsoleted 1 changesets
872 obsoleted 1 changesets
872 obsoleted 1 changesets
873 obsoleted 1 changesets
873 obsoleted 1 changesets
874 obsoleted 1 changesets
874 $ hg up tip
875 $ hg up tip
875 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
876 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
876
877
877 #if serve
878 #if serve
878
879
879 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
880 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
880 $ cat hg.pid >> $DAEMON_PIDS
881 $ cat hg.pid >> $DAEMON_PIDS
881
882
882 check changelog view
883 check changelog view
883
884
884 $ get-with-headers.py --headeronly localhost:$HGPORT 'shortlog/'
885 $ get-with-headers.py --headeronly localhost:$HGPORT 'shortlog/'
885 200 Script output follows
886 200 Script output follows
886
887
887 check graph view
888 check graph view
888
889
889 $ get-with-headers.py --headeronly localhost:$HGPORT 'graph'
890 $ get-with-headers.py --headeronly localhost:$HGPORT 'graph'
890 200 Script output follows
891 200 Script output follows
891
892
892 check filelog view
893 check filelog view
893
894
894 $ get-with-headers.py --headeronly localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar'
895 $ get-with-headers.py --headeronly localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar'
895 200 Script output follows
896 200 Script output follows
896
897
897 check filelog view for hidden commits (obsolete ones are hidden here)
898 check filelog view for hidden commits (obsolete ones are hidden here)
898
899
899 $ get-with-headers.py localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar' | grep obsolete
900 $ get-with-headers.py localhost:$HGPORT 'log/'`hg log -r . -T "{node}"`/'babar' | grep obsolete
900 [1]
901 [1]
901
902
902 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/68'
903 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/68'
903 200 Script output follows
904 200 Script output follows
904 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
905 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
905 404 Not Found
906 404 Not Found
906 [1]
907 [1]
907
908
908 check that web.view config option:
909 check that web.view config option:
909
910
910 $ killdaemons.py hg.pid
911 $ killdaemons.py hg.pid
911 $ cat >> .hg/hgrc << EOF
912 $ cat >> .hg/hgrc << EOF
912 > [web]
913 > [web]
913 > view=all
914 > view=all
914 > EOF
915 > EOF
915 $ wait
916 $ wait
916 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
917 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
917 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
918 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/67'
918 200 Script output follows
919 200 Script output follows
919 $ killdaemons.py hg.pid
920 $ killdaemons.py hg.pid
920
921
921 Checking _enable=False warning if obsolete marker exists
922 Checking _enable=False warning if obsolete marker exists
922
923
923 $ echo '[experimental]' >> $HGRCPATH
924 $ echo '[experimental]' >> $HGRCPATH
924 $ echo "evolution=" >> $HGRCPATH
925 $ echo "evolution=" >> $HGRCPATH
925 $ hg log -r tip
926 $ hg log -r tip
926 68:c15e9edfca13 (draft) [tip ] add celestine
927 68:c15e9edfca13 (draft) [tip ] add celestine
927
928
928 reenable for later test
929 reenable for later test
929
930
930 $ echo '[experimental]' >> $HGRCPATH
931 $ echo '[experimental]' >> $HGRCPATH
931 $ echo "evolution.exchange=True" >> $HGRCPATH
932 $ echo "evolution.exchange=True" >> $HGRCPATH
932 $ echo "evolution.createmarkers=True" >> $HGRCPATH
933 $ echo "evolution.createmarkers=True" >> $HGRCPATH
933
934
934 $ rm access.log errors.log
935 $ rm access.log errors.log
935 #endif
936 #endif
936
937
937 Several troubles on the same changeset (create an unstable and bumped changeset)
938 Several troubles on the same changeset (create an unstable and bumped changeset)
938
939
939 $ hg debugobsolete `getid obsolete_e`
940 $ hg debugobsolete `getid obsolete_e`
940 obsoleted 1 changesets
941 obsoleted 1 changesets
941 2 new orphan changesets
942 2 new orphan changesets
942 $ hg debugobsolete `getid original_c` `getid babar`
943 $ hg debugobsolete `getid original_c` `getid babar`
943 1 new phase-divergent changesets
944 1 new phase-divergent changesets
944 $ hg log --config ui.logtemplate= -r 'phasedivergent() and orphan()'
945 $ hg log --config ui.logtemplate= -r 'phasedivergent() and orphan()'
945 changeset: 7:50c51b361e60
946 changeset: 7:50c51b361e60
946 user: test
947 user: test
947 date: Thu Jan 01 00:00:00 1970 +0000
948 date: Thu Jan 01 00:00:00 1970 +0000
948 instability: orphan, phase-divergent
949 instability: orphan, phase-divergent
949 summary: add babar
950 summary: add babar
950
951
951
952
952 test the "obsolete" templatekw
953 test the "obsolete" templatekw
953
954
954 $ hg log -r 'obsolete()'
955 $ hg log -r 'obsolete()'
955 6:3de5eca88c00 (draft *obsolete*) [ ] add obsolete_e [pruned]
956 6:3de5eca88c00 (draft *obsolete*) [ ] add obsolete_e [pruned]
956
957
957 test the "troubles" templatekw
958 test the "troubles" templatekw
958
959
959 $ hg log -r 'phasedivergent() and orphan()'
960 $ hg log -r 'phasedivergent() and orphan()'
960 7:50c51b361e60 (draft orphan phase-divergent) [ ] add babar
961 7:50c51b361e60 (draft orphan phase-divergent) [ ] add babar
961
962
962 test the default cmdline template
963 test the default cmdline template
963
964
964 $ hg log -T default -r 'phasedivergent()'
965 $ hg log -T default -r 'phasedivergent()'
965 changeset: 7:50c51b361e60
966 changeset: 7:50c51b361e60
966 user: test
967 user: test
967 date: Thu Jan 01 00:00:00 1970 +0000
968 date: Thu Jan 01 00:00:00 1970 +0000
968 instability: orphan, phase-divergent
969 instability: orphan, phase-divergent
969 summary: add babar
970 summary: add babar
970
971
971 $ hg log -T default -r 'obsolete()'
972 $ hg log -T default -r 'obsolete()'
972 changeset: 6:3de5eca88c00
973 changeset: 6:3de5eca88c00
973 parent: 3:6f9641995072
974 parent: 3:6f9641995072
974 user: test
975 user: test
975 date: Thu Jan 01 00:00:00 1970 +0000
976 date: Thu Jan 01 00:00:00 1970 +0000
976 obsolete: pruned
977 obsolete: pruned
977 summary: add obsolete_e
978 summary: add obsolete_e
978
979
979
980
980 test the obsolete labels
981 test the obsolete labels
981
982
982 $ hg log --config ui.logtemplate= --color=debug -r 'phasedivergent()'
983 $ hg log --config ui.logtemplate= --color=debug -r 'phasedivergent()'
983 [log.changeset changeset.draft changeset.unstable instability.orphan instability.phase-divergent|changeset: 7:50c51b361e60]
984 [log.changeset changeset.draft changeset.unstable instability.orphan instability.phase-divergent|changeset: 7:50c51b361e60]
984 [log.user|user: test]
985 [log.user|user: test]
985 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
986 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
986 [log.instability|instability: orphan, phase-divergent]
987 [log.instability|instability: orphan, phase-divergent]
987 [log.summary|summary: add babar]
988 [log.summary|summary: add babar]
988
989
989
990
990 $ hg log -T default -r 'phasedivergent()' --color=debug
991 $ hg log -T default -r 'phasedivergent()' --color=debug
991 [log.changeset changeset.draft changeset.unstable instability.orphan instability.phase-divergent|changeset: 7:50c51b361e60]
992 [log.changeset changeset.draft changeset.unstable instability.orphan instability.phase-divergent|changeset: 7:50c51b361e60]
992 [log.user|user: test]
993 [log.user|user: test]
993 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
994 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
994 [log.instability|instability: orphan, phase-divergent]
995 [log.instability|instability: orphan, phase-divergent]
995 [log.summary|summary: add babar]
996 [log.summary|summary: add babar]
996
997
997
998
998 $ hg log --config ui.logtemplate= --color=debug -r "obsolete()"
999 $ hg log --config ui.logtemplate= --color=debug -r "obsolete()"
999 [log.changeset changeset.draft changeset.obsolete|changeset: 6:3de5eca88c00]
1000 [log.changeset changeset.draft changeset.obsolete|changeset: 6:3de5eca88c00]
1000 [log.parent changeset.draft|parent: 3:6f9641995072]
1001 [log.parent changeset.draft|parent: 3:6f9641995072]
1001 [log.user|user: test]
1002 [log.user|user: test]
1002 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1003 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1003 [log.obsfate|obsolete: pruned]
1004 [log.obsfate|obsolete: pruned]
1004 [log.summary|summary: add obsolete_e]
1005 [log.summary|summary: add obsolete_e]
1005
1006
1006
1007
1007 $ hg log -T default -r 'obsolete()' --color=debug
1008 $ hg log -T default -r 'obsolete()' --color=debug
1008 [log.changeset changeset.draft changeset.obsolete|changeset: 6:3de5eca88c00]
1009 [log.changeset changeset.draft changeset.obsolete|changeset: 6:3de5eca88c00]
1009 [log.parent changeset.draft|parent: 3:6f9641995072]
1010 [log.parent changeset.draft|parent: 3:6f9641995072]
1010 [log.user|user: test]
1011 [log.user|user: test]
1011 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1012 [log.date|date: Thu Jan 01 00:00:00 1970 +0000]
1012 [log.obsfate|obsolete: pruned]
1013 [log.obsfate|obsolete: pruned]
1013 [log.summary|summary: add obsolete_e]
1014 [log.summary|summary: add obsolete_e]
1014
1015
1015
1016
1016 test summary output
1017 test summary output
1017
1018
1018 $ hg up -r 'phasedivergent() and orphan()'
1019 $ hg up -r 'phasedivergent() and orphan()'
1019 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1020 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1020 $ hg summary
1021 $ hg summary
1021 parent: 7:50c51b361e60 (orphan, phase-divergent)
1022 parent: 7:50c51b361e60 (orphan, phase-divergent)
1022 add babar
1023 add babar
1023 branch: default
1024 branch: default
1024 commit: (clean)
1025 commit: (clean)
1025 update: 2 new changesets (update)
1026 update: 2 new changesets (update)
1026 phases: 4 draft
1027 phases: 4 draft
1027 orphan: 2 changesets
1028 orphan: 2 changesets
1028 phase-divergent: 1 changesets
1029 phase-divergent: 1 changesets
1029 $ hg up -r 'obsolete()'
1030 $ hg up -r 'obsolete()'
1030 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1031 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1031 $ hg summary
1032 $ hg summary
1032 parent: 6:3de5eca88c00 (obsolete)
1033 parent: 6:3de5eca88c00 (obsolete)
1033 add obsolete_e
1034 add obsolete_e
1034 branch: default
1035 branch: default
1035 commit: (clean)
1036 commit: (clean)
1036 update: 3 new changesets (update)
1037 update: 3 new changesets (update)
1037 phases: 4 draft
1038 phases: 4 draft
1038 orphan: 2 changesets
1039 orphan: 2 changesets
1039 phase-divergent: 1 changesets
1040 phase-divergent: 1 changesets
1040
1041
1041 test debugwhyunstable output
1042 test debugwhyunstable output
1042
1043
1043 $ hg debugwhyunstable 50c51b361e60
1044 $ hg debugwhyunstable 50c51b361e60
1044 orphan: obsolete parent 3de5eca88c00aa039da7399a220f4a5221faa585
1045 orphan: obsolete parent 3de5eca88c00aa039da7399a220f4a5221faa585
1045 phase-divergent: immutable predecessor 245bde4270cd1072a27757984f9cda8ba26f08ca
1046 phase-divergent: immutable predecessor 245bde4270cd1072a27757984f9cda8ba26f08ca
1046
1047
1047 test whyunstable template keyword
1048 test whyunstable template keyword
1048
1049
1049 $ hg log -r 50c51b361e60 -T '{whyunstable}\n'
1050 $ hg log -r 50c51b361e60 -T '{whyunstable}\n'
1050 orphan: obsolete parent 3de5eca88c00
1051 orphan: obsolete parent 3de5eca88c00
1051 phase-divergent: immutable predecessor 245bde4270cd
1052 phase-divergent: immutable predecessor 245bde4270cd
1052 $ hg log -r 50c51b361e60 -T '{whyunstable % "{instability}: {reason} {node|shortest}\n"}'
1053 $ hg log -r 50c51b361e60 -T '{whyunstable % "{instability}: {reason} {node|shortest}\n"}'
1053 orphan: obsolete parent 3de5
1054 orphan: obsolete parent 3de5
1054 phase-divergent: immutable predecessor 245b
1055 phase-divergent: immutable predecessor 245b
1055
1056
1056 #if serve
1057 #if serve
1057
1058
1058 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1059 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1059 $ cat hg.pid >> $DAEMON_PIDS
1060 $ cat hg.pid >> $DAEMON_PIDS
1060
1061
1061 check obsolete changeset
1062 check obsolete changeset
1062
1063
1063 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=paper' | grep '<span class="obsolete">'
1064 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=paper' | grep '<span class="obsolete">'
1064 <span class="phase">draft</span> <span class="obsolete">obsolete</span>
1065 <span class="phase">draft</span> <span class="obsolete">obsolete</span>
1065 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=coal' | grep '<span class="obsolete">'
1066 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=coal' | grep '<span class="obsolete">'
1066 <span class="phase">draft</span> <span class="obsolete">obsolete</span>
1067 <span class="phase">draft</span> <span class="obsolete">obsolete</span>
1067 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=gitweb' | grep '<span class="logtags">'
1068 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=gitweb' | grep '<span class="logtags">'
1068 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
1069 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
1069 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=monoblue' | grep '<span class="logtags">'
1070 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=monoblue' | grep '<span class="logtags">'
1070 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
1071 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="obsoletetag" title="obsolete">obsolete</span> </span>
1071 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=spartan' | grep 'class="obsolete"'
1072 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(obsolete())&style=spartan' | grep 'class="obsolete"'
1072 <th class="obsolete">obsolete:</th>
1073 <th class="obsolete">obsolete:</th>
1073 <td class="obsolete">pruned by &#116;&#101;&#115;&#116; <span class="age">Thu, 01 Jan 1970 00:00:00 +0000</span></td>
1074 <td class="obsolete">pruned by &#116;&#101;&#115;&#116; <span class="age">Thu, 01 Jan 1970 00:00:00 +0000</span></td>
1074
1075
1075 check changeset with instabilities
1076 check changeset with instabilities
1076
1077
1077 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=paper' | grep '<span class="instability">'
1078 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=paper' | grep '<span class="instability">'
1078 <span class="phase">draft</span> <span class="instability">orphan</span> <span class="instability">phase-divergent</span>
1079 <span class="phase">draft</span> <span class="instability">orphan</span> <span class="instability">phase-divergent</span>
1079 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=coal' | grep '<span class="instability">'
1080 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=coal' | grep '<span class="instability">'
1080 <span class="phase">draft</span> <span class="instability">orphan</span> <span class="instability">phase-divergent</span>
1081 <span class="phase">draft</span> <span class="instability">orphan</span> <span class="instability">phase-divergent</span>
1081 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=gitweb' | grep '<span class="logtags">'
1082 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=gitweb' | grep '<span class="logtags">'
1082 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="instabilitytag" title="orphan">orphan</span> <span class="instabilitytag" title="phase-divergent">phase-divergent</span> </span>
1083 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="instabilitytag" title="orphan">orphan</span> <span class="instabilitytag" title="phase-divergent">phase-divergent</span> </span>
1083 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=monoblue' | grep '<span class="logtags">'
1084 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=monoblue' | grep '<span class="logtags">'
1084 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="instabilitytag" title="orphan">orphan</span> <span class="instabilitytag" title="phase-divergent">phase-divergent</span> </span>
1085 <span class="logtags"><span class="phasetag" title="draft">draft</span> <span class="instabilitytag" title="orphan">orphan</span> <span class="instabilitytag" title="phase-divergent">phase-divergent</span> </span>
1085 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=spartan' | grep 'class="unstable"'
1086 $ get-with-headers.py localhost:$HGPORT 'log?rev=first(phasedivergent())&style=spartan' | grep 'class="unstable"'
1086 <th class="unstable">unstable:</th>
1087 <th class="unstable">unstable:</th>
1087 <td class="unstable">orphan: obsolete parent <a href="/rev/3de5eca88c00?style=spartan">3de5eca88c00</a></td>
1088 <td class="unstable">orphan: obsolete parent <a href="/rev/3de5eca88c00?style=spartan">3de5eca88c00</a></td>
1088 <th class="unstable">unstable:</th>
1089 <th class="unstable">unstable:</th>
1089 <td class="unstable">phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=spartan">245bde4270cd</a></td>
1090 <td class="unstable">phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=spartan">245bde4270cd</a></td>
1090
1091
1091 check explanation for an orphan and phase-divergent changeset
1092 check explanation for an orphan and phase-divergent changeset
1092
1093
1093 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=paper' | egrep '(orphan|phase-divergent):'
1094 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=paper' | egrep '(orphan|phase-divergent):'
1094 <td>orphan: obsolete parent <a href="/rev/3de5eca88c00?style=paper">3de5eca88c00</a><br>
1095 <td>orphan: obsolete parent <a href="/rev/3de5eca88c00?style=paper">3de5eca88c00</a><br>
1095 phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=paper">245bde4270cd</a></td>
1096 phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=paper">245bde4270cd</a></td>
1096 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=coal' | egrep '(orphan|phase-divergent):'
1097 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=coal' | egrep '(orphan|phase-divergent):'
1097 <td>orphan: obsolete parent <a href="/rev/3de5eca88c00?style=coal">3de5eca88c00</a><br>
1098 <td>orphan: obsolete parent <a href="/rev/3de5eca88c00?style=coal">3de5eca88c00</a><br>
1098 phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=coal">245bde4270cd</a></td>
1099 phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=coal">245bde4270cd</a></td>
1099 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=gitweb' | egrep '(orphan|phase-divergent):'
1100 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=gitweb' | egrep '(orphan|phase-divergent):'
1100 <td>orphan: obsolete parent <a class="list" href="/rev/3de5eca88c00?style=gitweb">3de5eca88c00</a></td>
1101 <td>orphan: obsolete parent <a class="list" href="/rev/3de5eca88c00?style=gitweb">3de5eca88c00</a></td>
1101 <td>phase-divergent: immutable predecessor <a class="list" href="/rev/245bde4270cd?style=gitweb">245bde4270cd</a></td>
1102 <td>phase-divergent: immutable predecessor <a class="list" href="/rev/245bde4270cd?style=gitweb">245bde4270cd</a></td>
1102 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=monoblue' | egrep '(orphan|phase-divergent):'
1103 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=monoblue' | egrep '(orphan|phase-divergent):'
1103 <dd>orphan: obsolete parent <a href="/rev/3de5eca88c00?style=monoblue">3de5eca88c00</a></dd>
1104 <dd>orphan: obsolete parent <a href="/rev/3de5eca88c00?style=monoblue">3de5eca88c00</a></dd>
1104 <dd>phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=monoblue">245bde4270cd</a></dd>
1105 <dd>phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=monoblue">245bde4270cd</a></dd>
1105 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=spartan' | egrep '(orphan|phase-divergent):'
1106 $ get-with-headers.py localhost:$HGPORT 'rev/50c51b361e60?style=spartan' | egrep '(orphan|phase-divergent):'
1106 <td class="unstable">orphan: obsolete parent <a href="/rev/3de5eca88c00?style=spartan">3de5eca88c00</a></td>
1107 <td class="unstable">orphan: obsolete parent <a href="/rev/3de5eca88c00?style=spartan">3de5eca88c00</a></td>
1107 <td class="unstable">phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=spartan">245bde4270cd</a></td>
1108 <td class="unstable">phase-divergent: immutable predecessor <a href="/rev/245bde4270cd?style=spartan">245bde4270cd</a></td>
1108
1109
1109 $ killdaemons.py
1110 $ killdaemons.py
1110
1111
1111 $ rm hg.pid access.log errors.log
1112 $ rm hg.pid access.log errors.log
1112
1113
1113 #endif
1114 #endif
1114
1115
1115 Test incoming/outcoming with changesets obsoleted remotely, known locally
1116 Test incoming/outcoming with changesets obsoleted remotely, known locally
1116 ===============================================================================
1117 ===============================================================================
1117
1118
1118 This test issue 3805
1119 This test issue 3805
1119
1120
1120 $ hg init repo-issue3805
1121 $ hg init repo-issue3805
1121 $ cd repo-issue3805
1122 $ cd repo-issue3805
1122 $ echo "base" > base
1123 $ echo "base" > base
1123 $ hg ci -Am "base"
1124 $ hg ci -Am "base"
1124 adding base
1125 adding base
1125 $ echo "foo" > foo
1126 $ echo "foo" > foo
1126 $ hg ci -Am "A"
1127 $ hg ci -Am "A"
1127 adding foo
1128 adding foo
1128 $ hg clone . ../other-issue3805
1129 $ hg clone . ../other-issue3805
1129 updating to branch default
1130 updating to branch default
1130 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1131 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
1131 $ echo "bar" >> foo
1132 $ echo "bar" >> foo
1132 $ hg ci --amend
1133 $ hg ci --amend
1133 $ cd ../other-issue3805
1134 $ cd ../other-issue3805
1134 $ hg log -G
1135 $ hg log -G
1135 @ 1:29f0c6921ddd (draft) [tip ] A
1136 @ 1:29f0c6921ddd (draft) [tip ] A
1136 |
1137 |
1137 o 0:d20a80d4def3 (draft) [ ] base
1138 o 0:d20a80d4def3 (draft) [ ] base
1138
1139
1139 $ hg log -G -R ../repo-issue3805
1140 $ hg log -G -R ../repo-issue3805
1140 @ 2:323a9c3ddd91 (draft) [tip ] A
1141 @ 2:323a9c3ddd91 (draft) [tip ] A
1141 |
1142 |
1142 o 0:d20a80d4def3 (draft) [ ] base
1143 o 0:d20a80d4def3 (draft) [ ] base
1143
1144
1144 $ hg incoming
1145 $ hg incoming
1145 comparing with $TESTTMP/tmpe/repo-issue3805
1146 comparing with $TESTTMP/tmpe/repo-issue3805
1146 searching for changes
1147 searching for changes
1147 2:323a9c3ddd91 (draft) [tip ] A
1148 2:323a9c3ddd91 (draft) [tip ] A
1148 $ hg incoming --bundle ../issue3805.hg
1149 $ hg incoming --bundle ../issue3805.hg
1149 comparing with $TESTTMP/tmpe/repo-issue3805
1150 comparing with $TESTTMP/tmpe/repo-issue3805
1150 searching for changes
1151 searching for changes
1151 2:323a9c3ddd91 (draft) [tip ] A
1152 2:323a9c3ddd91 (draft) [tip ] A
1152 $ hg outgoing
1153 $ hg outgoing
1153 comparing with $TESTTMP/tmpe/repo-issue3805
1154 comparing with $TESTTMP/tmpe/repo-issue3805
1154 searching for changes
1155 searching for changes
1155 1:29f0c6921ddd (draft) [tip ] A
1156 1:29f0c6921ddd (draft) [tip ] A
1156
1157
1157 #if serve
1158 #if serve
1158
1159
1159 $ hg serve -R ../repo-issue3805 -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1160 $ hg serve -R ../repo-issue3805 -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1160 $ cat hg.pid >> $DAEMON_PIDS
1161 $ cat hg.pid >> $DAEMON_PIDS
1161
1162
1162 $ hg incoming http://localhost:$HGPORT
1163 $ hg incoming http://localhost:$HGPORT
1163 comparing with http://localhost:$HGPORT/
1164 comparing with http://localhost:$HGPORT/
1164 searching for changes
1165 searching for changes
1165 2:323a9c3ddd91 (draft) [tip ] A
1166 2:323a9c3ddd91 (draft) [tip ] A
1166 $ hg outgoing http://localhost:$HGPORT
1167 $ hg outgoing http://localhost:$HGPORT
1167 comparing with http://localhost:$HGPORT/
1168 comparing with http://localhost:$HGPORT/
1168 searching for changes
1169 searching for changes
1169 1:29f0c6921ddd (draft) [tip ] A
1170 1:29f0c6921ddd (draft) [tip ] A
1170
1171
1171 $ killdaemons.py
1172 $ killdaemons.py
1172
1173
1173 #endif
1174 #endif
1174
1175
1175 This test issue 3814
1176 This test issue 3814
1176
1177
1177 (nothing to push but locally hidden changeset)
1178 (nothing to push but locally hidden changeset)
1178
1179
1179 $ cd ..
1180 $ cd ..
1180 $ hg init repo-issue3814
1181 $ hg init repo-issue3814
1181 $ cd repo-issue3805
1182 $ cd repo-issue3805
1182 $ hg push -r 323a9c3ddd91 ../repo-issue3814
1183 $ hg push -r 323a9c3ddd91 ../repo-issue3814
1183 pushing to ../repo-issue3814
1184 pushing to ../repo-issue3814
1184 searching for changes
1185 searching for changes
1185 adding changesets
1186 adding changesets
1186 adding manifests
1187 adding manifests
1187 adding file changes
1188 adding file changes
1188 added 2 changesets with 2 changes to 2 files
1189 added 2 changesets with 2 changes to 2 files
1189 1 new obsolescence markers
1190 1 new obsolescence markers
1190 $ hg out ../repo-issue3814
1191 $ hg out ../repo-issue3814
1191 comparing with ../repo-issue3814
1192 comparing with ../repo-issue3814
1192 searching for changes
1193 searching for changes
1193 no changes found
1194 no changes found
1194 [1]
1195 [1]
1195
1196
1196 Test that a local tag blocks a changeset from being hidden
1197 Test that a local tag blocks a changeset from being hidden
1197
1198
1198 $ hg tag -l visible -r 1 --hidden
1199 $ hg tag -l visible -r 1 --hidden
1199 $ hg log -G
1200 $ hg log -G
1200 @ 2:323a9c3ddd91 (draft) [tip ] A
1201 @ 2:323a9c3ddd91 (draft) [tip ] A
1201 |
1202 |
1202 | x 1:29f0c6921ddd (draft *obsolete*) [visible ] A [rewritten using amend as 2:323a9c3ddd91]
1203 | x 1:29f0c6921ddd (draft *obsolete*) [visible ] A [rewritten using amend as 2:323a9c3ddd91]
1203 |/
1204 |/
1204 o 0:d20a80d4def3 (draft) [ ] base
1205 o 0:d20a80d4def3 (draft) [ ] base
1205
1206
1206 Test that removing a local tag does not cause some commands to fail
1207 Test that removing a local tag does not cause some commands to fail
1207
1208
1208 $ hg tag -l -r tip tiptag
1209 $ hg tag -l -r tip tiptag
1209 $ hg tags
1210 $ hg tags
1210 tiptag 2:323a9c3ddd91
1211 tiptag 2:323a9c3ddd91
1211 tip 2:323a9c3ddd91
1212 tip 2:323a9c3ddd91
1212 visible 1:29f0c6921ddd
1213 visible 1:29f0c6921ddd
1213 $ hg --config extensions.strip= strip -r tip --no-backup
1214 $ hg --config extensions.strip= strip -r tip --no-backup
1214 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1215 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1215 $ hg tags
1216 $ hg tags
1216 visible 1:29f0c6921ddd
1217 visible 1:29f0c6921ddd
1217 tip 1:29f0c6921ddd
1218 tip 1:29f0c6921ddd
1218
1219
1219 Test bundle overlay onto hidden revision
1220 Test bundle overlay onto hidden revision
1220
1221
1221 $ cd ..
1222 $ cd ..
1222 $ hg init repo-bundleoverlay
1223 $ hg init repo-bundleoverlay
1223 $ cd repo-bundleoverlay
1224 $ cd repo-bundleoverlay
1224 $ echo "A" > foo
1225 $ echo "A" > foo
1225 $ hg ci -Am "A"
1226 $ hg ci -Am "A"
1226 adding foo
1227 adding foo
1227 $ echo "B" >> foo
1228 $ echo "B" >> foo
1228 $ hg ci -m "B"
1229 $ hg ci -m "B"
1229 $ hg up 0
1230 $ hg up 0
1230 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1231 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1231 $ echo "C" >> foo
1232 $ echo "C" >> foo
1232 $ hg ci -m "C"
1233 $ hg ci -m "C"
1233 created new head
1234 created new head
1234 $ hg log -G
1235 $ hg log -G
1235 @ 2:c186d7714947 (draft) [tip ] C
1236 @ 2:c186d7714947 (draft) [tip ] C
1236 |
1237 |
1237 | o 1:44526ebb0f98 (draft) [ ] B
1238 | o 1:44526ebb0f98 (draft) [ ] B
1238 |/
1239 |/
1239 o 0:4b34ecfb0d56 (draft) [ ] A
1240 o 0:4b34ecfb0d56 (draft) [ ] A
1240
1241
1241
1242
1242 $ hg clone -r1 . ../other-bundleoverlay
1243 $ hg clone -r1 . ../other-bundleoverlay
1243 adding changesets
1244 adding changesets
1244 adding manifests
1245 adding manifests
1245 adding file changes
1246 adding file changes
1246 added 2 changesets with 2 changes to 1 files
1247 added 2 changesets with 2 changes to 1 files
1247 new changesets 4b34ecfb0d56:44526ebb0f98 (2 drafts)
1248 new changesets 4b34ecfb0d56:44526ebb0f98 (2 drafts)
1248 updating to branch default
1249 updating to branch default
1249 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1250 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
1250 $ cd ../other-bundleoverlay
1251 $ cd ../other-bundleoverlay
1251 $ echo "B+" >> foo
1252 $ echo "B+" >> foo
1252 $ hg ci --amend -m "B+"
1253 $ hg ci --amend -m "B+"
1253 $ hg log -G --hidden
1254 $ hg log -G --hidden
1254 @ 2:b7d587542d40 (draft) [tip ] B+
1255 @ 2:b7d587542d40 (draft) [tip ] B+
1255 |
1256 |
1256 | x 1:44526ebb0f98 (draft *obsolete*) [ ] B [rewritten using amend as 2:b7d587542d40]
1257 | x 1:44526ebb0f98 (draft *obsolete*) [ ] B [rewritten using amend as 2:b7d587542d40]
1257 |/
1258 |/
1258 o 0:4b34ecfb0d56 (draft) [ ] A
1259 o 0:4b34ecfb0d56 (draft) [ ] A
1259
1260
1260
1261
1261 #if repobundlerepo
1262 #if repobundlerepo
1262 $ hg incoming ../repo-bundleoverlay --bundle ../bundleoverlay.hg
1263 $ hg incoming ../repo-bundleoverlay --bundle ../bundleoverlay.hg
1263 comparing with ../repo-bundleoverlay
1264 comparing with ../repo-bundleoverlay
1264 searching for changes
1265 searching for changes
1265 1:44526ebb0f98 (draft) [ ] B
1266 1:44526ebb0f98 (draft) [ ] B
1266 2:c186d7714947 (draft) [tip ] C
1267 2:c186d7714947 (draft) [tip ] C
1267 $ hg log -G -R ../bundleoverlay.hg
1268 $ hg log -G -R ../bundleoverlay.hg
1268 o 3:c186d7714947 (draft) [tip ] C
1269 o 3:c186d7714947 (draft) [tip ] C
1269 |
1270 |
1270 | @ 2:b7d587542d40 (draft) [ ] B+
1271 | @ 2:b7d587542d40 (draft) [ ] B+
1271 |/
1272 |/
1272 o 0:4b34ecfb0d56 (draft) [ ] A
1273 o 0:4b34ecfb0d56 (draft) [ ] A
1273
1274
1274 #endif
1275 #endif
1275
1276
1276 #if serve
1277 #if serve
1277
1278
1278 Test issue 4506
1279 Test issue 4506
1279
1280
1280 $ cd ..
1281 $ cd ..
1281 $ hg init repo-issue4506
1282 $ hg init repo-issue4506
1282 $ cd repo-issue4506
1283 $ cd repo-issue4506
1283 $ echo "0" > foo
1284 $ echo "0" > foo
1284 $ hg add foo
1285 $ hg add foo
1285 $ hg ci -m "content-0"
1286 $ hg ci -m "content-0"
1286
1287
1287 $ hg up null
1288 $ hg up null
1288 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1289 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1289 $ echo "1" > bar
1290 $ echo "1" > bar
1290 $ hg add bar
1291 $ hg add bar
1291 $ hg ci -m "content-1"
1292 $ hg ci -m "content-1"
1292 created new head
1293 created new head
1293 $ hg up 0
1294 $ hg up 0
1294 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1295 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
1295 $ hg graft 1
1296 $ hg graft 1
1296 grafting 1:1c9eddb02162 "content-1" (tip)
1297 grafting 1:1c9eddb02162 "content-1" (tip)
1297
1298
1298 $ hg debugobsolete `hg log -r1 -T'{node}'` `hg log -r2 -T'{node}'`
1299 $ hg debugobsolete `hg log -r1 -T'{node}'` `hg log -r2 -T'{node}'`
1299 obsoleted 1 changesets
1300 obsoleted 1 changesets
1300
1301
1301 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1302 $ hg serve -n test -p $HGPORT -d --pid-file=hg.pid -A access.log -E errors.log
1302 $ cat hg.pid >> $DAEMON_PIDS
1303 $ cat hg.pid >> $DAEMON_PIDS
1303
1304
1304 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/1'
1305 $ get-with-headers.py --headeronly localhost:$HGPORT 'rev/1'
1305 404 Not Found
1306 404 Not Found
1306 [1]
1307 [1]
1307 $ get-with-headers.py --headeronly localhost:$HGPORT 'file/tip/bar'
1308 $ get-with-headers.py --headeronly localhost:$HGPORT 'file/tip/bar'
1308 200 Script output follows
1309 200 Script output follows
1309 $ get-with-headers.py --headeronly localhost:$HGPORT 'annotate/tip/bar'
1310 $ get-with-headers.py --headeronly localhost:$HGPORT 'annotate/tip/bar'
1310 200 Script output follows
1311 200 Script output follows
1311
1312
1312 $ killdaemons.py
1313 $ killdaemons.py
1313
1314
1314 #endif
1315 #endif
1315
1316
1316 Test heads computation on pending index changes with obsolescence markers
1317 Test heads computation on pending index changes with obsolescence markers
1317 $ cd ..
1318 $ cd ..
1318 $ cat >$TESTTMP/test_extension.py << EOF
1319 $ cat >$TESTTMP/test_extension.py << EOF
1319 > from __future__ import absolute_import
1320 > from __future__ import absolute_import
1320 > from mercurial.i18n import _
1321 > from mercurial.i18n import _
1321 > from mercurial import cmdutil, pycompat, registrar
1322 > from mercurial import cmdutil, pycompat, registrar
1322 > from mercurial.utils import stringutil
1323 > from mercurial.utils import stringutil
1323 >
1324 >
1324 > cmdtable = {}
1325 > cmdtable = {}
1325 > command = registrar.command(cmdtable)
1326 > command = registrar.command(cmdtable)
1326 > @command(b"amendtransient",[], _(b'hg amendtransient [rev]'))
1327 > @command(b"amendtransient",[], _(b'hg amendtransient [rev]'))
1327 > def amend(ui, repo, *pats, **opts):
1328 > def amend(ui, repo, *pats, **opts):
1328 > opts = pycompat.byteskwargs(opts)
1329 > opts = pycompat.byteskwargs(opts)
1329 > opts[b'message'] = b'Test'
1330 > opts[b'message'] = b'Test'
1330 > opts[b'logfile'] = None
1331 > opts[b'logfile'] = None
1331 > cmdutil.amend(ui, repo, repo[b'.'], {}, pats, opts)
1332 > cmdutil.amend(ui, repo, repo[b'.'], {}, pats, opts)
1332 > ui.write(b'%s\n' % stringutil.pprint(repo.changelog.headrevs()))
1333 > ui.write(b'%s\n' % stringutil.pprint(repo.changelog.headrevs()))
1333 > EOF
1334 > EOF
1334 $ cat >> $HGRCPATH << EOF
1335 $ cat >> $HGRCPATH << EOF
1335 > [extensions]
1336 > [extensions]
1336 > testextension=$TESTTMP/test_extension.py
1337 > testextension=$TESTTMP/test_extension.py
1337 > EOF
1338 > EOF
1338 $ hg init repo-issue-nativerevs-pending-changes
1339 $ hg init repo-issue-nativerevs-pending-changes
1339 $ cd repo-issue-nativerevs-pending-changes
1340 $ cd repo-issue-nativerevs-pending-changes
1340 $ mkcommit a
1341 $ mkcommit a
1341 $ mkcommit b
1342 $ mkcommit b
1342 $ hg up ".^"
1343 $ hg up ".^"
1343 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1344 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1344 $ echo aa > a
1345 $ echo aa > a
1345 $ hg amendtransient
1346 $ hg amendtransient
1346 1 new orphan changesets
1347 1 new orphan changesets
1347 [1, 2]
1348 [1, 2]
1348
1349
1349 Test cache consistency for the visible filter
1350 Test cache consistency for the visible filter
1350 1) We want to make sure that the cached filtered revs are invalidated when
1351 1) We want to make sure that the cached filtered revs are invalidated when
1351 bookmarks change
1352 bookmarks change
1352 $ cd ..
1353 $ cd ..
1353 $ cat >$TESTTMP/test_extension.py << EOF
1354 $ cat >$TESTTMP/test_extension.py << EOF
1354 > from __future__ import absolute_import, print_function
1355 > from __future__ import absolute_import, print_function
1355 > import weakref
1356 > import weakref
1356 > from mercurial import (
1357 > from mercurial import (
1357 > bookmarks,
1358 > bookmarks,
1358 > cmdutil,
1359 > cmdutil,
1359 > extensions,
1360 > extensions,
1360 > repoview,
1361 > repoview,
1361 > )
1362 > )
1362 > def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
1363 > def _bookmarkchanged(orig, bkmstoreinst, *args, **kwargs):
1363 > reporef = weakref.ref(bkmstoreinst._repo)
1364 > reporef = weakref.ref(bkmstoreinst._repo)
1364 > def trhook(tr):
1365 > def trhook(tr):
1365 > repo = reporef()
1366 > repo = reporef()
1366 > hidden1 = repoview.computehidden(repo)
1367 > hidden1 = repoview.computehidden(repo)
1367 > hidden = repoview.filterrevs(repo, b'visible')
1368 > hidden = repoview.filterrevs(repo, b'visible')
1368 > if sorted(hidden1) != sorted(hidden):
1369 > if sorted(hidden1) != sorted(hidden):
1369 > print("cache inconsistency")
1370 > print("cache inconsistency")
1370 > bkmstoreinst._repo.currenttransaction().addpostclose(b'test_extension', trhook)
1371 > bkmstoreinst._repo.currenttransaction().addpostclose(b'test_extension', trhook)
1371 > orig(bkmstoreinst, *args, **kwargs)
1372 > orig(bkmstoreinst, *args, **kwargs)
1372 > def extsetup(ui):
1373 > def extsetup(ui):
1373 > extensions.wrapfunction(bookmarks.bmstore, '_recordchange',
1374 > extensions.wrapfunction(bookmarks.bmstore, '_recordchange',
1374 > _bookmarkchanged)
1375 > _bookmarkchanged)
1375 > EOF
1376 > EOF
1376
1377
1377 $ hg init repo-cache-inconsistency
1378 $ hg init repo-cache-inconsistency
1378 $ cd repo-issue-nativerevs-pending-changes
1379 $ cd repo-issue-nativerevs-pending-changes
1379 $ mkcommit a
1380 $ mkcommit a
1380 a already tracked!
1381 a already tracked!
1381 $ mkcommit b
1382 $ mkcommit b
1382 $ hg id
1383 $ hg id
1383 13bedc178fce tip
1384 13bedc178fce tip
1384 $ echo "hello" > b
1385 $ echo "hello" > b
1385 $ hg commit --amend -m "message"
1386 $ hg commit --amend -m "message"
1386 $ hg book bookb -r 13bedc178fce --hidden
1387 $ hg book bookb -r 13bedc178fce --hidden
1387 bookmarking hidden changeset 13bedc178fce
1388 bookmarking hidden changeset 13bedc178fce
1388 (hidden revision '13bedc178fce' was rewritten as: a9b1f8652753)
1389 (hidden revision '13bedc178fce' was rewritten as: a9b1f8652753)
1389 $ hg log -r 13bedc178fce
1390 $ hg log -r 13bedc178fce
1390 4:13bedc178fce (draft *obsolete*) [ bookb] add b [rewritten using amend as 5:a9b1f8652753]
1391 4:13bedc178fce (draft *obsolete*) [ bookb] add b [rewritten using amend as 5:a9b1f8652753]
1391 $ hg book -d bookb
1392 $ hg book -d bookb
1392 $ hg log -r 13bedc178fce
1393 $ hg log -r 13bedc178fce
1393 abort: hidden revision '13bedc178fce' was rewritten as: a9b1f8652753!
1394 abort: hidden revision '13bedc178fce' was rewritten as: a9b1f8652753!
1394 (use --hidden to access hidden revisions)
1395 (use --hidden to access hidden revisions)
1395 [255]
1396 [255]
1396
1397
1397 Empty out the test extension, as it isn't compatible with later parts
1398 Empty out the test extension, as it isn't compatible with later parts
1398 of the test.
1399 of the test.
1399 $ echo > $TESTTMP/test_extension.py
1400 $ echo > $TESTTMP/test_extension.py
1400
1401
1401 Test ability to pull changeset with locally applying obsolescence markers
1402 Test ability to pull changeset with locally applying obsolescence markers
1402 (issue4945)
1403 (issue4945)
1403
1404
1404 $ cd ..
1405 $ cd ..
1405 $ hg init issue4845
1406 $ hg init issue4845
1406 $ cd issue4845
1407 $ cd issue4845
1407
1408
1408 $ echo foo > f0
1409 $ echo foo > f0
1409 $ hg add f0
1410 $ hg add f0
1410 $ hg ci -m '0'
1411 $ hg ci -m '0'
1411 $ echo foo > f1
1412 $ echo foo > f1
1412 $ hg add f1
1413 $ hg add f1
1413 $ hg ci -m '1'
1414 $ hg ci -m '1'
1414 $ echo foo > f2
1415 $ echo foo > f2
1415 $ hg add f2
1416 $ hg add f2
1416 $ hg ci -m '2'
1417 $ hg ci -m '2'
1417
1418
1418 $ echo bar > f2
1419 $ echo bar > f2
1419 $ hg commit --amend --config experimental.evolution.createmarkers=True
1420 $ hg commit --amend --config experimental.evolution.createmarkers=True
1420 $ hg log -G
1421 $ hg log -G
1421 @ 3:b0551702f918 (draft) [tip ] 2
1422 @ 3:b0551702f918 (draft) [tip ] 2
1422 |
1423 |
1423 o 1:e016b03fd86f (draft) [ ] 1
1424 o 1:e016b03fd86f (draft) [ ] 1
1424 |
1425 |
1425 o 0:a78f55e5508c (draft) [ ] 0
1426 o 0:a78f55e5508c (draft) [ ] 0
1426
1427
1427 $ hg log -G --hidden
1428 $ hg log -G --hidden
1428 @ 3:b0551702f918 (draft) [tip ] 2
1429 @ 3:b0551702f918 (draft) [tip ] 2
1429 |
1430 |
1430 | x 2:e008cf283490 (draft *obsolete*) [ ] 2 [rewritten using amend as 3:b0551702f918]
1431 | x 2:e008cf283490 (draft *obsolete*) [ ] 2 [rewritten using amend as 3:b0551702f918]
1431 |/
1432 |/
1432 o 1:e016b03fd86f (draft) [ ] 1
1433 o 1:e016b03fd86f (draft) [ ] 1
1433 |
1434 |
1434 o 0:a78f55e5508c (draft) [ ] 0
1435 o 0:a78f55e5508c (draft) [ ] 0
1435
1436
1436
1437
1437 $ hg strip --hidden -r 2 --config extensions.strip= --config devel.strip-obsmarkers=no
1438 $ hg strip --hidden -r 2 --config extensions.strip= --config devel.strip-obsmarkers=no
1438 saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e008cf283490-ede36964-backup.hg
1439 saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e008cf283490-ede36964-backup.hg
1439 $ hg debugobsolete
1440 $ hg debugobsolete
1440 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1441 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1441 $ hg log -G
1442 $ hg log -G
1442 @ 2:b0551702f918 (draft) [tip ] 2
1443 @ 2:b0551702f918 (draft) [tip ] 2
1443 |
1444 |
1444 o 1:e016b03fd86f (draft) [ ] 1
1445 o 1:e016b03fd86f (draft) [ ] 1
1445 |
1446 |
1446 o 0:a78f55e5508c (draft) [ ] 0
1447 o 0:a78f55e5508c (draft) [ ] 0
1447
1448
1448 $ hg log -G --hidden
1449 $ hg log -G --hidden
1449 @ 2:b0551702f918 (draft) [tip ] 2
1450 @ 2:b0551702f918 (draft) [tip ] 2
1450 |
1451 |
1451 o 1:e016b03fd86f (draft) [ ] 1
1452 o 1:e016b03fd86f (draft) [ ] 1
1452 |
1453 |
1453 o 0:a78f55e5508c (draft) [ ] 0
1454 o 0:a78f55e5508c (draft) [ ] 0
1454
1455
1455 $ hg debugbundle .hg/strip-backup/e008cf283490-*-backup.hg
1456 $ hg debugbundle .hg/strip-backup/e008cf283490-*-backup.hg
1456 Stream params: {Compression: BZ}
1457 Stream params: {Compression: BZ}
1457 changegroup -- {nbchanges: 1, version: 02} (mandatory: True)
1458 changegroup -- {nbchanges: 1, version: 02} (mandatory: True)
1458 e008cf2834908e5d6b0f792a9d4b0e2272260fb8
1459 e008cf2834908e5d6b0f792a9d4b0e2272260fb8
1459 cache:rev-branch-cache -- {} (mandatory: False)
1460 cache:rev-branch-cache -- {} (mandatory: False)
1460 phase-heads -- {} (mandatory: True)
1461 phase-heads -- {} (mandatory: True)
1461 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 draft
1462 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 draft
1462
1463
1463 #if repobundlerepo
1464 #if repobundlerepo
1464 $ hg pull .hg/strip-backup/e008cf283490-*-backup.hg
1465 $ hg pull .hg/strip-backup/e008cf283490-*-backup.hg
1465 pulling from .hg/strip-backup/e008cf283490-ede36964-backup.hg
1466 pulling from .hg/strip-backup/e008cf283490-ede36964-backup.hg
1466 searching for changes
1467 searching for changes
1467 no changes found
1468 no changes found
1468 #endif
1469 #endif
1469 $ hg debugobsolete
1470 $ hg debugobsolete
1470 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1471 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1471 $ hg log -G
1472 $ hg log -G
1472 @ 2:b0551702f918 (draft) [tip ] 2
1473 @ 2:b0551702f918 (draft) [tip ] 2
1473 |
1474 |
1474 o 1:e016b03fd86f (draft) [ ] 1
1475 o 1:e016b03fd86f (draft) [ ] 1
1475 |
1476 |
1476 o 0:a78f55e5508c (draft) [ ] 0
1477 o 0:a78f55e5508c (draft) [ ] 0
1477
1478
1478 $ hg log -G --hidden
1479 $ hg log -G --hidden
1479 @ 2:b0551702f918 (draft) [tip ] 2
1480 @ 2:b0551702f918 (draft) [tip ] 2
1480 |
1481 |
1481 o 1:e016b03fd86f (draft) [ ] 1
1482 o 1:e016b03fd86f (draft) [ ] 1
1482 |
1483 |
1483 o 0:a78f55e5508c (draft) [ ] 0
1484 o 0:a78f55e5508c (draft) [ ] 0
1484
1485
1485
1486
1486 Testing that strip remove markers:
1487 Testing that strip remove markers:
1487
1488
1488 $ hg strip -r 1 --config extensions.strip=
1489 $ hg strip -r 1 --config extensions.strip=
1489 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1490 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
1490 saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e016b03fd86f-65ede734-backup.hg
1491 saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e016b03fd86f-65ede734-backup.hg
1491 $ hg debugobsolete
1492 $ hg debugobsolete
1492 $ hg log -G
1493 $ hg log -G
1493 @ 0:a78f55e5508c (draft) [tip ] 0
1494 @ 0:a78f55e5508c (draft) [tip ] 0
1494
1495
1495 $ hg log -G --hidden
1496 $ hg log -G --hidden
1496 @ 0:a78f55e5508c (draft) [tip ] 0
1497 @ 0:a78f55e5508c (draft) [tip ] 0
1497
1498
1498 $ hg debugbundle .hg/strip-backup/e016b03fd86f-*-backup.hg
1499 $ hg debugbundle .hg/strip-backup/e016b03fd86f-*-backup.hg
1499 Stream params: {Compression: BZ}
1500 Stream params: {Compression: BZ}
1500 changegroup -- {nbchanges: 2, version: 02} (mandatory: True)
1501 changegroup -- {nbchanges: 2, version: 02} (mandatory: True)
1501 e016b03fd86fcccc54817d120b90b751aaf367d6
1502 e016b03fd86fcccc54817d120b90b751aaf367d6
1502 b0551702f918510f01ae838ab03a463054c67b46
1503 b0551702f918510f01ae838ab03a463054c67b46
1503 cache:rev-branch-cache -- {} (mandatory: False)
1504 cache:rev-branch-cache -- {} (mandatory: False)
1504 obsmarkers -- {} (mandatory: True)
1505 obsmarkers -- {} (mandatory: True)
1505 version: 1 (92 bytes)
1506 version: 1 (92 bytes)
1506 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1507 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1507 phase-heads -- {} (mandatory: True)
1508 phase-heads -- {} (mandatory: True)
1508 b0551702f918510f01ae838ab03a463054c67b46 draft
1509 b0551702f918510f01ae838ab03a463054c67b46 draft
1509
1510
1510 $ hg unbundle .hg/strip-backup/e016b03fd86f-*-backup.hg
1511 $ hg unbundle .hg/strip-backup/e016b03fd86f-*-backup.hg
1511 adding changesets
1512 adding changesets
1512 adding manifests
1513 adding manifests
1513 adding file changes
1514 adding file changes
1514 added 2 changesets with 2 changes to 2 files
1515 added 2 changesets with 2 changes to 2 files
1515 1 new obsolescence markers
1516 1 new obsolescence markers
1516 new changesets e016b03fd86f:b0551702f918 (2 drafts)
1517 new changesets e016b03fd86f:b0551702f918 (2 drafts)
1517 (run 'hg update' to get a working copy)
1518 (run 'hg update' to get a working copy)
1518 $ hg debugobsolete | sort
1519 $ hg debugobsolete | sort
1519 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1520 e008cf2834908e5d6b0f792a9d4b0e2272260fb8 b0551702f918510f01ae838ab03a463054c67b46 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
1520 $ hg log -G
1521 $ hg log -G
1521 o 2:b0551702f918 (draft) [tip ] 2
1522 o 2:b0551702f918 (draft) [tip ] 2
1522 |
1523 |
1523 o 1:e016b03fd86f (draft) [ ] 1
1524 o 1:e016b03fd86f (draft) [ ] 1
1524 |
1525 |
1525 @ 0:a78f55e5508c (draft) [ ] 0
1526 @ 0:a78f55e5508c (draft) [ ] 0
1526
1527
1527 $ hg log -G --hidden
1528 $ hg log -G --hidden
1528 o 2:b0551702f918 (draft) [tip ] 2
1529 o 2:b0551702f918 (draft) [tip ] 2
1529 |
1530 |
1530 o 1:e016b03fd86f (draft) [ ] 1
1531 o 1:e016b03fd86f (draft) [ ] 1
1531 |
1532 |
1532 @ 0:a78f55e5508c (draft) [ ] 0
1533 @ 0:a78f55e5508c (draft) [ ] 0
1533
1534
1534 Test that 'hg debugobsolete --index --rev' can show indices of obsmarkers when
1535 Test that 'hg debugobsolete --index --rev' can show indices of obsmarkers when
1535 only a subset of those are displayed (because of --rev option)
1536 only a subset of those are displayed (because of --rev option)
1536 $ hg init doindexrev
1537 $ hg init doindexrev
1537 $ cd doindexrev
1538 $ cd doindexrev
1538 $ echo a > a
1539 $ echo a > a
1539 $ hg ci -Am a
1540 $ hg ci -Am a
1540 adding a
1541 adding a
1541 $ hg ci --amend -m aa
1542 $ hg ci --amend -m aa
1542 $ echo b > b
1543 $ echo b > b
1543 $ hg ci -Am b
1544 $ hg ci -Am b
1544 adding b
1545 adding b
1545 $ hg ci --amend -m bb
1546 $ hg ci --amend -m bb
1546 $ echo c > c
1547 $ echo c > c
1547 $ hg ci -Am c
1548 $ hg ci -Am c
1548 adding c
1549 adding c
1549 $ hg ci --amend -m cc
1550 $ hg ci --amend -m cc
1550 $ echo d > d
1551 $ echo d > d
1551 $ hg ci -Am d
1552 $ hg ci -Am d
1552 adding d
1553 adding d
1553 $ hg ci --amend -m dd --config experimental.evolution.track-operation=1
1554 $ hg ci --amend -m dd --config experimental.evolution.track-operation=1
1554 $ hg debugobsolete --index --rev "3+7"
1555 $ hg debugobsolete --index --rev "3+7"
1555 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1556 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1556 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1557 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1557 $ hg debugobsolete --index --rev "3+7" -Tjson
1558 $ hg debugobsolete --index --rev "3+7" -Tjson
1558 [
1559 [
1559 {
1560 {
1560 "date": [0, 0],
1561 "date": [0, 0],
1561 "flag": 0,
1562 "flag": 0,
1562 "index": 1,
1563 "index": 1,
1563 "metadata": {"ef1": "1", "operation": "amend", "user": "test"},
1564 "metadata": {"ef1": "1", "operation": "amend", "user": "test"},
1564 "prednode": "6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1",
1565 "prednode": "6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1",
1565 "succnodes": ["d27fb9b066076fd921277a4b9e8b9cb48c95bc6a"]
1566 "succnodes": ["d27fb9b066076fd921277a4b9e8b9cb48c95bc6a"]
1566 },
1567 },
1567 {
1568 {
1568 "date": [0, 0],
1569 "date": [0, 0],
1569 "flag": 0,
1570 "flag": 0,
1570 "index": 3,
1571 "index": 3,
1571 "metadata": {"ef1": "1", "operation": "amend", "user": "test"},
1572 "metadata": {"ef1": "1", "operation": "amend", "user": "test"},
1572 "prednode": "4715cf767440ed891755448016c2b8cf70760c30",
1573 "prednode": "4715cf767440ed891755448016c2b8cf70760c30",
1573 "succnodes": ["7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d"]
1574 "succnodes": ["7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d"]
1574 }
1575 }
1575 ]
1576 ]
1576
1577
1577 Test the --delete option of debugobsolete command
1578 Test the --delete option of debugobsolete command
1578 $ hg debugobsolete --index
1579 $ hg debugobsolete --index
1579 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1580 0 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1580 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1581 1 6fdef60fcbabbd3d50e9b9cbc2a240724b91a5e1 d27fb9b066076fd921277a4b9e8b9cb48c95bc6a 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1581 2 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1582 2 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1582 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1583 3 4715cf767440ed891755448016c2b8cf70760c30 7ae79c5d60f049c7b0dd02f5f25b9d60aaf7b36d 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1583 $ hg debugobsolete --delete 1 --delete 3
1584 $ hg debugobsolete --delete 1 --delete 3
1584 deleted 2 obsolescence markers
1585 deleted 2 obsolescence markers
1585 $ hg debugobsolete
1586 $ hg debugobsolete
1586 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1587 cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b f9bd49731b0b175e42992a3c8fa6c678b2bc11f1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1587 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1588 1ab51af8f9b41ef8c7f6f3312d4706d870b1fb74 29346082e4a9e27042b62d2da0e2de211c027621 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'amend', 'user': 'test'}
1588
1589
1589 Test adding changeset after obsmarkers affecting it
1590 Test adding changeset after obsmarkers affecting it
1590 (eg: during pull, or unbundle)
1591 (eg: during pull, or unbundle)
1591
1592
1592 $ mkcommit e
1593 $ mkcommit e
1593 $ hg bundle -r . --base .~1 ../bundle-2.hg
1594 $ hg bundle -r . --base .~1 ../bundle-2.hg
1594 1 changesets found
1595 1 changesets found
1595 $ getid .
1596 $ getid .
1596 $ hg --config extensions.strip= strip -r .
1597 $ hg --config extensions.strip= strip -r .
1597 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1598 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
1598 saved backup bundle to $TESTTMP/tmpe/issue4845/doindexrev/.hg/strip-backup/9bc153528424-ee80edd4-backup.hg
1599 saved backup bundle to $TESTTMP/tmpe/issue4845/doindexrev/.hg/strip-backup/9bc153528424-ee80edd4-backup.hg
1599 $ hg debugobsolete 9bc153528424ea266d13e57f9ff0d799dfe61e4b
1600 $ hg debugobsolete 9bc153528424ea266d13e57f9ff0d799dfe61e4b
1600 $ hg unbundle ../bundle-2.hg
1601 $ hg unbundle ../bundle-2.hg
1601 adding changesets
1602 adding changesets
1602 adding manifests
1603 adding manifests
1603 adding file changes
1604 adding file changes
1604 added 1 changesets with 1 changes to 1 files
1605 added 1 changesets with 1 changes to 1 files
1605 (1 other changesets obsolete on arrival)
1606 (1 other changesets obsolete on arrival)
1606 (run 'hg update' to get a working copy)
1607 (run 'hg update' to get a working copy)
1607 $ hg log -G
1608 $ hg log -G
1608 @ 7:7ae79c5d60f0 (draft) [tip ] dd
1609 @ 7:7ae79c5d60f0 (draft) [tip ] dd
1609 |
1610 |
1610 | o 6:4715cf767440 (draft) [ ] d
1611 | o 6:4715cf767440 (draft) [ ] d
1611 |/
1612 |/
1612 o 5:29346082e4a9 (draft) [ ] cc
1613 o 5:29346082e4a9 (draft) [ ] cc
1613 |
1614 |
1614 o 3:d27fb9b06607 (draft) [ ] bb
1615 o 3:d27fb9b06607 (draft) [ ] bb
1615 |
1616 |
1616 | o 2:6fdef60fcbab (draft) [ ] b
1617 | o 2:6fdef60fcbab (draft) [ ] b
1617 |/
1618 |/
1618 o 1:f9bd49731b0b (draft) [ ] aa
1619 o 1:f9bd49731b0b (draft) [ ] aa
1619
1620
1620
1621
1621 $ cd ..
1622 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now